_sodium_alignedcalloc(): use arc4random_buf() if available
This commit is contained in:
parent
323f24ef60
commit
696934b123
@ -54,9 +54,14 @@ _sodium_alignedcalloc(unsigned char ** const unaligned_p, const size_t len)
|
||||
return NULL;
|
||||
}
|
||||
*unaligned_p = unaligned;
|
||||
#ifdef HAVE_ARC4RANDOM
|
||||
(void) i;
|
||||
arc4random_buf(unaligned, len + (size_t) 256U);
|
||||
#else
|
||||
for (i = (size_t) 0U; i < len + (size_t) 256U; ++i) {
|
||||
unaligned[i] = (unsigned char) rand();
|
||||
}
|
||||
#endif
|
||||
aligned = unaligned + 64;
|
||||
aligned += (ptrdiff_t) 63 & (-(ptrdiff_t) aligned);
|
||||
memset(aligned, 0, len);
|
||||
|
Loading…
Reference in New Issue
Block a user