diff options
author | Damien Miller <djm@mindrot.org> | 2013-11-21 14:12:23 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-11-21 14:12:23 +1100 |
commit | 0fde8acdad78a4d20cadae974376cc0165f645ee (patch) | |
tree | 6e6aa82b73163bcb412920050d98f82ca9f4e86e /chacha.h | |
parent | fdb2306acdc3eb2bc46b6dfdaaf6005c650af22a (diff) |
- djm@cvs.openbsd.org 2013/11/21 00:45:44
[Makefile.in PROTOCOL PROTOCOL.chacha20poly1305 authfile.c chacha.c]
[chacha.h cipher-chachapoly.c cipher-chachapoly.h cipher.c cipher.h]
[dh.c myproposal.h packet.c poly1305.c poly1305.h servconf.c ssh.1]
[ssh.c ssh_config.5 sshd_config.5] Add a new protocol 2 transport
cipher "chacha20-poly1305@openssh.com" that combines Daniel
Bernstein's ChaCha20 stream cipher and Poly1305 MAC to build an
authenticated encryption mode.
Inspired by and similar to Adam Langley's proposal for TLS:
http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-03
but differs in layout used for the MAC calculation and the use of a
second ChaCha20 instance to separately encrypt packet lengths.
Details are in the PROTOCOL.chacha20poly1305 file.
Feedback markus@, naddy@; manpage bits Loganden Velvindron @ AfriNIC
ok markus@ naddy@
Diffstat (limited to 'chacha.h')
-rw-r--r-- | chacha.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/chacha.h b/chacha.h new file mode 100644 index 000000000..4ef42cc70 --- /dev/null +++ b/chacha.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* $OpenBSD: chacha.h,v 1.1 2013/11/21 00:45:44 djm Exp $ */ | ||
2 | |||
3 | /* | ||
4 | chacha-merged.c version 20080118 | ||
5 | D. J. Bernstein | ||
6 | Public domain. | ||
7 | */ | ||
8 | |||
9 | #ifndef CHACHA_H | ||
10 | #define CHACHA_H | ||
11 | |||
12 | #include <sys/types.h> | ||
13 | |||
14 | struct chacha_ctx { | ||
15 | u_int input[16]; | ||
16 | }; | ||
17 | |||
18 | #define CHACHA_MINKEYLEN 16 | ||
19 | #define CHACHA_NONCELEN 8 | ||
20 | #define CHACHA_CTRLEN 8 | ||
21 | #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) | ||
22 | #define CHACHA_BLOCKLEN 64 | ||
23 | |||
24 | void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits) | ||
25 | __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN))); | ||
26 | void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr) | ||
27 | __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN))) | ||
28 | __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN))); | ||
29 | void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m, | ||
30 | u_char *c, u_int bytes) | ||
31 | __attribute__((__bounded__(__buffer__, 2, 4))) | ||
32 | __attribute__((__bounded__(__buffer__, 3, 4))); | ||
33 | |||
34 | #endif /* CHACHA_H */ | ||
35 | |||