diff options
Diffstat (limited to 'src/crypto/include/zinc/chacha20.h')
-rw-r--r-- | src/crypto/include/zinc/chacha20.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/crypto/include/zinc/chacha20.h b/src/crypto/include/zinc/chacha20.h index 276bdba..34d577d 100644 --- a/src/crypto/include/zinc/chacha20.h +++ b/src/crypto/include/zinc/chacha20.h @@ -14,14 +14,14 @@ enum { CHACHA20_IV_SIZE = 16, CHACHA20_KEY_SIZE = 32, + CHACHA20_KEY_WORDS = CHACHA20_KEY_SIZE / sizeof(u32), CHACHA20_BLOCK_SIZE = 64, CHACHA20_BLOCK_WORDS = CHACHA20_BLOCK_SIZE / sizeof(u32), HCHACHA20_KEY_SIZE = 32, HCHACHA20_NONCE_SIZE = 16 }; -enum { - /* expand 32-byte k */ +enum { /* expand 32-byte k */ CHACHA20_CONSTANT_EXPA = 0x61707865U, CHACHA20_CONSTANT_ND_3 = 0x3320646eU, CHACHA20_CONSTANT_2_BY = 0x79622d32U, @@ -50,15 +50,15 @@ static inline void chacha20_init(struct chacha20_ctx *state, state->key[5] = get_unaligned_le32(key + 20); state->key[6] = get_unaligned_le32(key + 24); state->key[7] = get_unaligned_le32(key + 28); - state->counter[0] = state->counter[1] = 0; + state->counter[0] = 0; + state->counter[1] = 0; state->counter[2] = nonce & U32_MAX; state->counter[3] = nonce >> 32; } void chacha20(struct chacha20_ctx *state, u8 *dst, const u8 *src, u32 len, simd_context_t *simd_context); -/* Derived key should be 32-bit aligned */ -void hchacha20(u8 derived_key[CHACHA20_KEY_SIZE], +void hchacha20(u32 derived_key[CHACHA20_KEY_WORDS], const u8 nonce[HCHACHA20_NONCE_SIZE], const u8 key[HCHACHA20_KEY_SIZE], simd_context_t *simd_context); |