summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-21 17:00:31 -0700
committerirungentoo <irungentoo@gmail.com>2013-07-21 17:00:31 -0700
commitd35ddc161860610aec25517ba78a65647ff97169 (patch)
tree7c527674aea897146dc4b2b6e000ad81cd0ddb44
parentc211e361d29dbbb941a5aeb0c99fb4f30b76ca8f (diff)
parentb16013b86be5063dfe32a59cf04febebed0a6d35 (diff)
Merge pull request #78 from redwire/master
Implemented a faster algorithm for generating nonces
-rw-r--r--core/net_crypto.c10
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 */
143void random_nonce(uint8_t * nonce) 142void 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