mirror of https://github.com/wolfSSL/wolfssl.git
Fix: Remove old test files and update includes
Co-Authored-By: kaleb@wolfssl.com <kaleb@wolfssl.com>devin/1739818351-optimize-test-suite
parent
e27c00d3f8
commit
a98ef2c20d
|
@ -1,114 +0,0 @@
|
|||
/* test_blake2.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/blake2.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_blake2.h>
|
||||
|
||||
/*
|
||||
* Unit test for the wc_InitBlake2b()
|
||||
*/
|
||||
int test_wc_InitBlake2b(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef HAVE_BLAKE2
|
||||
Blake2b blake;
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitBlake2b(&blake, 64), 0);
|
||||
/* Test bad arg. */
|
||||
ExpectIntEQ(wc_InitBlake2b(NULL, 64), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2b(NULL, 128), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2b(&blake, 128), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2b(NULL, 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2b(&blake, 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_InitBlake2b*/
|
||||
|
||||
/*
|
||||
* Unit test for the wc_InitBlake2b_WithKey()
|
||||
*/
|
||||
int test_wc_InitBlake2b_WithKey(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef HAVE_BLAKE2
|
||||
Blake2b blake;
|
||||
word32 digestSz = BLAKE2B_KEYBYTES;
|
||||
byte key[BLAKE2B_KEYBYTES];
|
||||
word32 keylen = BLAKE2B_KEYBYTES;
|
||||
|
||||
XMEMSET(key, 0, sizeof(key));
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitBlake2b_WithKey(&blake, digestSz, key, keylen), 0);
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_InitBlake2b_WithKey(NULL, digestSz, key, keylen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2b_WithKey(&blake, digestSz, key, 256),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2b_WithKey(&blake, digestSz, NULL, keylen), 0);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END wc_InitBlake2b_WithKey*/
|
||||
|
||||
/*
|
||||
* Unit test for the wc_InitBlake2s_WithKey()
|
||||
*/
|
||||
int test_wc_InitBlake2s_WithKey(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef HAVE_BLAKE2S
|
||||
Blake2s blake;
|
||||
word32 digestSz = BLAKE2S_KEYBYTES;
|
||||
byte *key = (byte*)"01234567890123456789012345678901";
|
||||
word32 keylen = BLAKE2S_KEYBYTES;
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitBlake2s_WithKey(&blake, digestSz, key, keylen), 0);
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_InitBlake2s_WithKey(NULL, digestSz, key, keylen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2s_WithKey(&blake, digestSz, key, 256),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_InitBlake2s_WithKey(&blake, digestSz, NULL, keylen), 0);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END wc_InitBlake2s_WithKey*/
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* test_blake2.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_BLAKE2_H
|
||||
#define WOLFCRYPT_TEST_BLAKE2_H
|
||||
|
||||
int test_wc_InitBlake2b(void);
|
||||
int test_wc_InitBlake2b_WithKey(void);
|
||||
int test_wc_InitBlake2s_WithKey(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_BLAKE2_H */
|
|
@ -1,230 +0,0 @@
|
|||
/* test_hash.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_hash.h>
|
||||
|
||||
int test_wc_HashInit(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
int i; /* 0 indicates tests passed, 1 indicates failure */
|
||||
|
||||
wc_HashAlg hash;
|
||||
|
||||
/* enum for holding supported algorithms, #ifndef's restrict if disabled */
|
||||
enum wc_HashType enumArray[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
};
|
||||
/* dynamically finds the length */
|
||||
int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType));
|
||||
|
||||
/* For loop to test various arguments... */
|
||||
for (i = 0; i < enumlen; i++) {
|
||||
/* check for bad args */
|
||||
ExpectIntEQ(wc_HashInit(&hash, enumArray[i]), 0);
|
||||
wc_HashFree(&hash, enumArray[i]);
|
||||
|
||||
/* check for null ptr */
|
||||
ExpectIntEQ(wc_HashInit(NULL, enumArray[i]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
} /* end of for loop */
|
||||
|
||||
return EXPECT_RESULT();
|
||||
} /* end of test_wc_HashInit */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_HashSetFlags()
|
||||
*/
|
||||
int test_wc_HashSetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_HASH_FLAGS
|
||||
wc_HashAlg hash;
|
||||
word32 flags = 0;
|
||||
int i, j;
|
||||
int notSupportedLen;
|
||||
|
||||
/* enum for holding supported algorithms, #ifndef's restrict if disabled */
|
||||
enum wc_HashType enumArray[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
WC_HASH_TYPE_SHA3_224,
|
||||
#endif
|
||||
};
|
||||
enum wc_HashType notSupported[] = {
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
WC_HASH_TYPE_MD2,
|
||||
WC_HASH_TYPE_MD4,
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
WC_HASH_TYPE_NONE,
|
||||
};
|
||||
|
||||
/* dynamically finds the length */
|
||||
int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType));
|
||||
|
||||
/* For loop to test various arguments... */
|
||||
for (i = 0; i < enumlen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, enumArray[i]), 0);
|
||||
ExpectIntEQ(wc_HashSetFlags(&hash, enumArray[i], flags), 0);
|
||||
ExpectTrue((flags & WC_HASH_FLAG_ISCOPY) == 0);
|
||||
ExpectIntEQ(wc_HashSetFlags(NULL, enumArray[i], flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_HashFree(&hash, enumArray[i]);
|
||||
|
||||
}
|
||||
/* For loop to test not supported cases */
|
||||
notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType));
|
||||
for (j = 0; j < notSupportedLen; j++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupported[j]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashSetFlags(&hash, notSupported[j], flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFree(&hash, notSupported[j]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_HashSetFlags */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_HashGetFlags()
|
||||
*/
|
||||
int test_wc_HashGetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_HASH_FLAGS
|
||||
wc_HashAlg hash;
|
||||
word32 flags = 0;
|
||||
int i, j;
|
||||
|
||||
/* enum for holding supported algorithms, #ifndef's restrict if disabled */
|
||||
enum wc_HashType enumArray[] = {
|
||||
#ifndef NO_MD5
|
||||
WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
WC_HASH_TYPE_SHA3_224,
|
||||
#endif
|
||||
};
|
||||
enum wc_HashType notSupported[] = {
|
||||
WC_HASH_TYPE_MD5_SHA,
|
||||
WC_HASH_TYPE_MD2,
|
||||
WC_HASH_TYPE_MD4,
|
||||
WC_HASH_TYPE_BLAKE2B,
|
||||
WC_HASH_TYPE_BLAKE2S,
|
||||
WC_HASH_TYPE_NONE,
|
||||
};
|
||||
int enumlen = (sizeof(enumArray)/sizeof(enum wc_HashType));
|
||||
int notSupportedLen;
|
||||
|
||||
/* For loop to test various arguments... */
|
||||
for (i = 0; i < enumlen; i++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, enumArray[i]), 0);
|
||||
ExpectIntEQ(wc_HashGetFlags(&hash, enumArray[i], &flags), 0);
|
||||
ExpectTrue((flags & WC_HASH_FLAG_ISCOPY) == 0);
|
||||
ExpectIntEQ(wc_HashGetFlags(NULL, enumArray[i], &flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_HashFree(&hash, enumArray[i]);
|
||||
}
|
||||
/* For loop to test not supported cases */
|
||||
notSupportedLen = (sizeof(notSupported)/sizeof(enum wc_HashType));
|
||||
for (j = 0; j < notSupportedLen; j++) {
|
||||
ExpectIntEQ(wc_HashInit(&hash, notSupported[j]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashGetFlags(&hash, notSupported[j], &flags),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_HashFree(&hash, notSupported[j]),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
}
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_HashGetFlags */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* test_hash.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_HASH_H
|
||||
#define WOLFCRYPT_TEST_HASH_H
|
||||
|
||||
int test_wc_HashInit(void);
|
||||
int test_wc_HashSetFlags(void);
|
||||
int test_wc_HashGetFlags(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_HASH_H */
|
|
@ -1,144 +0,0 @@
|
|||
/* test_md5.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/md5.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_md5.h>
|
||||
|
||||
/*
|
||||
* Unit test for the wc_InitMd5()
|
||||
*/
|
||||
int test_wc_InitMd5(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD5
|
||||
wc_Md5 md5;
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitMd5(&md5), 0);
|
||||
/* Test bad arg. */
|
||||
ExpectIntEQ(wc_InitMd5(NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Md5Free(&md5);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_InitMd5 */
|
||||
|
||||
|
||||
/*
|
||||
* Testing wc_UpdateMd5()
|
||||
*/
|
||||
int test_wc_Md5Update(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD5
|
||||
wc_Md5 md5;
|
||||
byte hash[WC_MD5_DIGEST_SIZE];
|
||||
testVector a, b, c;
|
||||
|
||||
ExpectIntEQ(wc_InitMd5(&md5), 0);
|
||||
|
||||
/* Input */
|
||||
a.input = "a";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
ExpectIntEQ(wc_Md5Update(&md5, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_Md5Final(&md5, hash), 0);
|
||||
|
||||
/* Update input. */
|
||||
a.input = "abc";
|
||||
a.output = "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f"
|
||||
"\x72";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
a.outLen = XSTRLEN(a.output);
|
||||
ExpectIntEQ(wc_Md5Update(&md5, (byte*) a.input, (word32) a.inLen), 0);
|
||||
ExpectIntEQ(wc_Md5Final(&md5, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, a.output, WC_MD5_DIGEST_SIZE), 0);
|
||||
|
||||
/* Pass in bad values. */
|
||||
b.input = NULL;
|
||||
b.inLen = 0;
|
||||
ExpectIntEQ(wc_Md5Update(&md5, (byte*)b.input, (word32)b.inLen), 0);
|
||||
c.input = NULL;
|
||||
c.inLen = WC_MD5_DIGEST_SIZE;
|
||||
ExpectIntEQ(wc_Md5Update(&md5, (byte*)c.input, (word32)c.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Md5Update(NULL, (byte*)a.input, (word32)a.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Md5Free(&md5);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Md5Update() */
|
||||
|
||||
/*
|
||||
* Unit test on wc_Md5Final() in wolfcrypt/src/md5.c
|
||||
*/
|
||||
int test_wc_Md5Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_MD5
|
||||
/* Instantiate */
|
||||
wc_Md5 md5;
|
||||
byte* hash_test[3];
|
||||
byte hash1[WC_MD5_DIGEST_SIZE];
|
||||
byte hash2[2*WC_MD5_DIGEST_SIZE];
|
||||
byte hash3[5*WC_MD5_DIGEST_SIZE];
|
||||
int times, i;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitMd5(&md5), 0);
|
||||
|
||||
hash_test[0] = hash1;
|
||||
hash_test[1] = hash2;
|
||||
hash_test[2] = hash3;
|
||||
times = sizeof(hash_test)/sizeof(byte*);
|
||||
for (i = 0; i < times; i++) {
|
||||
ExpectIntEQ(wc_Md5Final(&md5, hash_test[i]), 0);
|
||||
}
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Md5Final(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Md5Final(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Md5Final(&md5, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Md5Free(&md5);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* test_md5.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_MD5_H
|
||||
#define WOLFCRYPT_TEST_MD5_H
|
||||
|
||||
int test_wc_InitMd5(void);
|
||||
int test_wc_Md5Update(void);
|
||||
int test_wc_Md5Final(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_MD5_H */
|
|
@ -1,139 +0,0 @@
|
|||
/* test_ripemd.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/ripemd.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_ripemd.h>
|
||||
|
||||
/*
|
||||
* Testing wc_InitRipeMd()
|
||||
*/
|
||||
int test_wc_InitRipeMd(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_RIPEMD
|
||||
RipeMd ripemd;
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitRipeMd(&ripemd), 0);
|
||||
/* Test bad arg. */
|
||||
ExpectIntEQ(wc_InitRipeMd(NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
|
||||
} /* END test_wc_InitRipeMd */
|
||||
|
||||
/*
|
||||
* Testing wc_RipeMdUpdate()
|
||||
*/
|
||||
int test_wc_RipeMdUpdate(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_RIPEMD
|
||||
RipeMd ripemd;
|
||||
byte hash[RIPEMD_DIGEST_SIZE];
|
||||
testVector a, b, c;
|
||||
|
||||
ExpectIntEQ(wc_InitRipeMd(&ripemd), 0);
|
||||
|
||||
/* Input */
|
||||
a.input = "a";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
ExpectIntEQ(wc_RipeMdUpdate(&ripemd, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_RipeMdFinal(&ripemd, hash), 0);
|
||||
|
||||
/* Update input. */
|
||||
a.input = "abc";
|
||||
a.output = "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04\x4a\x8e\x98\xc6"
|
||||
"\xb0\x87\xf1\x5a\x0b\xfc";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
a.outLen = XSTRLEN(a.output);
|
||||
ExpectIntEQ(wc_RipeMdUpdate(&ripemd, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_RipeMdFinal(&ripemd, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, a.output, RIPEMD_DIGEST_SIZE), 0);
|
||||
|
||||
/* Pass in bad values. */
|
||||
b.input = NULL;
|
||||
b.inLen = 0;
|
||||
ExpectIntEQ(wc_RipeMdUpdate(&ripemd, (byte*)b.input, (word32)b.inLen), 0);
|
||||
c.input = NULL;
|
||||
c.inLen = RIPEMD_DIGEST_SIZE;
|
||||
ExpectIntEQ(wc_RipeMdUpdate(&ripemd, (byte*)c.input, (word32)c.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_RipeMdUpdate(NULL, (byte*)a.input, (word32)a.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_RipeMdUdpate */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_RipeMdFinal()
|
||||
*/
|
||||
int test_wc_RipeMdFinal(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_RIPEMD
|
||||
RipeMd ripemd;
|
||||
byte* hash_test[3];
|
||||
byte hash1[RIPEMD_DIGEST_SIZE];
|
||||
byte hash2[2*RIPEMD_DIGEST_SIZE];
|
||||
byte hash3[5*RIPEMD_DIGEST_SIZE];
|
||||
int times, i;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitRipeMd(&ripemd), 0);
|
||||
|
||||
hash_test[0] = hash1;
|
||||
hash_test[1] = hash2;
|
||||
hash_test[2] = hash3;
|
||||
times = sizeof(hash_test) / sizeof(byte*);
|
||||
/* Testing oversized buffers. */
|
||||
for (i = 0; i < times; i++) {
|
||||
ExpectIntEQ(wc_RipeMdFinal(&ripemd, hash_test[i]), 0);
|
||||
}
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_RipeMdFinal(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_RipeMdFinal(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_RipeMdFinal(&ripemd, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_RipeMdFinal */
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* test_ripemd.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_RIPEMD_H
|
||||
#define WOLFCRYPT_TEST_RIPEMD_H
|
||||
|
||||
int test_wc_InitRipeMd(void);
|
||||
int test_wc_RipeMdUpdate(void);
|
||||
int test_wc_RipeMdFinal(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_RIPEMD_H */
|
|
@ -1,146 +0,0 @@
|
|||
/* test_sha.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_sha.h>
|
||||
|
||||
/*
|
||||
* Unit test for the wc_InitSha()
|
||||
*/
|
||||
int test_wc_InitSha(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA
|
||||
wc_Sha sha;
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitSha(&sha), 0);
|
||||
/* Test bad arg. */
|
||||
ExpectIntEQ(wc_InitSha(NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_ShaFree(&sha);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_InitSha */
|
||||
|
||||
/*
|
||||
* Tesing wc_ShaUpdate()
|
||||
*/
|
||||
int test_wc_ShaUpdate(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA
|
||||
wc_Sha sha;
|
||||
byte hash[WC_SHA_DIGEST_SIZE];
|
||||
testVector a, b, c;
|
||||
|
||||
ExpectIntEQ(wc_InitSha(&sha), 0);
|
||||
|
||||
/* Input. */
|
||||
a.input = "a";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
|
||||
ExpectIntEQ(wc_ShaUpdate(&sha, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_ShaUpdate(&sha, (byte*)a.input, 0), 0);
|
||||
ExpectIntEQ(wc_ShaUpdate(&sha, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_ShaFinal(&sha, hash), 0);
|
||||
|
||||
/* Update input. */
|
||||
a.input = "abc";
|
||||
a.output = "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2"
|
||||
"\x6C\x9C\xD0\xD8\x9D";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
a.outLen = XSTRLEN(a.output);
|
||||
|
||||
ExpectIntEQ(wc_ShaUpdate(&sha, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_ShaFinal(&sha, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, a.output, WC_SHA_DIGEST_SIZE), 0);
|
||||
|
||||
/* Try passing in bad values. */
|
||||
b.input = NULL;
|
||||
b.inLen = 0;
|
||||
ExpectIntEQ(wc_ShaUpdate(&sha, (byte*)b.input, (word32)b.inLen), 0);
|
||||
c.input = NULL;
|
||||
c.inLen = WC_SHA_DIGEST_SIZE;
|
||||
ExpectIntEQ(wc_ShaUpdate(&sha, (byte*)c.input, (word32)c.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_ShaUpdate(NULL, (byte*)a.input, (word32)a.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_ShaFree(&sha);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_ShaUpdate() */
|
||||
|
||||
/*
|
||||
* Unit test on wc_ShaFinal
|
||||
*/
|
||||
int test_wc_ShaFinal(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA
|
||||
wc_Sha sha;
|
||||
byte* hash_test[3];
|
||||
byte hash1[WC_SHA_DIGEST_SIZE];
|
||||
byte hash2[2*WC_SHA_DIGEST_SIZE];
|
||||
byte hash3[5*WC_SHA_DIGEST_SIZE];
|
||||
int times, i;
|
||||
|
||||
/* Initialize*/
|
||||
ExpectIntEQ(wc_InitSha(&sha), 0);
|
||||
|
||||
hash_test[0] = hash1;
|
||||
hash_test[1] = hash2;
|
||||
hash_test[2] = hash3;
|
||||
times = sizeof(hash_test)/sizeof(byte*);
|
||||
for (i = 0; i < times; i++) {
|
||||
ExpectIntEQ(wc_ShaFinal(&sha, hash_test[i]), 0);
|
||||
}
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_ShaFinal(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_ShaFinal(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_ShaFinal(&sha, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_ShaFree(&sha);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_ShaFinal */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* test_sha.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_SHA_H
|
||||
#define WOLFCRYPT_TEST_SHA_H
|
||||
|
||||
int test_wc_InitSha(void);
|
||||
int test_wc_ShaUpdate(void);
|
||||
int test_wc_ShaFinal(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_SHA_H */
|
|
@ -1,503 +0,0 @@
|
|||
/* test_sha256.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_sha256.h>
|
||||
|
||||
/*******************************************************************************
|
||||
* SHA-256
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Unit test for wc_InitSha256()
|
||||
*/
|
||||
int test_wc_InitSha256(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256 sha256;
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitSha256(&sha256), 0);
|
||||
/* Test bad arg. */
|
||||
ExpectIntEQ(wc_InitSha256(NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha256Free(&sha256);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_InitSha256 */
|
||||
|
||||
/*
|
||||
* Unit test for wc_Sha256Update()
|
||||
*/
|
||||
int test_wc_Sha256Update(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256 sha256;
|
||||
byte hash[WC_SHA256_DIGEST_SIZE];
|
||||
byte hash_unaligned[WC_SHA256_DIGEST_SIZE+1];
|
||||
testVector a, b, c;
|
||||
|
||||
ExpectIntEQ(wc_InitSha256(&sha256), 0);
|
||||
|
||||
/* Input. */
|
||||
a.input = "a";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
ExpectIntEQ(wc_Sha256Update(&sha256, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_Sha256Update(&sha256, (byte*)a.input, 0), 0);
|
||||
ExpectIntEQ(wc_Sha256Update(&sha256, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_Sha256Final(&sha256, hash), 0);
|
||||
|
||||
/* Update input. */
|
||||
a.input = "abc";
|
||||
a.output = "\xBA\x78\x16\xBF\x8F\x01\xCF\xEA\x41\x41\x40\xDE\x5D\xAE\x22"
|
||||
"\x23\xB0\x03\x61\xA3\x96\x17\x7A\x9C\xB4\x10\xFF\x61\xF2\x00"
|
||||
"\x15\xAD";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
a.outLen = XSTRLEN(a.output);
|
||||
ExpectIntEQ(wc_Sha256Update(&sha256, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_Sha256Final(&sha256, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, a.output, WC_SHA256_DIGEST_SIZE), 0);
|
||||
|
||||
/* Unaligned check. */
|
||||
ExpectIntEQ(wc_Sha256Update(&sha256, (byte*)a.input+1, (word32)a.inLen-1),
|
||||
0);
|
||||
ExpectIntEQ(wc_Sha256Final(&sha256, hash_unaligned + 1), 0);
|
||||
|
||||
/* Try passing in bad values */
|
||||
b.input = NULL;
|
||||
b.inLen = 0;
|
||||
ExpectIntEQ(wc_Sha256Update(&sha256, (byte*)b.input, (word32)b.inLen), 0);
|
||||
c.input = NULL;
|
||||
c.inLen = WC_SHA256_DIGEST_SIZE;
|
||||
ExpectIntEQ(wc_Sha256Update(&sha256, (byte*)c.input, (word32)c.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256Update(NULL, (byte*)a.input, (word32)a.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha256Free(&sha256);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha256Update */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha256Final()
|
||||
*/
|
||||
int test_wc_Sha256Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256 sha256;
|
||||
byte* hash_test[3];
|
||||
byte hash1[WC_SHA256_DIGEST_SIZE];
|
||||
byte hash2[2*WC_SHA256_DIGEST_SIZE];
|
||||
byte hash3[5*WC_SHA256_DIGEST_SIZE];
|
||||
int times, i;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha256(&sha256), 0);
|
||||
|
||||
hash_test[0] = hash1;
|
||||
hash_test[1] = hash2;
|
||||
hash_test[2] = hash3;
|
||||
times = sizeof(hash_test) / sizeof(byte*);
|
||||
for (i = 0; i < times; i++) {
|
||||
ExpectIntEQ(wc_Sha256Final(&sha256, hash_test[i]), 0);
|
||||
}
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha256Final(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256Final(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256Final(&sha256, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha256Free(&sha256);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha256Final */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha256FinalRaw()
|
||||
*/
|
||||
int test_wc_Sha256FinalRaw(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if !defined(NO_SHA256) && !defined(HAVE_SELFTEST) && \
|
||||
!defined(WOLFSSL_DEVCRYPTO) && (!defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 3))) && \
|
||||
!defined(WOLFSSL_NO_HASH_RAW)
|
||||
wc_Sha256 sha256;
|
||||
byte* hash_test[3];
|
||||
byte hash1[WC_SHA256_DIGEST_SIZE];
|
||||
byte hash2[2*WC_SHA256_DIGEST_SIZE];
|
||||
byte hash3[5*WC_SHA256_DIGEST_SIZE];
|
||||
int times, i;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha256(&sha256), 0);
|
||||
|
||||
hash_test[0] = hash1;
|
||||
hash_test[1] = hash2;
|
||||
hash_test[2] = hash3;
|
||||
times = sizeof(hash_test) / sizeof(byte*);
|
||||
for (i = 0; i < times; i++) {
|
||||
ExpectIntEQ(wc_Sha256FinalRaw(&sha256, hash_test[i]), 0);
|
||||
}
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha256FinalRaw(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256FinalRaw(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256FinalRaw(&sha256, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha256Free(&sha256);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
|
||||
} /* END test_wc_Sha256FinalRaw */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha256GetFlags()
|
||||
*/
|
||||
int test_wc_Sha256GetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if !defined(NO_SHA256) && defined(WOLFSSL_HASH_FLAGS)
|
||||
wc_Sha256 sha256;
|
||||
word32 flags = 0;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha256(&sha256), 0);
|
||||
|
||||
ExpectIntEQ(wc_Sha256GetFlags(&sha256, &flags), 0);
|
||||
ExpectTrue((flags & WC_HASH_FLAG_ISCOPY) == 0);
|
||||
wc_Sha256Free(&sha256);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
|
||||
} /* END test_wc_Sha256GetFlags */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha256Free()
|
||||
*/
|
||||
int test_wc_Sha256Free(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256Free(NULL);
|
||||
/* Set result to SUCCESS. */
|
||||
ExpectTrue(1);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha256Free */
|
||||
/*
|
||||
* Unit test function for wc_Sha256GetHash()
|
||||
*/
|
||||
int test_wc_Sha256GetHash(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256 sha256;
|
||||
byte hash1[WC_SHA256_DIGEST_SIZE];
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha256(&sha256), 0);
|
||||
|
||||
ExpectIntEQ(wc_Sha256GetHash(&sha256, hash1), 0);
|
||||
|
||||
/* test bad arguments*/
|
||||
ExpectIntEQ(wc_Sha256GetHash(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256GetHash(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256GetHash(&sha256, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha256Free(&sha256);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha256GetHash */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha256Copy()
|
||||
*/
|
||||
int test_wc_Sha256Copy(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256 sha256;
|
||||
wc_Sha256 temp;
|
||||
|
||||
XMEMSET(&sha256, 0, sizeof(sha256));
|
||||
XMEMSET(&temp, 0, sizeof(temp));
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha256(&sha256), 0);
|
||||
ExpectIntEQ(wc_InitSha256(&temp), 0);
|
||||
|
||||
ExpectIntEQ(wc_Sha256Copy(&sha256, &temp), 0);
|
||||
|
||||
/* test bad arguments*/
|
||||
ExpectIntEQ(wc_Sha256Copy(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256Copy(NULL, &temp), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha256Copy(&sha256, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha256Free(&sha256);
|
||||
wc_Sha256Free(&temp);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha256Copy */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* SHA-224
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Testing wc_InitSha224();
|
||||
*/
|
||||
int test_wc_InitSha224(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224 sha224;
|
||||
|
||||
/* Test good arg. */
|
||||
ExpectIntEQ(wc_InitSha224(&sha224), 0);
|
||||
/* Test bad arg. */
|
||||
ExpectIntEQ(wc_InitSha224(NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha224Free(&sha224);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_InitSha224 */
|
||||
|
||||
/*
|
||||
* Unit test on wc_Sha224Update
|
||||
*/
|
||||
int test_wc_Sha224Update(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224 sha224;
|
||||
byte hash[WC_SHA224_DIGEST_SIZE];
|
||||
testVector a, b, c;
|
||||
|
||||
ExpectIntEQ(wc_InitSha224(&sha224), 0);
|
||||
|
||||
/* Input. */
|
||||
a.input = "a";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
ExpectIntEQ(wc_Sha224Update(&sha224, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_Sha224Update(&sha224, (byte*)a.input, 0), 0);
|
||||
ExpectIntEQ(wc_Sha224Update(&sha224, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_Sha224Final(&sha224, hash), 0);
|
||||
|
||||
/* Update input. */
|
||||
a.input = "abc";
|
||||
a.output = "\x23\x09\x7d\x22\x34\x05\xd8\x22\x86\x42\xa4\x77\xbd\xa2"
|
||||
"\x55\xb3\x2a\xad\xbc\xe4\xbd\xa0\xb3\xf7\xe3\x6c\x9d\xa7";
|
||||
a.inLen = XSTRLEN(a.input);
|
||||
a.outLen = XSTRLEN(a.output);
|
||||
ExpectIntEQ(wc_Sha224Update(&sha224, (byte*)a.input, (word32)a.inLen), 0);
|
||||
ExpectIntEQ(wc_Sha224Final(&sha224, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, a.output, WC_SHA224_DIGEST_SIZE), 0);
|
||||
|
||||
/* Pass in bad values. */
|
||||
b.input = NULL;
|
||||
b.inLen = 0;
|
||||
ExpectIntEQ(wc_Sha224Update(&sha224, (byte*)b.input, (word32)b.inLen), 0);
|
||||
c.input = NULL;
|
||||
c.inLen = WC_SHA224_DIGEST_SIZE;
|
||||
ExpectIntEQ(wc_Sha224Update(&sha224, (byte*)c.input, (word32)c.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha224Update(NULL, (byte*)a.input, (word32)a.inLen),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha224Free(&sha224);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha224Update */
|
||||
|
||||
/*
|
||||
* Unit test for wc_Sha224Final();
|
||||
*/
|
||||
int test_wc_Sha224Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224 sha224;
|
||||
byte* hash_test[3];
|
||||
byte hash1[WC_SHA224_DIGEST_SIZE];
|
||||
byte hash2[2*WC_SHA224_DIGEST_SIZE];
|
||||
byte hash3[5*WC_SHA224_DIGEST_SIZE];
|
||||
int times, i;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha224(&sha224), 0);
|
||||
|
||||
hash_test[0] = hash1;
|
||||
hash_test[1] = hash2;
|
||||
hash_test[2] = hash3;
|
||||
times = sizeof(hash_test) / sizeof(byte*);
|
||||
/* Good test args. */
|
||||
/* Testing oversized buffers. */
|
||||
for (i = 0; i < times; i++) {
|
||||
ExpectIntEQ(wc_Sha224Final(&sha224, hash_test[i]), 0);
|
||||
}
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha224Final(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha224Final(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha224Final(&sha224, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha224Free(&sha224);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha224Final */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha224SetFlags()
|
||||
*/
|
||||
int test_wc_Sha224SetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA224) && defined(WOLFSSL_HASH_FLAGS)
|
||||
wc_Sha224 sha224;
|
||||
word32 flags = WC_HASH_FLAG_WILLCOPY;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha224(&sha224), 0);
|
||||
|
||||
ExpectIntEQ(wc_Sha224SetFlags(&sha224, flags), 0);
|
||||
flags = 0;
|
||||
ExpectIntEQ(wc_Sha224GetFlags(&sha224, &flags), 0);
|
||||
ExpectTrue(flags == WC_HASH_FLAG_WILLCOPY);
|
||||
|
||||
wc_Sha224Free(&sha224);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha224SetFlags */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha224GetFlags()
|
||||
*/
|
||||
int test_wc_Sha224GetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA224) && defined(WOLFSSL_HASH_FLAGS)
|
||||
wc_Sha224 sha224;
|
||||
word32 flags = 0;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha224(&sha224), 0);
|
||||
|
||||
ExpectIntEQ(wc_Sha224GetFlags(&sha224, &flags), 0);
|
||||
ExpectTrue((flags & WC_HASH_FLAG_ISCOPY) == 0);
|
||||
|
||||
wc_Sha224Free(&sha224);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha224GetFlags */
|
||||
/*
|
||||
* Unit test function for wc_Sha224Free()
|
||||
*/
|
||||
int test_wc_Sha224Free(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224Free(NULL);
|
||||
/* Set result to SUCCESS. */
|
||||
ExpectTrue(1);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
|
||||
} /* END test_wc_Sha224Free */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha224GetHash()
|
||||
*/
|
||||
int test_wc_Sha224GetHash(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224 sha224;
|
||||
byte hash1[WC_SHA224_DIGEST_SIZE];
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha224(&sha224), 0);
|
||||
|
||||
ExpectIntEQ(wc_Sha224GetHash(&sha224, hash1), 0);
|
||||
/* test bad arguments*/
|
||||
ExpectIntEQ(wc_Sha224GetHash(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha224GetHash(NULL, hash1), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha224GetHash(&sha224, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha224Free(&sha224);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha224GetHash */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha224Copy()
|
||||
*/
|
||||
int test_wc_Sha224Copy(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224 sha224;
|
||||
wc_Sha224 temp;
|
||||
|
||||
XMEMSET(&sha224, 0, sizeof(wc_Sha224));
|
||||
XMEMSET(&temp, 0, sizeof(wc_Sha224));
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha224(&sha224), 0);
|
||||
ExpectIntEQ(wc_InitSha224(&temp), 0);
|
||||
|
||||
ExpectIntEQ(wc_Sha224Copy(&sha224, &temp), 0);
|
||||
/* test bad arguments*/
|
||||
ExpectIntEQ(wc_Sha224Copy(NULL, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha224Copy(NULL, &temp), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha224Copy(&sha224, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha224Free(&sha224);
|
||||
wc_Sha224Free(&temp);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha224Copy */
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/* test_sha256.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_SHA256_H
|
||||
#define WOLFCRYPT_TEST_SHA256_H
|
||||
|
||||
int test_wc_InitSha256(void);
|
||||
int test_wc_Sha256Update(void);
|
||||
int test_wc_Sha256Final(void);
|
||||
int test_wc_Sha256FinalRaw(void);
|
||||
int test_wc_Sha256GetFlags(void);
|
||||
int test_wc_Sha256Free(void);
|
||||
int test_wc_Sha256GetHash(void);
|
||||
int test_wc_Sha256Copy(void);
|
||||
|
||||
int test_wc_InitSha224(void);
|
||||
int test_wc_Sha224Update(void);
|
||||
int test_wc_Sha224Final(void);
|
||||
int test_wc_Sha224SetFlags(void);
|
||||
int test_wc_Sha224GetFlags(void);
|
||||
int test_wc_Sha224Free(void);
|
||||
int test_wc_Sha224GetHash(void);
|
||||
int test_wc_Sha224Copy(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_SHA256_H */
|
|
@ -1,730 +0,0 @@
|
|||
/* test_sha3.c
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(WOLFSSL_NO_OPTIONS_H)
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef NO_INLINE
|
||||
#include <wolfssl/wolfcrypt/misc.h>
|
||||
#else
|
||||
#define WOLFSSL_MISC_INCLUDED
|
||||
#include <wolfcrypt/src/misc.c>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/sha3.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
#include <tests/unit.h>
|
||||
#include <tests/api/api.h>
|
||||
#include <tests/api/test_sha3.h>
|
||||
|
||||
/*******************************************************************************
|
||||
* SHA-3
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Testing wc_InitSha3_224, wc_InitSha3_256, wc_InitSha3_384, and
|
||||
* wc_InitSha3_512
|
||||
*/
|
||||
int test_wc_InitSha3(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3)
|
||||
wc_Sha3 sha3;
|
||||
|
||||
(void)sha3;
|
||||
|
||||
#if !defined(WOLFSSL_NOSHA3_224)
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_InitSha3_224(NULL, HEAP_HINT, testDevId),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_224_Free(&sha3);
|
||||
#endif /* NOSHA3_224 */
|
||||
#if !defined(WOLFSSL_NOSHA3_256)
|
||||
ExpectIntEQ(wc_InitSha3_256(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_InitSha3_256(NULL, HEAP_HINT, testDevId),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_256_Free(&sha3);
|
||||
#endif /* NOSHA3_256 */
|
||||
#if !defined(WOLFSSL_NOSHA3_384)
|
||||
ExpectIntEQ(wc_InitSha3_384(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_InitSha3_384(NULL, HEAP_HINT, testDevId),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_384_Free(&sha3);
|
||||
#endif /* NOSHA3_384 */
|
||||
#if !defined(WOLFSSL_NOSHA3_512)
|
||||
ExpectIntEQ(wc_InitSha3_512(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_InitSha3_512(NULL, HEAP_HINT, testDevId),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_512_Free(&sha3);
|
||||
#endif /* NOSHA3_512 */
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_InitSha3 */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_Update()
|
||||
*/
|
||||
int test_wc_Sha3_Update(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_XILINX_CRYPT) && \
|
||||
!defined(WOLFSSL_AFALG_XILINX)
|
||||
wc_Sha3 sha3;
|
||||
byte msg[] = "Everybody's working for the weekend.";
|
||||
byte msg2[] = "Everybody gets Friday off.";
|
||||
byte msgCmp[] = "\x45\x76\x65\x72\x79\x62\x6f\x64\x79\x27\x73\x20"
|
||||
"\x77\x6f\x72\x6b\x69\x6e\x67\x20\x66\x6f\x72\x20\x74"
|
||||
"\x68\x65\x20\x77\x65\x65\x6b\x65\x6e\x64\x2e\x45\x76"
|
||||
"\x65\x72\x79\x62\x6f\x64\x79\x20\x67\x65\x74\x73\x20"
|
||||
"\x46\x72\x69\x64\x61\x79\x20\x6f\x66\x66\x2e";
|
||||
word32 msglen = sizeof(msg) - 1;
|
||||
word32 msg2len = sizeof(msg2);
|
||||
word32 msgCmplen = sizeof(msgCmp);
|
||||
|
||||
#if !defined(WOLFSSL_NOSHA3_224)
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, msg, msglen), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg, sha3.t, msglen), 0);
|
||||
ExpectTrue(sha3.i == msglen);
|
||||
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(sha3.t, msgCmp, msgCmplen), 0);
|
||||
|
||||
/* Pass bad args. */
|
||||
ExpectIntEQ(wc_Sha3_224_Update(NULL, msg2, msg2len),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, NULL, 5),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_224_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg2, sha3.t, msg2len), 0);
|
||||
wc_Sha3_224_Free(&sha3);
|
||||
#endif /* SHA3_224 */
|
||||
|
||||
#if !defined(WOLFSSL_NOSHA3_256)
|
||||
ExpectIntEQ(wc_InitSha3_256(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, msg, msglen), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg, sha3.t, msglen), 0);
|
||||
ExpectTrue(sha3.i == msglen);
|
||||
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(sha3.t, msgCmp, msgCmplen), 0);
|
||||
|
||||
/* Pass bad args. */
|
||||
ExpectIntEQ(wc_Sha3_256_Update(NULL, msg2, msg2len),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, NULL, 5),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_256_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_256(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg2, sha3.t, msg2len), 0);
|
||||
wc_Sha3_256_Free(&sha3);
|
||||
#endif /* SHA3_256 */
|
||||
|
||||
#if !defined(WOLFSSL_NOSHA3_384)
|
||||
ExpectIntEQ(wc_InitSha3_384(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, msg, msglen), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg, sha3.t, msglen), 0);
|
||||
ExpectTrue(sha3.i == msglen);
|
||||
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(sha3.t, msgCmp, msgCmplen), 0);
|
||||
|
||||
/* Pass bad args. */
|
||||
ExpectIntEQ(wc_Sha3_384_Update(NULL, msg2, msg2len),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, NULL, 5),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_384_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_384(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg2, sha3.t, msg2len), 0);
|
||||
wc_Sha3_384_Free(&sha3);
|
||||
#endif /* SHA3_384 */
|
||||
|
||||
#if !defined(WOLFSSL_NOSHA3_512)
|
||||
ExpectIntEQ(wc_InitSha3_512(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, msg, msglen), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg, sha3.t, msglen), 0);
|
||||
ExpectTrue(sha3.i == msglen);
|
||||
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(sha3.t, msgCmp, msgCmplen), 0);
|
||||
|
||||
/* Pass bad args. */
|
||||
ExpectIntEQ(wc_Sha3_512_Update(NULL, msg2, msg2len),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, NULL, 5),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_512_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_512(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg2, sha3.t, msg2len), 0);
|
||||
wc_Sha3_512_Free(&sha3);
|
||||
#endif /* SHA3_512 */
|
||||
#endif /* WOLFSSL_SHA3 */
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_Update */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_224_Final()
|
||||
*/
|
||||
int test_wc_Sha3_224_Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_224)
|
||||
wc_Sha3 sha3;
|
||||
const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom"
|
||||
"nopnopq";
|
||||
const char* expOut = "\x8a\x24\x10\x8b\x15\x4a\xda\x21\xc9\xfd\x55"
|
||||
"\x74\x49\x44\x79\xba\x5c\x7e\x7a\xb7\x6e\xf2"
|
||||
"\x64\xea\xd0\xfc\xce\x33";
|
||||
byte hash[WC_SHA3_224_DIGEST_SIZE];
|
||||
byte hashRet[WC_SHA3_224_DIGEST_SIZE];
|
||||
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(expOut, hash, WC_SHA3_224_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_224_Final(NULL, hash), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_224_Final(&sha3, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_224_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashRet, 0, sizeof(hashRet));
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_GetHash(&sha3, hashRet), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashRet, WC_SHA3_224_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_224_GetHash(NULL, hashRet),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_224_GetHash(&sha3, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_224_Free(&sha3);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_224_Final */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_256_Final()
|
||||
*/
|
||||
int test_wc_Sha3_256_Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256)
|
||||
wc_Sha3 sha3;
|
||||
const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom"
|
||||
"nopnopq";
|
||||
const char* expOut = "\x41\xc0\xdb\xa2\xa9\xd6\x24\x08\x49\x10\x03\x76\xa8"
|
||||
"\x23\x5e\x2c\x82\xe1\xb9\x99\x8a\x99\x9e\x21\xdb\x32"
|
||||
"\xdd\x97\x49\x6d\x33\x76";
|
||||
byte hash[WC_SHA3_256_DIGEST_SIZE];
|
||||
byte hashRet[WC_SHA3_256_DIGEST_SIZE];
|
||||
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_256(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(expOut, hash, WC_SHA3_256_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_256_Final(NULL, hash), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_256_Final(&sha3, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_256_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_256(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashRet, 0, sizeof(hashRet));
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_GetHash(&sha3, hashRet), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashRet, WC_SHA3_256_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_256_GetHash(NULL, hashRet),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_256_GetHash(&sha3, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_256_Free(&sha3);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_256_Final */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_384_Final()
|
||||
*/
|
||||
int test_wc_Sha3_384_Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_384)
|
||||
wc_Sha3 sha3;
|
||||
const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom"
|
||||
"nopnopq";
|
||||
const char* expOut = "\x99\x1c\x66\x57\x55\xeb\x3a\x4b\x6b\xbd\xfb\x75\xc7"
|
||||
"\x8a\x49\x2e\x8c\x56\xa2\x2c\x5c\x4d\x7e\x42\x9b\xfd"
|
||||
"\xbc\x32\xb9\xd4\xad\x5a\xa0\x4a\x1f\x07\x6e\x62\xfe"
|
||||
"\xa1\x9e\xef\x51\xac\xd0\x65\x7c\x22";
|
||||
byte hash[WC_SHA3_384_DIGEST_SIZE];
|
||||
byte hashRet[WC_SHA3_384_DIGEST_SIZE];
|
||||
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_384(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(expOut, hash, WC_SHA3_384_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_384_Final(NULL, hash), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_384_Final(&sha3, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_384_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_384(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashRet, 0, sizeof(hashRet));
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_GetHash(&sha3, hashRet), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashRet, WC_SHA3_384_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_384_GetHash(NULL, hashRet),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_384_GetHash(&sha3, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_384_Free(&sha3);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_384_Final */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_512_Final()
|
||||
*/
|
||||
int test_wc_Sha3_512_Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_512) && \
|
||||
!defined(WOLFSSL_NOSHA3_384)
|
||||
wc_Sha3 sha3;
|
||||
const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom"
|
||||
"nopnopq";
|
||||
const char* expOut = "\x04\xa3\x71\xe8\x4e\xcf\xb5\xb8\xb7\x7c\xb4\x86\x10"
|
||||
"\xfc\xa8\x18\x2d\xd4\x57\xce\x6f\x32\x6a\x0f\xd3\xd7"
|
||||
"\xec\x2f\x1e\x91\x63\x6d\xee\x69\x1f\xbe\x0c\x98\x53"
|
||||
"\x02\xba\x1b\x0d\x8d\xc7\x8c\x08\x63\x46\xb5\x33\xb4"
|
||||
"\x9c\x03\x0d\x99\xa2\x7d\xaf\x11\x39\xd6\xe7\x5e";
|
||||
byte hash[WC_SHA3_512_DIGEST_SIZE];
|
||||
byte hashRet[WC_SHA3_512_DIGEST_SIZE];
|
||||
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_512(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(expOut, hash, WC_SHA3_512_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_512_Final(NULL, hash), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_512_Final(&sha3, NULL), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Sha3_512_Free(&sha3);
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_512(&sha3, HEAP_HINT, testDevId), 0);
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashRet, 0, sizeof(hashRet));
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, (byte*)msg, (word32)XSTRLEN(msg)), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_GetHash(&sha3, hashRet), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashRet, WC_SHA3_512_DIGEST_SIZE), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_512_GetHash(NULL, hashRet),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_512_GetHash(&sha3, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_512_Free(&sha3);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_512_Final */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_224_Copy()
|
||||
*/
|
||||
int test_wc_Sha3_224_Copy(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_224)
|
||||
wc_Sha3 sha3, sha3Cpy;
|
||||
const char* msg = TEST_STRING;
|
||||
word32 msglen = (word32)TEST_STRING_SZ;
|
||||
byte hash[WC_SHA3_224_DIGEST_SIZE];
|
||||
byte hashCpy[WC_SHA3_224_DIGEST_SIZE];
|
||||
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashCpy, 0, sizeof(hashCpy));
|
||||
XMEMSET(&sha3, 0, sizeof(wc_Sha3));
|
||||
XMEMSET(&sha3Cpy, 0, sizeof(wc_Sha3));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3Cpy, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Update(&sha3, (byte*)msg, msglen), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Copy(&sha3Cpy, &sha3), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(wc_Sha3_224_Final(&sha3Cpy, hashCpy), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashCpy, sizeof(hash)), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_224_Copy(NULL, &sha3), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_224_Copy(&sha3Cpy, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_224_Free(&sha3);
|
||||
wc_Sha3_224_Free(&sha3Cpy);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_224_Copy */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_256_Copy()
|
||||
*/
|
||||
int test_wc_Sha3_256_Copy(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_256)
|
||||
wc_Sha3 sha3, sha3Cpy;
|
||||
const char* msg = TEST_STRING;
|
||||
word32 msglen = (word32)TEST_STRING_SZ;
|
||||
byte hash[WC_SHA3_256_DIGEST_SIZE];
|
||||
byte hashCpy[WC_SHA3_256_DIGEST_SIZE];
|
||||
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashCpy, 0, sizeof(hashCpy));
|
||||
XMEMSET(&sha3, 0, sizeof(wc_Sha3));
|
||||
XMEMSET(&sha3Cpy, 0, sizeof(wc_Sha3));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_256(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_InitSha3_256(&sha3Cpy, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Update(&sha3, (byte*)msg, msglen), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Copy(&sha3Cpy, &sha3), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(wc_Sha3_256_Final(&sha3Cpy, hashCpy), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashCpy, sizeof(hash)), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_256_Copy(NULL, &sha3), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_256_Copy(&sha3Cpy, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_256_Free(&sha3);
|
||||
wc_Sha3_256_Free(&sha3Cpy);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_256_Copy */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_384_Copy()
|
||||
*/
|
||||
int test_wc_Sha3_384_Copy(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_384)
|
||||
wc_Sha3 sha3, sha3Cpy;
|
||||
const char* msg = TEST_STRING;
|
||||
word32 msglen = (word32)TEST_STRING_SZ;
|
||||
byte hash[WC_SHA3_384_DIGEST_SIZE];
|
||||
byte hashCpy[WC_SHA3_384_DIGEST_SIZE];
|
||||
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashCpy, 0, sizeof(hashCpy));
|
||||
XMEMSET(&sha3, 0, sizeof(wc_Sha3));
|
||||
XMEMSET(&sha3Cpy, 0, sizeof(wc_Sha3));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_384(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_InitSha3_384(&sha3Cpy, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Update(&sha3, (byte*)msg, msglen), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Copy(&sha3Cpy, &sha3), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(wc_Sha3_384_Final(&sha3Cpy, hashCpy), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashCpy, sizeof(hash)), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_384_Copy(NULL, &sha3), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_384_Copy(&sha3Cpy, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_384_Free(&sha3);
|
||||
wc_Sha3_384_Free(&sha3Cpy);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_384_Copy */
|
||||
|
||||
/*
|
||||
* Testing wc_Sha3_512_Copy()
|
||||
*/
|
||||
int test_wc_Sha3_512_Copy(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && !defined(WOLFSSL_NOSHA3_512)
|
||||
wc_Sha3 sha3, sha3Cpy;
|
||||
const char* msg = TEST_STRING;
|
||||
word32 msglen = (word32)TEST_STRING_SZ;
|
||||
byte hash[WC_SHA3_512_DIGEST_SIZE];
|
||||
byte hashCpy[WC_SHA3_512_DIGEST_SIZE];
|
||||
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashCpy, 0, sizeof(hashCpy));
|
||||
XMEMSET(&sha3, 0, sizeof(wc_Sha3));
|
||||
XMEMSET(&sha3Cpy, 0, sizeof(wc_Sha3));
|
||||
|
||||
ExpectIntEQ(wc_InitSha3_512(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_InitSha3_512(&sha3Cpy, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Update(&sha3, (byte*)msg, msglen), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Copy(&sha3Cpy, &sha3), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Final(&sha3, hash), 0);
|
||||
ExpectIntEQ(wc_Sha3_512_Final(&sha3Cpy, hashCpy), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashCpy, sizeof(hash)), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Sha3_512_Copy(NULL, &sha3), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Sha3_512_Copy(&sha3Cpy, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Sha3_512_Free(&sha3);
|
||||
wc_Sha3_512_Free(&sha3Cpy);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_512_Copy */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Sha3_GetFlags()
|
||||
*/
|
||||
int test_wc_Sha3_GetFlags(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(WOLFSSL_SHA3) && defined(WOLFSSL_HASH_FLAGS)
|
||||
wc_Sha3 sha3;
|
||||
word32 flags = 0;
|
||||
|
||||
/* Initialize */
|
||||
ExpectIntEQ(wc_InitSha3_224(&sha3, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Sha3_GetFlags(&sha3, &flags), 0);
|
||||
ExpectTrue((flags & WC_HASH_FLAG_ISCOPY) == 0);
|
||||
wc_Sha3_224_Free(&sha3);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Sha3_GetFlags */
|
||||
|
||||
/*******************************************************************************
|
||||
* SHAKE-256
|
||||
******************************************************************************/
|
||||
|
||||
int test_wc_InitShake256(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHAKE256
|
||||
wc_Shake shake;
|
||||
|
||||
ExpectIntEQ(wc_InitShake256(&shake, HEAP_HINT, testDevId), 0);
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_InitShake256(NULL, HEAP_HINT, testDevId),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Shake256_Free(&shake);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
|
||||
int test_wc_Shake256_Update(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHAKE256
|
||||
wc_Shake shake;
|
||||
byte msg[] = "Everybody's working for the weekend.";
|
||||
byte msg2[] = "Everybody gets Friday off.";
|
||||
byte msgCmp[] = "\x45\x76\x65\x72\x79\x62\x6f\x64\x79\x27\x73\x20"
|
||||
"\x77\x6f\x72\x6b\x69\x6e\x67\x20\x66\x6f\x72\x20\x74"
|
||||
"\x68\x65\x20\x77\x65\x65\x6b\x65\x6e\x64\x2e\x45\x76"
|
||||
"\x65\x72\x79\x62\x6f\x64\x79\x20\x67\x65\x74\x73\x20"
|
||||
"\x46\x72\x69\x64\x61\x79\x20\x6f\x66\x66\x2e";
|
||||
word32 msglen = sizeof(msg) - 1;
|
||||
word32 msg2len = sizeof(msg2);
|
||||
word32 msgCmplen = sizeof(msgCmp);
|
||||
|
||||
ExpectIntEQ(wc_InitShake256(&shake, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Shake256_Update(&shake, msg, msglen), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg, shake.t, msglen), 0);
|
||||
ExpectTrue(shake.i == msglen);
|
||||
|
||||
ExpectIntEQ(wc_Shake256_Update(&shake, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(shake.t, msgCmp, msgCmplen), 0);
|
||||
|
||||
/* Pass bad args. */
|
||||
ExpectIntEQ(wc_Shake256_Update(NULL, msg2, msg2len),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Shake256_Update(&shake, NULL, 5),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
wc_Shake256_Free(&shake);
|
||||
|
||||
ExpectIntEQ(wc_InitShake256(&shake, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Shake256_Update(&shake, NULL, 0), 0);
|
||||
ExpectIntEQ(wc_Shake256_Update(&shake, msg2, msg2len), 0);
|
||||
ExpectIntEQ(XMEMCMP(msg2, shake.t, msg2len), 0);
|
||||
wc_Shake256_Free(&shake);
|
||||
#endif /* WOLFSSL_SHAKE256 */
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_wc_Shake256_Final(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHAKE256
|
||||
wc_Shake shake;
|
||||
const char* msg = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnom"
|
||||
"nopnopq";
|
||||
const char* expOut = "\x4d\x8c\x2d\xd2\x43\x5a\x01\x28\xee\xfb\xb8\xc3\x6f"
|
||||
"\x6f\x87\x13\x3a\x79\x11\xe1\x8d\x97\x9e\xe1\xae\x6b"
|
||||
"\xe5\xd4\xfd\x2e\x33\x29\x40\xd8\x68\x8a\x4e\x6a\x59"
|
||||
"\xaa\x80\x60\xf1\xf9\xbc\x99\x6c\x05\xac\xa3\xc6\x96"
|
||||
"\xa8\xb6\x62\x79\xdc\x67\x2c\x74\x0b\xb2\x24\xec\x37"
|
||||
"\xa9\x2b\x65\xdb\x05\x39\xc0\x20\x34\x55\xf5\x1d\x97"
|
||||
"\xcc\xe4\xcf\xc4\x91\x27\xd7\x26\x0a\xfc\x67\x3a\xf2"
|
||||
"\x08\xba\xf1\x9b\xe2\x12\x33\xf3\xde\xbe\x78\xd0\x67"
|
||||
"\x60\xcf\xa5\x51\xee\x1e\x07\x91\x41\xd4";
|
||||
byte hash[114];
|
||||
|
||||
/* Init stack variables. */
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
|
||||
ExpectIntEQ(wc_InitShake256(&shake, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_Shake256_Update(&shake, (byte*)msg, (word32)XSTRLEN(msg)),
|
||||
0);
|
||||
ExpectIntEQ(wc_Shake256_Final(&shake, hash, (word32)sizeof(hash)), 0);
|
||||
ExpectIntEQ(XMEMCMP(expOut, hash, (word32)sizeof(hash)), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Shake256_Final(NULL, hash, (word32)sizeof(hash)),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Shake256_Final(&shake, NULL, (word32)sizeof(hash)),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Shake256_Free(&shake);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/*
|
||||
* Testing wc_Shake256_Copy()
|
||||
*/
|
||||
int test_wc_Shake256_Copy(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHAKE256
|
||||
wc_Shake shake, shakeCpy;
|
||||
const char* msg = TEST_STRING;
|
||||
word32 msglen = (word32)TEST_STRING_SZ;
|
||||
byte hash[144];
|
||||
byte hashCpy[144];
|
||||
word32 hashLen = sizeof(hash);
|
||||
word32 hashLenCpy = sizeof(hashCpy);
|
||||
|
||||
XMEMSET(hash, 0, sizeof(hash));
|
||||
XMEMSET(hashCpy, 0, sizeof(hashCpy));
|
||||
|
||||
ExpectIntEQ(wc_InitShake256(&shake, HEAP_HINT, testDevId), 0);
|
||||
ExpectIntEQ(wc_InitShake256(&shakeCpy, HEAP_HINT, testDevId), 0);
|
||||
|
||||
ExpectIntEQ(wc_Shake256_Update(&shake, (byte*)msg, msglen), 0);
|
||||
ExpectIntEQ(wc_Shake256_Copy(&shakeCpy, &shake), 0);
|
||||
ExpectIntEQ(wc_Shake256_Final(&shake, hash, hashLen), 0);
|
||||
ExpectIntEQ(wc_Shake256_Final(&shakeCpy, hashCpy, hashLenCpy), 0);
|
||||
ExpectIntEQ(XMEMCMP(hash, hashCpy, sizeof(hash)), 0);
|
||||
|
||||
/* Test bad args. */
|
||||
ExpectIntEQ(wc_Shake256_Copy(NULL, &shake), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
ExpectIntEQ(wc_Shake256_Copy(&shakeCpy, NULL),
|
||||
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
|
||||
|
||||
wc_Shake256_Free(&shake);
|
||||
wc_Shake256_Free(&shakeCpy);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Shake256_Copy */
|
||||
|
||||
/*
|
||||
* Unit test function for wc_Shake256Hash()
|
||||
*/
|
||||
int test_wc_Shake256Hash(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef WOLFSSL_SHAKE256
|
||||
const byte data[] = { /* Hello World */
|
||||
0x48,0x65,0x6c,0x6c,0x6f,0x20,0x57,0x6f,
|
||||
0x72,0x6c,0x64
|
||||
};
|
||||
word32 len = sizeof(data);
|
||||
byte hash[144];
|
||||
word32 hashLen = sizeof(hash);
|
||||
|
||||
ExpectIntEQ(wc_Shake256Hash(data, len, hash, hashLen), 0);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
} /* END test_wc_Shake256Hash */
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/* test_sha3.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_SHA3_H
|
||||
#define WOLFCRYPT_TEST_SHA3_H
|
||||
|
||||
int test_wc_InitSha3(void);
|
||||
int test_wc_Sha3_Update(void);
|
||||
int test_wc_Sha3_224_Final(void);
|
||||
int test_wc_Sha3_256_Final(void);
|
||||
int test_wc_Sha3_384_Final(void);
|
||||
int test_wc_Sha3_512_Final(void);
|
||||
int test_wc_Sha3_224_Copy(void);
|
||||
int test_wc_Sha3_256_Copy(void);
|
||||
int test_wc_Sha3_384_Copy(void);
|
||||
int test_wc_Sha3_512_Copy(void);
|
||||
int test_wc_Sha3_GetFlags(void);
|
||||
|
||||
int test_wc_InitShake256(void);
|
||||
int test_wc_Shake256_Update(void);
|
||||
int test_wc_Shake256_Final(void);
|
||||
int test_wc_Shake256_Copy(void);
|
||||
int test_wc_Shake256Hash(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_SHA3_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,61 +0,0 @@
|
|||
/* test_sha512.h
|
||||
*
|
||||
* Copyright (C) 2006-2025 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* wolfSSL is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef WOLFCRYPT_TEST_SHA512_H
|
||||
#define WOLFCRYPT_TEST_SHA512_H
|
||||
|
||||
int test_wc_InitSha512(void);
|
||||
int test_wc_Sha512Update(void);
|
||||
int test_wc_Sha512Final(void);
|
||||
int test_wc_Sha512FinalRaw(void);
|
||||
int test_wc_Sha512GetFlags(void);
|
||||
int test_wc_Sha512Free(void);
|
||||
int test_wc_Sha512GetHash(void);
|
||||
int test_wc_Sha512Copy(void);
|
||||
|
||||
int test_wc_InitSha512_224(void);
|
||||
int test_wc_Sha512_224Update(void);
|
||||
int test_wc_Sha512_224Final(void);
|
||||
int test_wc_Sha512_224FinalRaw(void);
|
||||
int test_wc_Sha512_224GetFlags(void);
|
||||
int test_wc_Sha512_224Free(void);
|
||||
int test_wc_Sha512_224GetHash(void);
|
||||
int test_wc_Sha512_224Copy(void);
|
||||
|
||||
int test_wc_InitSha512_256(void);
|
||||
int test_wc_Sha512_256Update(void);
|
||||
int test_wc_Sha512_256Final(void);
|
||||
int test_wc_Sha512_256FinalRaw(void);
|
||||
int test_wc_Sha512_256GetFlags(void);
|
||||
int test_wc_Sha512_256Free(void);
|
||||
int test_wc_Sha512_256GetHash(void);
|
||||
int test_wc_Sha512_256Copy(void);
|
||||
|
||||
int test_wc_InitSha384(void);
|
||||
int test_wc_Sha384Update(void);
|
||||
int test_wc_Sha384Final(void);
|
||||
int test_wc_Sha384FinalRaw(void);
|
||||
int test_wc_Sha384GetFlags(void);
|
||||
int test_wc_Sha384Free(void);
|
||||
int test_wc_Sha384GetHash(void);
|
||||
int test_wc_Sha384Copy(void);
|
||||
|
||||
#endif /* WOLFCRYPT_TEST_SHA512_H */
|
Loading…
Reference in New Issue