forked from wolfSSL/wolfssl
add autoconf support for chapoly-aead, wipe temp polykey, minor whitespace adjusts
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
AC_INIT([wolfssl],[3.4.0],[https://github.com/wolfssl/wolfssl/issues],[wolfssl],[http://www.wolfssl.com])
|
||||
AC_INIT([wolfssl],[3.4.1],[https://github.com/wolfssl/wolfssl/issues],[wolfssl],[http://www.wolfssl.com])
|
||||
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
|
||||
|
@@ -146,6 +146,9 @@ endif
|
||||
|
||||
if BUILD_CHACHA
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha.c
|
||||
if BUILD_POLY1305
|
||||
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha20_poly1305.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if !BUILD_INLINE
|
||||
|
@@ -5,6 +5,6 @@ includedir=${prefix}/include
|
||||
|
||||
Name: wolfssl
|
||||
Description: wolfssl C library.
|
||||
Version: 3.4.0
|
||||
Version: 3.4.1
|
||||
Libs: -L${libdir} -lwolfssl
|
||||
Cflags: -I${includedir}
|
||||
|
@@ -285,6 +285,9 @@ int benchmark_test(void *args)
|
||||
#ifdef HAVE_CHACHA
|
||||
bench_chacha();
|
||||
#endif
|
||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
bench_chacha20_poly1305_aead();
|
||||
#endif
|
||||
#ifndef NO_DES3
|
||||
bench_des();
|
||||
#endif
|
||||
@@ -297,9 +300,6 @@ int benchmark_test(void *args)
|
||||
#ifdef HAVE_POLY1305
|
||||
bench_poly1305();
|
||||
#endif
|
||||
#if( defined( HAVE_CHACHA ) && defined( HAVE_POLY1305 ) )
|
||||
bench_chacha20_poly1305_aead();
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
bench_sha();
|
||||
#endif
|
||||
@@ -790,7 +790,8 @@ void bench_chacha20_poly1305_aead(void)
|
||||
|
||||
for (i = 0; i < numBlocks; i++)
|
||||
{
|
||||
wc_ChaCha20Poly1305_Encrypt( key, iv, NULL, 0, plain, sizeof( plain ), cipher, authTag );
|
||||
wc_ChaCha20Poly1305_Encrypt(key, iv, NULL, 0, plain, sizeof(plain),
|
||||
cipher, authTag );
|
||||
}
|
||||
|
||||
END_INTEL_CYCLES
|
||||
@@ -801,7 +802,8 @@ void bench_chacha20_poly1305_aead(void)
|
||||
persec = persec / 1024;
|
||||
#endif
|
||||
|
||||
printf("ChaCha20-Poly1305 AEAD %d %s took %5.3f seconds, %7.3f MB/s", numBlocks, blockType, total, persec);
|
||||
printf("ChaCha-Poly %d %s took %5.3f seconds, %7.3f MB/s",
|
||||
numBlocks, blockType, total, persec);
|
||||
SHOW_INTEL_CYCLES
|
||||
printf("\n");
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if( defined( HAVE_CHACHA ) && defined( HAVE_POLY1305 ) )
|
||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
|
||||
#include <wolfssl/wolfcrypt/chacha20_poly1305.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
@@ -47,14 +47,16 @@
|
||||
#define CHACHA20_POLY1305_AEAD_INITIAL_COUNTER 0
|
||||
#define CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT 16
|
||||
|
||||
static void _word32ToLittle64( const word32 inLittle32, byte outLittle64[8] );
|
||||
static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
static void word32ToLittle64(const word32 inLittle32, byte outLittle64[8]);
|
||||
static int calculateAuthTag(
|
||||
const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte *inCiphertext, const word32 inCiphertextLen,
|
||||
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
|
||||
static int constantTimeCompare(const byte *a, const byte *b, word32 len);
|
||||
|
||||
WOLFSSL_API int wc_ChaCha20Poly1305_Encrypt( const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
int wc_ChaCha20Poly1305_Encrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inPlaintext, const word32 inPlaintextLen,
|
||||
@@ -65,7 +67,7 @@ WOLFSSL_API int wc_ChaCha20Poly1305_Encrypt( const byte inKey[CHACHA20_POLY1305_
|
||||
byte poly1305Key[CHACHA20_POLY1305_AEAD_KEYSIZE];
|
||||
ChaCha chaChaCtx;
|
||||
|
||||
// Validate function arguments
|
||||
/* Validate function arguments */
|
||||
|
||||
if (!inKey || !inIV ||
|
||||
!inPlaintext || !inPlaintextLen ||
|
||||
@@ -75,39 +77,37 @@ WOLFSSL_API int wc_ChaCha20Poly1305_Encrypt( const byte inKey[CHACHA20_POLY1305_
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
ForceZero( poly1305Key, sizeof( poly1305Key ) );
|
||||
XMEMSET(poly1305Key, 0, sizeof(poly1305Key));
|
||||
|
||||
err = 0;
|
||||
/* Create the Poly1305 key */
|
||||
err = wc_Chacha_SetKey(&chaChaCtx, inKey, CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
if (err != 0) return err;
|
||||
|
||||
// Create the Poly1305 key
|
||||
err = wc_Chacha_SetIV(&chaChaCtx, inIV,
|
||||
CHACHA20_POLY1305_AEAD_INITIAL_COUNTER);
|
||||
if (err != 0) return err;
|
||||
|
||||
err += wc_Chacha_SetKey( &chaChaCtx, inKey, CHACHA20_POLY1305_AEAD_KEYSIZE );
|
||||
err += wc_Chacha_SetIV( &chaChaCtx, inIV, CHACHA20_POLY1305_AEAD_INITIAL_COUNTER );
|
||||
err += wc_Chacha_Process( &chaChaCtx, poly1305Key, poly1305Key, CHACHA20_POLY1305_AEAD_KEYSIZE );
|
||||
if( err )
|
||||
{
|
||||
return err;
|
||||
}
|
||||
err = wc_Chacha_Process(&chaChaCtx, poly1305Key, poly1305Key,
|
||||
CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
if (err != 0) return err;
|
||||
|
||||
// Encrypt the plaintext using ChaCha20
|
||||
|
||||
err = wc_Chacha_Process( &chaChaCtx, outCiphertext, inPlaintext, inPlaintextLen );
|
||||
if( err )
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
// Calculate the Poly1305 auth tag
|
||||
|
||||
err = _calculateAuthTag( poly1305Key,
|
||||
/* Encrypt the plaintext using ChaCha20 */
|
||||
err = wc_Chacha_Process(&chaChaCtx, outCiphertext, inPlaintext,
|
||||
inPlaintextLen);
|
||||
/* Calculate the Poly1305 auth tag */
|
||||
if (err == 0)
|
||||
err = calculateAuthTag(poly1305Key,
|
||||
inAAD, inAADLen,
|
||||
outCiphertext, inPlaintextLen,
|
||||
outAuthTag);
|
||||
ForceZero(poly1305Key, sizeof(poly1305Key));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
WOLFSSL_API int wc_ChaCha20Poly1305_Decrypt( const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
|
||||
int wc_ChaCha20Poly1305_Decrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inCiphertext, const word32 inCiphertextLen,
|
||||
@@ -119,7 +119,7 @@ WOLFSSL_API int wc_ChaCha20Poly1305_Decrypt( const byte inKey[CHACHA20_POLY1305_
|
||||
ChaCha chaChaCtx;
|
||||
byte calculatedAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
|
||||
|
||||
// Validate function arguments
|
||||
/* Validate function arguments */
|
||||
|
||||
if (!inKey || !inIV ||
|
||||
!inCiphertext || !inCiphertextLen ||
|
||||
@@ -129,43 +129,46 @@ WOLFSSL_API int wc_ChaCha20Poly1305_Decrypt( const byte inKey[CHACHA20_POLY1305_
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
ForceZero( calculatedAuthTag, sizeof( calculatedAuthTag ) );
|
||||
ForceZero( poly1305Key, sizeof( poly1305Key ) );
|
||||
XMEMSET(calculatedAuthTag, 0, sizeof(calculatedAuthTag));
|
||||
XMEMSET(poly1305Key, 0, sizeof(poly1305Key));
|
||||
|
||||
err = 0;
|
||||
/* Create the Poly1305 key */
|
||||
err = wc_Chacha_SetKey(&chaChaCtx, inKey, CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
if (err != 0) return err;
|
||||
|
||||
// Create the Poly1305 key
|
||||
err = wc_Chacha_SetIV(&chaChaCtx, inIV,
|
||||
CHACHA20_POLY1305_AEAD_INITIAL_COUNTER);
|
||||
if (err != 0) return err;
|
||||
|
||||
err += wc_Chacha_SetKey( &chaChaCtx, inKey, CHACHA20_POLY1305_AEAD_KEYSIZE );
|
||||
err += wc_Chacha_SetIV( &chaChaCtx, inIV, CHACHA20_POLY1305_AEAD_INITIAL_COUNTER );
|
||||
err += wc_Chacha_Process( &chaChaCtx, poly1305Key, poly1305Key, CHACHA20_POLY1305_AEAD_KEYSIZE );
|
||||
if( err )
|
||||
{
|
||||
return err;
|
||||
}
|
||||
err = wc_Chacha_Process(&chaChaCtx, poly1305Key, poly1305Key,
|
||||
CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
if (err != 0) return err;
|
||||
|
||||
// Calculate the Poly1305 auth tag
|
||||
|
||||
err = _calculateAuthTag( poly1305Key,
|
||||
/* Calculate the Poly1305 auth tag */
|
||||
err = calculateAuthTag(poly1305Key,
|
||||
inAAD, inAADLen,
|
||||
inCiphertext, inCiphertextLen,
|
||||
calculatedAuthTag);
|
||||
|
||||
// Compare the calculated auth tag with the received one
|
||||
|
||||
if( constantTimeCompare( inAuthTag, calculatedAuthTag, CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE ) )
|
||||
/* Compare the calculated auth tag with the received one */
|
||||
if (err == 0 && constantTimeCompare(inAuthTag, calculatedAuthTag,
|
||||
CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE) != 0)
|
||||
{
|
||||
return MAC_CMP_FAILED_E;
|
||||
err = MAC_CMP_FAILED_E;
|
||||
}
|
||||
|
||||
// Decrypt the received ciphertext
|
||||
|
||||
err = wc_Chacha_Process( &chaChaCtx, outPlaintext, inCiphertext, inCiphertextLen );
|
||||
/* Decrypt the received ciphertext */
|
||||
if (err == 0)
|
||||
err = wc_Chacha_Process(&chaChaCtx, outPlaintext, inCiphertext,
|
||||
inCiphertextLen);
|
||||
ForceZero(poly1305Key, sizeof(poly1305Key));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
|
||||
static int calculateAuthTag(
|
||||
const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte *inAAD, const word32 inAADLen,
|
||||
const byte *inCiphertext, const word32 inCiphertextLen,
|
||||
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE])
|
||||
@@ -176,26 +179,27 @@ static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZ
|
||||
word32 paddingLen;
|
||||
byte little64[8];
|
||||
|
||||
ForceZero( padding, sizeof( padding ) );
|
||||
XMEMSET(padding, 0, sizeof(padding));
|
||||
paddingLen = 0;
|
||||
|
||||
// Initialize Poly1305
|
||||
/* Initialize Poly1305 */
|
||||
|
||||
err = wc_Poly1305SetKey( &poly1305Ctx, inAuthKey, CHACHA20_POLY1305_AEAD_KEYSIZE );
|
||||
err = wc_Poly1305SetKey(&poly1305Ctx, inAuthKey,
|
||||
CHACHA20_POLY1305_AEAD_KEYSIZE);
|
||||
if (err)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
// Create the authTag by MAC'ing the following items:
|
||||
/* Create the authTag by MAC'ing the following items: */
|
||||
|
||||
// -- AAD
|
||||
/* -- AAD */
|
||||
|
||||
if (inAAD && inAADLen)
|
||||
{
|
||||
err = wc_Poly1305Update(&poly1305Ctx, inAAD, inAADLen);
|
||||
|
||||
// -- padding1: pad the AAD to 16 bytes
|
||||
/* -- padding1: pad the AAD to 16 bytes */
|
||||
|
||||
paddingLen = -inAADLen & (CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT - 1);
|
||||
if (paddingLen)
|
||||
@@ -209,7 +213,7 @@ static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZ
|
||||
}
|
||||
}
|
||||
|
||||
// -- Ciphertext
|
||||
/* -- Ciphertext */
|
||||
|
||||
err = wc_Poly1305Update(&poly1305Ctx, inCiphertext, inCiphertextLen);
|
||||
if (err)
|
||||
@@ -217,9 +221,10 @@ static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZ
|
||||
return err;
|
||||
}
|
||||
|
||||
// -- padding2: pad the ciphertext to 16 bytes
|
||||
/* -- padding2: pad the ciphertext to 16 bytes */
|
||||
|
||||
paddingLen = -inCiphertextLen & ( CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT - 1 );
|
||||
paddingLen = -inCiphertextLen &
|
||||
(CHACHA20_POLY1305_MAC_PADDING_ALIGNMENT - 1);
|
||||
if (paddingLen)
|
||||
{
|
||||
err = wc_Poly1305Update(&poly1305Ctx, padding, paddingLen);
|
||||
@@ -229,9 +234,9 @@ static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZ
|
||||
}
|
||||
}
|
||||
|
||||
// -- AAD length as a 64-bit little endian integer
|
||||
/* -- AAD length as a 64-bit little endian integer */
|
||||
|
||||
_word32ToLittle64( inAADLen, little64 );
|
||||
word32ToLittle64(inAADLen, little64);
|
||||
|
||||
err = wc_Poly1305Update(&poly1305Ctx, little64, sizeof(little64));
|
||||
if (err)
|
||||
@@ -239,9 +244,9 @@ static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZ
|
||||
return err;
|
||||
}
|
||||
|
||||
// -- Ciphertext length as a 64-bit little endian integer
|
||||
/* -- Ciphertext length as a 64-bit little endian integer */
|
||||
|
||||
_word32ToLittle64( inCiphertextLen, little64 );
|
||||
word32ToLittle64(inCiphertextLen, little64);
|
||||
|
||||
err = wc_Poly1305Update(&poly1305Ctx, little64, sizeof(little64));
|
||||
if (err)
|
||||
@@ -249,16 +254,17 @@ static int _calculateAuthTag( const byte inAuthKey[CHACHA20_POLY1305_AEAD_KEYSIZ
|
||||
return err;
|
||||
}
|
||||
|
||||
// Finalize the auth tag
|
||||
/* Finalize the auth tag */
|
||||
|
||||
err = wc_Poly1305Final(&poly1305Ctx, outAuthTag);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void _word32ToLittle64( const word32 inLittle32, byte outLittle64[8] )
|
||||
|
||||
static void word32ToLittle64(const word32 inLittle32, byte outLittle64[8])
|
||||
{
|
||||
ForceZero( outLittle64, 8 );
|
||||
XMEMSET(outLittle64, 0, 8);
|
||||
|
||||
outLittle64[0] = (inLittle32 & 0x000000FF);
|
||||
outLittle64[1] = (inLittle32 & 0x0000FF00) >> 8;
|
||||
@@ -266,6 +272,7 @@ static void _word32ToLittle64( const word32 inLittle32, byte outLittle64[8] )
|
||||
outLittle64[3] = (inLittle32 & 0xFF000000) >> 24;
|
||||
}
|
||||
|
||||
|
||||
static int constantTimeCompare(const byte *a, const byte *b, word32 len)
|
||||
{
|
||||
word32 i;
|
||||
|
@@ -316,6 +316,9 @@ const char* wc_GetErrorString(int error)
|
||||
case THREAD_STORE_SET_E:
|
||||
return "Thread Storage Set error";
|
||||
|
||||
case MAC_CMP_FAILED_E:
|
||||
return "MAC comparison failed";
|
||||
|
||||
default:
|
||||
return "unknown error number";
|
||||
|
||||
|
@@ -2074,11 +2074,11 @@ int poly1305_test(void)
|
||||
#endif /* HAVE_POLY1305 */
|
||||
|
||||
|
||||
#if(defined(HAVE_CHACHA) && defined(HAVE_POLY1305))
|
||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
int chacha20_poly1305_aead_test(void)
|
||||
{
|
||||
// Test #1 from Section 2.8.2 of draft-irtf-cfrg-chacha20-poly1305-10
|
||||
// https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10
|
||||
/* Test #1 from Section 2.8.2 of draft-irtf-cfrg-chacha20-poly1305-10 */
|
||||
/* https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10 */
|
||||
|
||||
const byte key1[] = {
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
@@ -2138,8 +2138,8 @@ int chacha20_poly1305_aead_test(void)
|
||||
0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91
|
||||
};
|
||||
|
||||
// Test #2 from Appendix A.2 in draft-irtf-cfrg-chacha20-poly1305-10
|
||||
// https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10
|
||||
/* Test #2 from Appendix A.2 in draft-irtf-cfrg-chacha20-poly1305-10 */
|
||||
/* https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10 */
|
||||
|
||||
const byte key2[] = {
|
||||
0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a,
|
||||
@@ -2246,7 +2246,7 @@ int chacha20_poly1305_aead_test(void)
|
||||
XMEMSET(generatedAuthTag, 0, sizeof(generatedAuthTag));
|
||||
XMEMSET(generatedPlaintext, 0, sizeof(generatedPlaintext));
|
||||
|
||||
// Test #1
|
||||
/* Test #1 */
|
||||
|
||||
err = wc_ChaCha20Poly1305_Encrypt(key1, iv1,
|
||||
aad1, sizeof(aad1),
|
||||
@@ -2257,7 +2257,7 @@ int chacha20_poly1305_aead_test(void)
|
||||
return err;
|
||||
}
|
||||
|
||||
// -- Check the ciphertext and authtag
|
||||
/* -- Check the ciphertext and authtag */
|
||||
|
||||
if (XMEMCMP(generatedCiphertext, cipher1, sizeof(cipher1)))
|
||||
{
|
||||
@@ -2269,7 +2269,7 @@ int chacha20_poly1305_aead_test(void)
|
||||
return -1065;
|
||||
}
|
||||
|
||||
// -- Verify decryption works
|
||||
/* -- Verify decryption works */
|
||||
|
||||
err = wc_ChaCha20Poly1305_Decrypt(key1, iv1,
|
||||
aad1, sizeof(aad1),
|
||||
@@ -2289,7 +2289,7 @@ int chacha20_poly1305_aead_test(void)
|
||||
XMEMSET(generatedAuthTag, 0, sizeof(generatedAuthTag));
|
||||
XMEMSET(generatedPlaintext, 0, sizeof(generatedPlaintext));
|
||||
|
||||
// Test #2
|
||||
/* Test #2 */
|
||||
|
||||
err = wc_ChaCha20Poly1305_Encrypt(key2, iv2,
|
||||
aad2, sizeof(aad2),
|
||||
@@ -2300,7 +2300,7 @@ int chacha20_poly1305_aead_test(void)
|
||||
return err;
|
||||
}
|
||||
|
||||
// -- Check the ciphertext and authtag
|
||||
/* -- Check the ciphertext and authtag */
|
||||
|
||||
if (XMEMCMP(generatedCiphertext, cipher2, sizeof(cipher2)))
|
||||
{
|
||||
@@ -2312,7 +2312,7 @@ int chacha20_poly1305_aead_test(void)
|
||||
return -1068;
|
||||
}
|
||||
|
||||
// -- Verify decryption works
|
||||
/* -- Verify decryption works */
|
||||
|
||||
err = wc_ChaCha20Poly1305_Decrypt(key2, iv2,
|
||||
aad2, sizeof(aad2),
|
||||
|
@@ -26,8 +26,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIBWOLFSSL_VERSION_STRING "3.4.0"
|
||||
#define LIBWOLFSSL_VERSION_HEX 0x03004000
|
||||
#define LIBWOLFSSL_VERSION_STRING "3.4.1"
|
||||
#define LIBWOLFSSL_VERSION_HEX 0x03004001
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -17,13 +17,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
* This implementation of the ChaCha20-Poly1305 AEAD is based on "ChaCha20
|
||||
*/
|
||||
|
||||
/* This implementation of the ChaCha20-Poly1305 AEAD is based on "ChaCha20
|
||||
* and Poly1305 for IETF protocols" (draft-irtf-cfrg-chacha20-poly1305-10):
|
||||
* https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10
|
||||
*/
|
||||
|
||||
#if( defined( HAVE_CHACHA ) && defined( HAVE_POLY1305 ) )
|
||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
|
||||
#ifndef WOLF_CRYPT_CHACHA20_POLY1305_H
|
||||
#define WOLF_CRYPT_CHACHA20_POLY1305_H
|
||||
@@ -52,14 +53,18 @@ extern "C" {
|
||||
* concatenating a constant value.
|
||||
*/
|
||||
|
||||
WOLFSSL_API int wc_ChaCha20Poly1305_Encrypt(const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
WOLFSSL_API
|
||||
int wc_ChaCha20Poly1305_Encrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inPlaintext, const word32 inPlaintextLen,
|
||||
byte* outCiphertext,
|
||||
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
|
||||
|
||||
WOLFSSL_API int wc_ChaCha20Poly1305_Decrypt(const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
WOLFSSL_API
|
||||
int wc_ChaCha20Poly1305_Decrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inCiphertext, const word32 inCiphertextLen,
|
||||
|
@@ -32,6 +32,7 @@ nobase_include_HEADERS+= \
|
||||
wolfssl/wolfcrypt/pwdbased.h \
|
||||
wolfssl/wolfcrypt/rabbit.h \
|
||||
wolfssl/wolfcrypt/chacha.h \
|
||||
wolfssl/wolfcrypt/chacha20_poly1305.h \
|
||||
wolfssl/wolfcrypt/random.h \
|
||||
wolfssl/wolfcrypt/ripemd.h \
|
||||
wolfssl/wolfcrypt/rsa.h \
|
||||
|
Reference in New Issue
Block a user