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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 inline uint32_t getWord(); | 70 inline uint32_t getWord(); |
71 | 71 |
72 ARC4Stream m_stream; | 72 ARC4Stream m_stream; |
73 int m_count; | 73 int m_count; |
74 Mutex m_mutex; | 74 Mutex m_mutex; |
75 }; | 75 }; |
76 | 76 |
77 ARC4Stream::ARC4Stream() | 77 ARC4Stream::ARC4Stream() |
78 { | 78 { |
79 for (int n = 0; n < 256; n++) | 79 for (int n = 0; n < 256; n++) |
80 s[n] = n; | 80 s[n] = static_cast<uint8_t>(n); |
81 i = 0; | 81 i = 0; |
82 j = 0; | 82 j = 0; |
83 } | 83 } |
84 | 84 |
85 ARC4RandomNumberGenerator::ARC4RandomNumberGenerator() | 85 ARC4RandomNumberGenerator::ARC4RandomNumberGenerator() |
86 : m_count(0) | 86 : m_count(0) |
87 { | 87 { |
88 } | 88 } |
89 | 89 |
90 void ARC4RandomNumberGenerator::addRandomData(unsigned char* data, int length) | 90 void ARC4RandomNumberGenerator::addRandomData(unsigned char* data, int length) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |