18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR MIT */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef __CHACHA20POLY1305_H 78c2ecf20Sopenharmony_ci#define __CHACHA20POLY1305_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci#include <linux/scatterlist.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cienum chacha20poly1305_lengths { 138c2ecf20Sopenharmony_ci XCHACHA20POLY1305_NONCE_SIZE = 24, 148c2ecf20Sopenharmony_ci CHACHA20POLY1305_KEY_SIZE = 32, 158c2ecf20Sopenharmony_ci CHACHA20POLY1305_AUTHTAG_SIZE = 16 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_civoid chacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len, 198c2ecf20Sopenharmony_ci const u8 *ad, const size_t ad_len, 208c2ecf20Sopenharmony_ci const u64 nonce, 218c2ecf20Sopenharmony_ci const u8 key[CHACHA20POLY1305_KEY_SIZE]); 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cibool __must_check 248c2ecf20Sopenharmony_cichacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len, 258c2ecf20Sopenharmony_ci const u8 *ad, const size_t ad_len, const u64 nonce, 268c2ecf20Sopenharmony_ci const u8 key[CHACHA20POLY1305_KEY_SIZE]); 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_civoid xchacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len, 298c2ecf20Sopenharmony_ci const u8 *ad, const size_t ad_len, 308c2ecf20Sopenharmony_ci const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE], 318c2ecf20Sopenharmony_ci const u8 key[CHACHA20POLY1305_KEY_SIZE]); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cibool __must_check xchacha20poly1305_decrypt( 348c2ecf20Sopenharmony_ci u8 *dst, const u8 *src, const size_t src_len, const u8 *ad, 358c2ecf20Sopenharmony_ci const size_t ad_len, const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE], 368c2ecf20Sopenharmony_ci const u8 key[CHACHA20POLY1305_KEY_SIZE]); 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cibool chacha20poly1305_encrypt_sg_inplace(struct scatterlist *src, size_t src_len, 398c2ecf20Sopenharmony_ci const u8 *ad, const size_t ad_len, 408c2ecf20Sopenharmony_ci const u64 nonce, 418c2ecf20Sopenharmony_ci const u8 key[CHACHA20POLY1305_KEY_SIZE]); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cibool chacha20poly1305_decrypt_sg_inplace(struct scatterlist *src, size_t src_len, 448c2ecf20Sopenharmony_ci const u8 *ad, const size_t ad_len, 458c2ecf20Sopenharmony_ci const u64 nonce, 468c2ecf20Sopenharmony_ci const u8 key[CHACHA20POLY1305_KEY_SIZE]); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cibool chacha20poly1305_selftest(void); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#endif /* __CHACHA20POLY1305_H */ 51