diff options
Diffstat (limited to 'core/net_crypto.c')
-rw-r--r-- | core/net_crypto.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/core/net_crypto.c b/core/net_crypto.c index 26102a02..166adafb 100644 --- a/core/net_crypto.c +++ b/core/net_crypto.c | |||
@@ -141,16 +141,11 @@ void increment_nonce(uint8_t * nonce) | |||
141 | /* fill the given nonce with random bytes. */ | 141 | /* fill the given nonce with random bytes. */ |
142 | void random_nonce(uint8_t * nonce) | 142 | void random_nonce(uint8_t * nonce) |
143 | { | 143 | { |
144 | uint32_t i, j, r, m = crypto_box_NONCEBYTES / 3, ind = 0; | 144 | uint32_t i, temp; |
145 | for(i = 0; i < m; ++i) | 145 | for (i = 0; i < crypto_box_NONCEBYTES / 4; ++i) |
146 | { | 146 | { |
147 | r = random_int(); | 147 | uint32_t temp = random_int(); |
148 | for (j = 0; j < 3; j++) | 148 | memcpy(nonce + 4 * i, &temp, 4); |
149 | { | ||
150 | nonce[ind] = r % 1000 % 256; | ||
151 | r /= 1000; | ||
152 | ++ind; | ||
153 | } | ||
154 | } | 149 | } |
155 | } | 150 | } |
156 | 151 | ||