| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can be | |
| 4 * found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 #include "native_client/src/trusted/service_runtime/name_service/default_name_se
rvice.h" | |
| 8 | |
| 9 #include "native_client/src/shared/platform/nacl_log.h" | |
| 10 #include "native_client/src/trusted/desc/nacl_desc_rng.h" | |
| 11 #include "native_client/src/trusted/manifest_name_service_proxy/manifest_proxy.h
" | |
| 12 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" | |
| 13 #include "native_client/src/trusted/service_runtime/sel_ldr_thread_interface.h" | |
| 14 | |
| 15 int NaClDefaultNameServiceInit(struct NaClNameService *ns) { | |
| 16 /* | |
| 17 * Create an CSPRNG and enter it into the name server. | |
| 18 */ | |
| 19 struct NaClDescRng *rng = NULL; | |
| 20 | |
| 21 rng = (struct NaClDescRng *) malloc(sizeof *rng); | |
| 22 if (NULL == rng) { | |
| 23 goto malloc_failed; | |
| 24 } | |
| 25 if (!NaClDescRngCtor(rng)) { | |
| 26 goto rng_ctor_failed; | |
| 27 } | |
| 28 | |
| 29 /* | |
| 30 * It may appear desirable to insert a factory for rng, so there can | |
| 31 * be per-thread secure rng access. However, note that the only way | |
| 32 * we "transfer" a RNG is to create a new (but indistinguishable) | |
| 33 * RNG at the recipient, so each lookup results in a new generator | |
| 34 * anyway. | |
| 35 */ | |
| 36 (*NACL_VTBL(NaClNameService, ns)-> | |
| 37 CreateDescEntry)(ns, | |
| 38 "SecureRandom", NACL_ABI_O_RDWR, | |
| 39 (struct NaClDesc *) rng); | |
| 40 rng = NULL; | |
| 41 | |
| 42 return 1; | |
| 43 | |
| 44 rng_ctor_failed: | |
| 45 free(rng); | |
| 46 malloc_failed: | |
| 47 return 0; | |
| 48 } | |
| OLD | NEW |