| 1 |
|
| 2 | |
| 3 | * Common values for the Poly1305 algorithm
|
| 4 |
|
| 5 |
|
| 6 | #ifndef _CRYPTO_POLY1305_H
|
| 7 | #define _CRYPTO_POLY1305_H
|
| 8 |
|
| 9 | #include <linux/types.h>
|
| 10 |
|
| 11 | #define POLY1305_BLOCK_SIZE 16
|
| 12 | #define POLY1305_KEY_SIZE 32
|
| 13 | #define POLY1305_DIGEST_SIZE 16
|
| 14 |
|
| 15 | |
| 16 | * implementation-defined. Limbs might be in base 2^64 or base 2^26, or
|
| 17 | * different yet. The union type provided keeps these 64-bit aligned for the
|
| 18 | * case in which this is implemented using 64x64 multiplies.
|
| 19 |
|
| 20 |
|
| 21 | struct poly1305_key {
|
| 22 | union {
|
| 23 | u32 r[5];
|
| 24 | u64 r64[3];
|
| 25 | };
|
| 26 | };
|
| 27 |
|
| 28 | struct poly1305_core_key {
|
| 29 | struct poly1305_key key;
|
| 30 | struct poly1305_key precomputed_s;
|
| 31 | };
|
| 32 |
|
| 33 | struct poly1305_state {
|
| 34 | union {
|
| 35 | u32 h[5];
|
| 36 | u64 h64[3];
|
| 37 | };
|
| 38 | };
|
| 39 |
|
| 40 |
|
| 41 | struct poly1305_block_state {
|
| 42 |
|
| 43 | struct poly1305_state h;
|
| 44 |
|
| 45 | union {
|
| 46 | struct poly1305_key opaque_r[CONFIG_CRYPTO_LIB_POLY1305_RSIZE];
|
| 47 | struct poly1305_core_key core_r;
|
| 48 | };
|
| 49 | };
|
| 50 |
|
| 51 | struct poly1305_desc_ctx {
|
| 52 |
|
| 53 | u8 buf[POLY1305_BLOCK_SIZE];
|
| 54 |
|
| 55 | unsigned int buflen;
|
| 56 |
|
| 57 | u32 s[4];
|
| 58 | struct poly1305_block_state state;
|
| 59 | };
|
| 60 |
|
| 61 | void poly1305_init(struct poly1305_desc_ctx *desc,
|
| 62 | const u8 key[at_least POLY1305_KEY_SIZE]);
|
| 63 | void poly1305_update(struct poly1305_desc_ctx *desc, const u8 *src,
|
| 64 | size_t nbytes);
|
| 65 | void poly1305_final(struct poly1305_desc_ctx *desc, u8 *digest);
|
| 66 |
|
| 67 | #endif
|