diff options
author | Linus Nordberg <linus@nordberg.se> | 2020-01-21 16:11:38 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2020-01-21 16:11:38 +0100 |
commit | ee799425c42bbd46dddb506f9133091874a74175 (patch) | |
tree | 396ff4510828a1662bb7171a50d51cbb6f37810d /src/cc20rng/cc20_prng.h | |
parent | e775954924a390e2e8c9fa5e4c0d16f96e9c6fe5 (diff) | |
parent | 76a6b631f4bd6866622f537870bc145c935bef40 (diff) |
Merge branch 'ln/cc20rng-revamp' into ln/devel
Diffstat (limited to 'src/cc20rng/cc20_prng.h')
-rw-r--r-- | src/cc20rng/cc20_prng.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/cc20rng/cc20_prng.h b/src/cc20rng/cc20_prng.h index 6940f53..08f78d7 100644 --- a/src/cc20rng/cc20_prng.h +++ b/src/cc20rng/cc20_prng.h @@ -3,16 +3,22 @@ #include <stdint.h> -#define CHACHA20_MAX_BLOCK_COUNTER 0xffffffff -#define CHACHA20_NUM_WORDS 16 -#define CHACHA20_BLOCK_SIZE (CHACHA20_NUM_WORDS * 4) +#define CHACHA20_BLOCK_SIZE_WORDS 16 +#define CHACHA20_BLOCK_SIZE (CHACHA20_BLOCK_SIZE_WORDS * 4) struct cc20_state { - uint32_t i[CHACHA20_NUM_WORDS]; + union { + struct { + uint32_t constant[4]; + uint32_t key[8]; + uint32_t counter; + uint32_t nonce[3]; + } s; + uint32_t i[CHACHA20_BLOCK_SIZE_WORDS]; + }; }; -extern void chacha20_prng_reseed(struct cc20_state *cc, uint32_t *entropy); -extern void chacha20_prng_block(struct cc20_state *cc, uint32_t block_counter, struct cc20_state *out); -extern int chacha20_prng_self_test(); +void chacha20_prng_block(struct cc20_state *cc, uint8_t *out); +int chacha20_prng_self_test(); #endif /* __STM32_CHACHA20_H */ |