summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/chacha.h
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2013-11-21 00:45:43 +0000
committerdjm <djm@openbsd.org>2013-11-21 00:45:43 +0000
commit1edbfe239db2487faa56c5fb5877105e3018932c (patch)
treed5cbb0444e798f9ca43091e45c4a31f1498e401f /usr.bin/ssh/chacha.h
parentremove the #define b_cylinder b_resid from bufs. i hated the (diff)
downloadwireguard-openbsd-1edbfe239db2487faa56c5fb5877105e3018932c.tar.xz
wireguard-openbsd-1edbfe239db2487faa56c5fb5877105e3018932c.zip
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 'usr.bin/ssh/chacha.h')
-rw-r--r--usr.bin/ssh/chacha.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/usr.bin/ssh/chacha.h b/usr.bin/ssh/chacha.h
new file mode 100644
index 00000000000..4ef42cc70cf
--- /dev/null
+++ b/usr.bin/ssh/chacha.h
@@ -0,0 +1,35 @@
+/* $OpenBSD: chacha.h,v 1.1 2013/11/21 00:45:44 djm Exp $ */
+
+/*
+chacha-merged.c version 20080118
+D. J. Bernstein
+Public domain.
+*/
+
+#ifndef CHACHA_H
+#define CHACHA_H
+
+#include <sys/types.h>
+
+struct chacha_ctx {
+ u_int input[16];
+};
+
+#define CHACHA_MINKEYLEN 16
+#define CHACHA_NONCELEN 8
+#define CHACHA_CTRLEN 8
+#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
+#define CHACHA_BLOCKLEN 64
+
+void chacha_keysetup(struct chacha_ctx *x, const u_char *k, u_int kbits)
+ __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)));
+void chacha_ivsetup(struct chacha_ctx *x, const u_char *iv, const u_char *ctr)
+ __attribute__((__bounded__(__minbytes__, 2, CHACHA_NONCELEN)))
+ __attribute__((__bounded__(__minbytes__, 3, CHACHA_CTRLEN)));
+void chacha_encrypt_bytes(struct chacha_ctx *x, const u_char *m,
+ u_char *c, u_int bytes)
+ __attribute__((__bounded__(__buffer__, 2, 4)))
+ __attribute__((__bounded__(__buffer__, 3, 4)));
+
+#endif /* CHACHA_H */
+