diff options
author | Eric Biggers <ebiggers@google.com> | 2018-11-16 20:26:27 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-11-20 01:26:56 -0500 |
commit | 878afc35cd28bcd93cd3c5e1985ef39a104a4d45 (patch) | |
tree | e17291b3c2ea1c786fceb3ee4f78cf175273a0cc /include/crypto | |
parent | bdb063a79f6da589af1de3f10a7c8f654fba9ae8 (diff) |
crypto: poly1305 - use structures for key and accumulator
In preparation for exposing a low-level Poly1305 API which implements
the ε-almost-∆-universal (εA∆U) hash function underlying the Poly1305
MAC and supports block-aligned inputs only, create structures
poly1305_key and poly1305_state which hold the limbs of the Poly1305
"r" key and accumulator, respectively.
These structures could actually have the same type (e.g. poly1305_val),
but different types are preferable, to prevent misuse.
Acked-by: Martin Willi <martin@strongswan.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
-rw-r--r-- | include/crypto/poly1305.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/crypto/poly1305.h b/include/crypto/poly1305.h index f718a19da82f..493244c46664 100644 --- a/include/crypto/poly1305.h +++ b/include/crypto/poly1305.h | |||
@@ -13,13 +13,21 @@ | |||
13 | #define POLY1305_KEY_SIZE 32 | 13 | #define POLY1305_KEY_SIZE 32 |
14 | #define POLY1305_DIGEST_SIZE 16 | 14 | #define POLY1305_DIGEST_SIZE 16 |
15 | 15 | ||
16 | struct poly1305_key { | ||
17 | u32 r[5]; /* key, base 2^26 */ | ||
18 | }; | ||
19 | |||
20 | struct poly1305_state { | ||
21 | u32 h[5]; /* accumulator, base 2^26 */ | ||
22 | }; | ||
23 | |||
16 | struct poly1305_desc_ctx { | 24 | struct poly1305_desc_ctx { |
17 | /* key */ | 25 | /* key */ |
18 | u32 r[5]; | 26 | struct poly1305_key r; |
19 | /* finalize key */ | 27 | /* finalize key */ |
20 | u32 s[4]; | 28 | u32 s[4]; |
21 | /* accumulator */ | 29 | /* accumulator */ |
22 | u32 h[5]; | 30 | struct poly1305_state h; |
23 | /* partial buffer */ | 31 | /* partial buffer */ |
24 | u8 buf[POLY1305_BLOCK_SIZE]; | 32 | u8 buf[POLY1305_BLOCK_SIZE]; |
25 | /* bytes used in partial buffer */ | 33 | /* bytes used in partial buffer */ |