pkg: tweetnacl: use random_bytes()
This commit is contained in:
parent
caabc15395
commit
9f3aa366a3
1
pkg/tweetnacl/Makefile.dep
Normal file
1
pkg/tweetnacl/Makefile.dep
Normal file
@ -0,0 +1 @@
|
|||||||
|
USEMODULE+=random
|
||||||
@ -15,15 +15,6 @@
|
|||||||
|
|
||||||
void randombytes(uint8_t *target, uint64_t n)
|
void randombytes(uint8_t *target, uint64_t n)
|
||||||
{
|
{
|
||||||
uint32_t random;
|
/* tweetnacl needs uint64_t as "n" parameter, random provides uint32 */
|
||||||
uint8_t *random_pos = (uint8_t*)&random;
|
random_bytes(target, n);
|
||||||
unsigned _n = 0;
|
|
||||||
|
|
||||||
while (n--) {
|
|
||||||
if (! (_n++ & 0x3)) {
|
|
||||||
random = random_uint32();
|
|
||||||
random_pos = (uint8_t *) &random;
|
|
||||||
}
|
|
||||||
*target++ = *random_pos++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user