diff options
-rw-r--r-- | core/net_crypto.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c index 270c969a..bdde7063 100644 --- a/core/net_crypto.c +++ b/core/net_crypto.c | |||
@@ -138,14 +138,14 @@ void increment_nonce(uint8_t * nonce) | |||
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | /* fill the given nonce with random bytes. | 141 | /* fill the given nonce with random bytes. */ |
142 | TODO: make this more optimized */ | ||
143 | void random_nonce(uint8_t * nonce) | 142 | void random_nonce(uint8_t * nonce) |
144 | { | 143 | { |
145 | uint32_t i; | 144 | uint32_t i, temp; |
146 | for(i = 0; i < crypto_box_NONCEBYTES; ++i) | 145 | for (i = 0; i < crypto_box_NONCEBYTES / 4; ++i) |
147 | { | 146 | { |
148 | nonce[i] = random_int() % 256; | 147 | temp = random_int(); |
148 | memcpy(nonce + 4 * i, &temp, 4); | ||
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||