summaryrefslogtreecommitdiff
path: root/cipher-chachapoly.h
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-11-21 14:12:23 +1100
committerDamien Miller <djm@mindrot.org>2013-11-21 14:12:23 +1100
commit0fde8acdad78a4d20cadae974376cc0165f645ee (patch)
tree6e6aa82b73163bcb412920050d98f82ca9f4e86e /cipher-chachapoly.h
parentfdb2306acdc3eb2bc46b6dfdaaf6005c650af22a (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 'cipher-chachapoly.h')
-rw-r--r--cipher-chachapoly.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/cipher-chachapoly.h b/cipher-chachapoly.h
new file mode 100644
index 000000000..1628693b2
--- /dev/null
+++ b/cipher-chachapoly.h
@@ -0,0 +1,41 @@
1/* $OpenBSD: cipher-chachapoly.h,v 1.1 2013/11/21 00:45:44 djm Exp $ */
2
3/*
4 * Copyright (c) Damien Miller 2013 <djm@mindrot.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18#ifndef CHACHA_POLY_AEAD_H
19#define CHACHA_POLY_AEAD_H
20
21#include <sys/types.h>
22#include "chacha.h"
23#include "poly1305.h"
24
25#define CHACHA_KEYLEN 32 /* Only 256 bit keys used here */
26
27struct chachapoly_ctx {
28 struct chacha_ctx main_ctx, header_ctx;
29};
30
31void chachapoly_init(struct chachapoly_ctx *cpctx,
32 const u_char *key, u_int keylen)
33 __attribute__((__bounded__(__buffer__, 2, 3)));
34int chachapoly_crypt(struct chachapoly_ctx *cpctx, u_int seqnr,
35 u_char *dest, const u_char *src, u_int len, u_int aadlen, u_int authlen,
36 int do_encrypt);
37int chachapoly_get_length(struct chachapoly_ctx *cpctx,
38 u_int *plenp, u_int seqnr, const u_char *cp, u_int len)
39 __attribute__((__bounded__(__buffer__, 4, 5)));
40
41#endif /* CHACHA_POLY_AEAD_H */