3 AEAD mechanism based on chacha and poly1305.
4 See draft-agl-tls-chacha20poly1305-04.
6 Copyright (C) 2014 Niels Möller
8 This file is part of GNU Nettle.
10 GNU Nettle is free software: you can redistribute it and/or
11 modify it under the terms of either:
13 * the GNU Lesser General Public License as published by the Free
14 Software Foundation; either version 3 of the License, or (at your
15 option) any later version.
19 * the GNU General Public License as published by the Free
20 Software Foundation; either version 2 of the License, or (at your
21 option) any later version.
23 or both in parallel, as here.
25 GNU Nettle is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 General Public License for more details.
30 You should have received copies of the GNU General Public License and
31 the GNU Lesser General Public License along with this program. If
32 not, see http://www.gnu.org/licenses/.
35 #ifndef NETTLE_CHACHA_POLY1305_H_INCLUDED
36 #define NETTLE_CHACHA_POLY1305_H_INCLUDED
46 #define chacha_poly1305_set_key nettle_chacha_poly1305_set_key
47 #define chacha_poly1305_set_nonce nettle_chacha_poly1305_set_nonce
48 #define chacha_poly1305_update nettle_chacha_poly1305_update
49 #define chacha_poly1305_decrypt nettle_chacha_poly1305_decrypt
50 #define chacha_poly1305_encrypt nettle_chacha_poly1305_encrypt
51 #define chacha_poly1305_digest nettle_chacha_poly1305_digest
53 #define CHACHA_POLY1305_BLOCK_SIZE 64
54 /* FIXME: Any need for 128-bit variant? */
55 #define CHACHA_POLY1305_KEY_SIZE 32
56 #define CHACHA_POLY1305_NONCE_SIZE CHACHA_NONCE96_SIZE
57 #define CHACHA_POLY1305_DIGEST_SIZE 16
59 struct chacha_poly1305_ctx
61 struct chacha_ctx chacha;
62 struct poly1305_ctx poly1305;
63 union nettle_block16 s;
67 uint8_t block[POLY1305_BLOCK_SIZE];
72 chacha_poly1305_set_key (struct chacha_poly1305_ctx *ctx,
75 chacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx,
76 const uint8_t *nonce);
79 chacha_poly1305_update (struct chacha_poly1305_ctx *ctx,
80 size_t length, const uint8_t *data);
83 chacha_poly1305_encrypt (struct chacha_poly1305_ctx *ctx,
84 size_t length, uint8_t *dst, const uint8_t *src);
87 chacha_poly1305_decrypt (struct chacha_poly1305_ctx *ctx,
88 size_t length, uint8_t *dst, const uint8_t *src);
91 chacha_poly1305_digest (struct chacha_poly1305_ctx *ctx,
92 size_t length, uint8_t *digest);
98 #endif /* NETTLE_CHACHA_POLY1305_H_INCLUDED */