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 |
12 /* | 20 /* |
13 * #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See | 21 * #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See |
14 * the "Community Additions" comment on MSDN here: | 22 * the "Community Additions" comment on MSDN here: |
15 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx | 23 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx |
16 */ | 24 */ |
17 #define SystemFunction036 NTAPI SystemFunction036 | 25 #define SystemFunction036 NTAPI SystemFunction036 |
18 #include <NTSecAPI.h> | 26 #include <NTSecAPI.h> |
19 #undef SystemFunction036 | 27 #undef SystemFunction036 |
20 | 28 |
21 #include "native_client/src/shared/platform/nacl_log.h" | 29 #include "native_client/src/shared/platform/nacl_log.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if (0 > self->nvalid) { | 84 if (0 > self->nvalid) { |
77 NaClLog(LOG_FATAL, | 85 NaClLog(LOG_FATAL, |
78 "NaClSecureRngGenByte: illegal buffer state, nvalid = %d\n", | 86 "NaClSecureRngGenByte: illegal buffer state, nvalid = %d\n", |
79 self->nvalid); | 87 self->nvalid); |
80 } | 88 } |
81 if (0 == self->nvalid) { | 89 if (0 == self->nvalid) { |
82 NaClSecureRngFilbuf(self); | 90 NaClSecureRngFilbuf(self); |
83 } | 91 } |
84 return self->buf[--self->nvalid]; | 92 return self->buf[--self->nvalid]; |
85 } | 93 } |
OLD | NEW |