| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef NETTLE_CHACHA_POLY1305_H_INCLUDED |
| #define NETTLE_CHACHA_POLY1305_H_INCLUDED |
|
|
| #include "chacha.h" |
| #include "poly1305.h" |
|
|
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
|
|
| |
| #define chacha_poly1305_set_key nettle_chacha_poly1305_set_key |
| #define chacha_poly1305_set_nonce nettle_chacha_poly1305_set_nonce |
| #define chacha_poly1305_update nettle_chacha_poly1305_update |
| #define chacha_poly1305_decrypt nettle_chacha_poly1305_decrypt |
| #define chacha_poly1305_encrypt nettle_chacha_poly1305_encrypt |
| #define chacha_poly1305_digest nettle_chacha_poly1305_digest |
|
|
| #define CHACHA_POLY1305_BLOCK_SIZE 64 |
| |
| #define CHACHA_POLY1305_KEY_SIZE 32 |
| #define CHACHA_POLY1305_NONCE_SIZE CHACHA_NONCE96_SIZE |
| #define CHACHA_POLY1305_DIGEST_SIZE 16 |
|
|
| struct chacha_poly1305_ctx |
| { |
| struct chacha_ctx chacha; |
| struct poly1305_ctx poly1305; |
| union nettle_block16 s; |
| uint64_t auth_size; |
| uint64_t data_size; |
| |
| uint8_t block[POLY1305_BLOCK_SIZE]; |
| unsigned index; |
| }; |
|
|
| void |
| chacha_poly1305_set_key (struct chacha_poly1305_ctx *ctx, |
| const uint8_t *key); |
| void |
| chacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx, |
| const uint8_t *nonce); |
|
|
| void |
| chacha_poly1305_update (struct chacha_poly1305_ctx *ctx, |
| size_t length, const uint8_t *data); |
|
|
| void |
| chacha_poly1305_encrypt (struct chacha_poly1305_ctx *ctx, |
| size_t length, uint8_t *dst, const uint8_t *src); |
| |
| void |
| chacha_poly1305_decrypt (struct chacha_poly1305_ctx *ctx, |
| size_t length, uint8_t *dst, const uint8_t *src); |
| |
| void |
| chacha_poly1305_digest (struct chacha_poly1305_ctx *ctx, |
| size_t length, uint8_t *digest); |
|
|
| #ifdef __cplusplus |
| } |
| #endif |
|
|
| #endif |
|
|