xref: /netbsd-src/crypto/external/bsd/openssh/dist/cipher-chachapoly.h (revision 8db691be9054b79fe6a8cb4febe9efe24dae371d)
1*8db691beSchristos /*	$NetBSD: cipher-chachapoly.h,v 1.3 2020/05/28 17:05:49 christos Exp $	*/
2*8db691beSchristos /* $OpenBSD: cipher-chachapoly.h,v 1.5 2020/04/03 04:27:03 djm Exp $ */
35484a5efSchristos 
45484a5efSchristos /*
55484a5efSchristos  * Copyright (c) Damien Miller 2013 <djm@mindrot.org>
65484a5efSchristos  *
75484a5efSchristos  * Permission to use, copy, modify, and distribute this software for any
85484a5efSchristos  * purpose with or without fee is hereby granted, provided that the above
95484a5efSchristos  * copyright notice and this permission notice appear in all copies.
105484a5efSchristos  *
115484a5efSchristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
125484a5efSchristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
135484a5efSchristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
145484a5efSchristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
155484a5efSchristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
165484a5efSchristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
175484a5efSchristos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
185484a5efSchristos  */
195484a5efSchristos #ifndef CHACHA_POLY_AEAD_H
205484a5efSchristos #define CHACHA_POLY_AEAD_H
215484a5efSchristos 
225484a5efSchristos #include <sys/types.h>
235484a5efSchristos #include "chacha.h"
245484a5efSchristos #include "poly1305.h"
255484a5efSchristos 
265484a5efSchristos #define CHACHA_KEYLEN	32 /* Only 256 bit keys used here */
275484a5efSchristos 
28*8db691beSchristos struct chachapoly_ctx;
295484a5efSchristos 
30*8db691beSchristos struct chachapoly_ctx *chachapoly_new(const u_char *key, u_int keylen)
31*8db691beSchristos     __attribute__((__bounded__(__buffer__, 1, 2)));
32*8db691beSchristos void chachapoly_free(struct chachapoly_ctx *cpctx);
33*8db691beSchristos 
345484a5efSchristos int	chachapoly_crypt(struct chachapoly_ctx *cpctx, u_int seqnr,
355484a5efSchristos     u_char *dest, const u_char *src, u_int len, u_int aadlen, u_int authlen,
365484a5efSchristos     int do_encrypt);
375484a5efSchristos int	chachapoly_get_length(struct chachapoly_ctx *cpctx,
385484a5efSchristos     u_int *plenp, u_int seqnr, const u_char *cp, u_int len)
395484a5efSchristos     __attribute__((__bounded__(__buffer__, 4, 5)));
405484a5efSchristos 
415484a5efSchristos #endif /* CHACHA_POLY_AEAD_H */
42