File indexing completed on 2025-01-18 10:02:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef NETTLE_CHACHA_POLY1305_H_INCLUDED
0036 #define NETTLE_CHACHA_POLY1305_H_INCLUDED
0037
0038 #include "chacha.h"
0039 #include "poly1305.h"
0040
0041 #ifdef __cplusplus
0042 extern "C" {
0043 #endif
0044
0045
0046 #define chacha_poly1305_set_key nettle_chacha_poly1305_set_key
0047 #define chacha_poly1305_set_nonce nettle_chacha_poly1305_set_nonce
0048 #define chacha_poly1305_update nettle_chacha_poly1305_update
0049 #define chacha_poly1305_decrypt nettle_chacha_poly1305_decrypt
0050 #define chacha_poly1305_encrypt nettle_chacha_poly1305_encrypt
0051 #define chacha_poly1305_digest nettle_chacha_poly1305_digest
0052
0053 #define CHACHA_POLY1305_BLOCK_SIZE 64
0054
0055 #define CHACHA_POLY1305_KEY_SIZE 32
0056 #define CHACHA_POLY1305_NONCE_SIZE CHACHA_NONCE96_SIZE
0057 #define CHACHA_POLY1305_DIGEST_SIZE 16
0058
0059 struct chacha_poly1305_ctx
0060 {
0061 struct chacha_ctx chacha;
0062 struct poly1305_ctx poly1305;
0063 union nettle_block16 s;
0064 uint64_t auth_size;
0065 uint64_t data_size;
0066
0067 uint8_t block[POLY1305_BLOCK_SIZE];
0068 unsigned index;
0069 };
0070
0071 void
0072 chacha_poly1305_set_key (struct chacha_poly1305_ctx *ctx,
0073 const uint8_t *key);
0074 void
0075 chacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx,
0076 const uint8_t *nonce);
0077
0078 void
0079 chacha_poly1305_update (struct chacha_poly1305_ctx *ctx,
0080 size_t length, const uint8_t *data);
0081
0082 void
0083 chacha_poly1305_encrypt (struct chacha_poly1305_ctx *ctx,
0084 size_t length, uint8_t *dst, const uint8_t *src);
0085
0086 void
0087 chacha_poly1305_decrypt (struct chacha_poly1305_ctx *ctx,
0088 size_t length, uint8_t *dst, const uint8_t *src);
0089
0090 void
0091 chacha_poly1305_digest (struct chacha_poly1305_ctx *ctx,
0092 size_t length, uint8_t *digest);
0093
0094 #ifdef __cplusplus
0095 }
0096 #endif
0097
0098 #endif