| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 1996, David Mazieres <dm@uun.org> | 2 * Copyright (c) 1996, David Mazieres <dm@uun.org> |
| 3 * Copyright (c) 2008, Damien Miller <djm@openbsd.org> | 3 * Copyright (c) 2008, Damien Miller <djm@openbsd.org> |
| 4 * | 4 * |
| 5 * Permission to use, copy, modify, and distribute this software for any | 5 * Permission to use, copy, modify, and distribute this software for any |
| 6 * purpose with or without fee is hereby granted, provided that the above | 6 * purpose with or without fee is hereby granted, provided that the above |
| 7 * copyright notice and this permission notice appear in all copies. | 7 * copyright notice and this permission notice appear in all copies. |
| 8 * | 8 * |
| 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 stirIfNeeded(); | 158 stirIfNeeded(); |
| 159 while (length--) { | 159 while (length--) { |
| 160 m_count--; | 160 m_count--; |
| 161 stirIfNeeded(); | 161 stirIfNeeded(); |
| 162 result[length] = getByte(); | 162 result[length] = getByte(); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 ARC4RandomNumberGenerator& sharedRandomNumberGenerator() | 166 ARC4RandomNumberGenerator& sharedRandomNumberGenerator() |
| 167 { | 167 { |
| 168 AtomicallyInitializedStatic(ARC4RandomNumberGenerator*, randomNumberGenerato
r = new ARC4RandomNumberGenerator); | 168 AtomicallyInitializedStaticReference(ARC4RandomNumberGenerator, randomNumber
Generator, new ARC4RandomNumberGenerator); |
| 169 return *randomNumberGenerator; | 169 return randomNumberGenerator; |
| 170 } | 170 } |
| 171 | 171 |
| 172 } | 172 } |
| 173 | 173 |
| 174 | 174 |
| 175 uint32_t cryptographicallyRandomNumber() | 175 uint32_t cryptographicallyRandomNumber() |
| 176 { | 176 { |
| 177 return sharedRandomNumberGenerator().randomNumber(); | 177 return sharedRandomNumberGenerator().randomNumber(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void cryptographicallyRandomValues(void* buffer, size_t length) | 180 void cryptographicallyRandomValues(void* buffer, size_t length) |
| 181 { | 181 { |
| 182 sharedRandomNumberGenerator().randomValues(buffer, length); | 182 sharedRandomNumberGenerator().randomValues(buffer, length); |
| 183 } | 183 } |
| 184 | 184 |
| 185 } | 185 } |
| OLD | NEW |