OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2008 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * NaCl Service Runtime. Secure RNG implementation. | 8 * NaCl Service Runtime. Secure RNG implementation. |
9 */ | 9 */ |
10 #include <windows.h> | 10 #include <windows.h> |
11 | 11 |
12 /* Work around a clang-cl bug: SecureZeroMemory() below uses __stosb() but | |
13 * windows.h only declares that intrinsic and then uses `#pragma intrinsic` for | |
14 * it. clang-cl doesn't implement `#pragma intrinsic` yet; it instead defines | |
15 * the function as an always-inline symbol in its intrin.h. | |
16 * TODO(thakis): Remove this once http://llvm.org/PR19898 is fixed. | |
17 */ | |
18 #include <intrin.h> | |
19 | |
20 /* | 12 /* |
21 * #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See | 13 * #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See |
22 * the "Community Additions" comment on MSDN here: | 14 * the "Community Additions" comment on MSDN here: |
23 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx | 15 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx |
24 */ | 16 */ |
25 #define SystemFunction036 NTAPI SystemFunction036 | 17 #define SystemFunction036 NTAPI SystemFunction036 |
26 #include <NTSecAPI.h> | 18 #include <NTSecAPI.h> |
27 #undef SystemFunction036 | 19 #undef SystemFunction036 |
28 | 20 |
29 #include "native_client/src/shared/platform/nacl_log.h" | 21 #include "native_client/src/shared/platform/nacl_log.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 if (0 > self->nvalid) { | 76 if (0 > self->nvalid) { |
85 NaClLog(LOG_FATAL, | 77 NaClLog(LOG_FATAL, |
86 "NaClSecureRngGenByte: illegal buffer state, nvalid = %d\n", | 78 "NaClSecureRngGenByte: illegal buffer state, nvalid = %d\n", |
87 self->nvalid); | 79 self->nvalid); |
88 } | 80 } |
89 if (0 == self->nvalid) { | 81 if (0 == self->nvalid) { |
90 NaClSecureRngFilbuf(self); | 82 NaClSecureRngFilbuf(self); |
91 } | 83 } |
92 return self->buf[--self->nvalid]; | 84 return self->buf[--self->nvalid]; |
93 } | 85 } |
OLD | NEW |