mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-28 10:42:10 -04:00
drop 128-bit keys from ChaCha implementation
This commit is contained in:
parent
b52d9ca831
commit
433af6d4ba
3 changed files with 16 additions and 25 deletions
9
random.c
9
random.c
|
@ -35,14 +35,11 @@ static void get_random_seed(void *buf, size_t size) {
|
|||
}
|
||||
}
|
||||
|
||||
#define KEY_SIZE 32
|
||||
#define IV_SIZE 8
|
||||
|
||||
void random_state_init(struct random_state *state) {
|
||||
uint8_t rnd[KEY_SIZE + IV_SIZE];
|
||||
uint8_t rnd[CHACHA_KEY_SIZE + CHACHA_IV_SIZE];
|
||||
get_random_seed(rnd, sizeof(rnd));
|
||||
chacha_keysetup(&state->ctx, rnd, KEY_SIZE * 8);
|
||||
chacha_ivsetup(&state->ctx, rnd + KEY_SIZE);
|
||||
chacha_keysetup(&state->ctx, rnd);
|
||||
chacha_ivsetup(&state->ctx, rnd + CHACHA_KEY_SIZE);
|
||||
chacha_keystream_bytes(&state->ctx, state->cache, RANDOM_CACHE_SIZE);
|
||||
state->index = 0;
|
||||
state->reseed = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue