1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/random/sha1prng: make random_init use init_by_array

This commit is contained in:
PeterKietzmann 2020-05-11 10:38:44 +02:00
parent 54d6b0d096
commit eb62ac6ff1

View File

@ -106,15 +106,6 @@ void _random_bytes(uint8_t *bytes, size_t size) /* TODO: use with global API */
}
}
void random_init(uint32_t seed)
{
sha1_init(&ctx);
sha1_update(&ctx, (void *)&seed, sizeof(uint32_t));
sha1_final(&ctx, digestdata);
/* copy seeded SHA1 state to PRNG state */
memcpy(prng_state, &ctx.state, 20);
}
void random_init_by_array(uint32_t init_key[], int key_length)
{
sha1_init(&ctx);
@ -125,6 +116,11 @@ void random_init_by_array(uint32_t init_key[], int key_length)
memcpy(prng_state, &ctx.state, STATE_SIZE);
}
void random_init(uint32_t seed)
{
random_init_by_array((uint32_t *)&seed, sizeof(seed));
}
uint32_t random_uint32(void)
{
uint32_t ret;