Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of wolfSSL by
chacha20_poly1305.h
00001 /* chacha20_poly1305.h 00002 * 00003 * Copyright (C) 2006-2016 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 00023 /* This implementation of the ChaCha20-Poly1305 AEAD is based on "ChaCha20 00024 * and Poly1305 for IETF protocols" (draft-irtf-cfrg-chacha20-poly1305-10): 00025 * https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10 00026 */ 00027 00028 #ifndef WOLF_CRYPT_CHACHA20_POLY1305_H 00029 #define WOLF_CRYPT_CHACHA20_POLY1305_H 00030 00031 #include <wolfssl/wolfcrypt/types.h> 00032 00033 #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 #define CHACHA20_POLY1305_AEAD_KEYSIZE 32 00040 #define CHACHA20_POLY1305_AEAD_IV_SIZE 12 00041 #define CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE 16 00042 00043 enum { 00044 CHACHA20_POLY_1305_ENC_TYPE = 8 /* cipher unique type */ 00045 }; 00046 00047 /* 00048 * The IV for this implementation is 96 bits to give the most flexibility. 00049 * 00050 * Some protocols may have unique per-invocation inputs that are not 00051 * 96-bit in length. For example, IPsec may specify a 64-bit nonce. In 00052 * such a case, it is up to the protocol document to define how to 00053 * transform the protocol nonce into a 96-bit nonce, for example by 00054 * concatenating a constant value. 00055 */ 00056 00057 WOLFSSL_API 00058 int wc_ChaCha20Poly1305_Encrypt( 00059 const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE], 00060 const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE], 00061 const byte* inAAD, const word32 inAADLen, 00062 const byte* inPlaintext, const word32 inPlaintextLen, 00063 byte* outCiphertext, 00064 byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]); 00065 00066 WOLFSSL_API 00067 int wc_ChaCha20Poly1305_Decrypt( 00068 const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE], 00069 const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE], 00070 const byte* inAAD, const word32 inAADLen, 00071 const byte* inCiphertext, const word32 inCiphertextLen, 00072 const byte inAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE], 00073 byte* outPlaintext); 00074 00075 #ifdef __cplusplus 00076 } /* extern "C" */ 00077 #endif 00078 00079 #endif /* HAVE_CHACHA && HAVE_POLY1305 */ 00080 #endif /* WOLF_CRYPT_CHACHA20_POLY1305_H */ 00081
Generated on Tue Jul 12 2022 23:30:54 by
1.7.2
