summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredwire <redwire@riseup.net>2013-07-21 21:13:04 -0230
committerredwire <redwire@riseup.net>2013-07-21 21:13:04 -0230
commit99c3426cbcb91a1b3509671c11ebffb1778057e6 (patch)
treea434473d5ce664e41c9620c2c28e5b587096628f
parent5a5e6fd307cc75e89ac2b2268ee9bc89d82101eb (diff)
Going with irungentoo's suggestion and using memcpy instead of sectioning with arithmetic
-rw-r--r--core/net_crypto.c13
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. */
142void random_nonce(uint8_t * nonce) 142void 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