From 4a0e319af86c0d38304535293f6fc32fe436ef1d Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 28 Aug 2018 23:50:35 -0600 Subject: crypto: import zinc --- src/crypto/include/zinc/poly1305.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/crypto/include/zinc/poly1305.h (limited to 'src/crypto/include/zinc/poly1305.h') diff --git a/src/crypto/include/zinc/poly1305.h b/src/crypto/include/zinc/poly1305.h new file mode 100644 index 0000000..5c9220f --- /dev/null +++ b/src/crypto/include/zinc/poly1305.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Copyright (C) 2015-2018 Jason A. Donenfeld . All Rights Reserved. + */ + +#ifndef _ZINC_POLY1305_H +#define _ZINC_POLY1305_H + +#include +#include + +enum poly1305_lengths { + POLY1305_BLOCK_SIZE = 16, + POLY1305_KEY_SIZE = 32, + POLY1305_MAC_SIZE = 16 +}; + +struct poly1305_ctx { + u8 opaque[24 * sizeof(u64)]; + u32 nonce[4]; + u8 data[POLY1305_BLOCK_SIZE]; + size_t num; +} __aligned(8); + +void poly1305_fpu_init(void); + +void poly1305_init(struct poly1305_ctx *ctx, const u8 key[POLY1305_KEY_SIZE], + simd_context_t simd_context); +void poly1305_update(struct poly1305_ctx *ctx, const u8 *inp, const size_t len, + simd_context_t simd_context); +void poly1305_finish(struct poly1305_ctx *ctx, u8 mac[POLY1305_MAC_SIZE], + simd_context_t simd_context); + +#ifdef DEBUG +bool poly1305_selftest(void); +#endif + +#endif /* _ZINC_POLY1305_H */ -- cgit v1.2.3-59-g8ed1b