forked from wolfSSL/wolfssl
Move ForceZero test to api.c and turn on tests when inline disabled
This commit is contained in:
@@ -3318,7 +3318,6 @@ AC_ARG_ENABLE([examples],
|
|||||||
)
|
)
|
||||||
|
|
||||||
AS_IF([test "x$ENABLED_FILESYSTEM" = "xno"], [ENABLED_EXAMPLES="no"])
|
AS_IF([test "x$ENABLED_FILESYSTEM" = "xno"], [ENABLED_EXAMPLES="no"])
|
||||||
AS_IF([test "x$ENABLED_INLINE" = "xno"], [ENABLED_EXAMPLES="no"])
|
|
||||||
AS_IF([test "x$ENABLED_CRYPTONLY" = "xyes"], [ENABLED_EXAMPLES="no"])
|
AS_IF([test "x$ENABLED_CRYPTONLY" = "xyes"], [ENABLED_EXAMPLES="no"])
|
||||||
AM_CONDITIONAL([BUILD_EXAMPLE_SERVERS], [test "x$ENABLED_EXAMPLES" = "xyes" && test "x$ENABLED_LEANTLS" = "xno"])
|
AM_CONDITIONAL([BUILD_EXAMPLE_SERVERS], [test "x$ENABLED_EXAMPLES" = "xyes" && test "x$ENABLED_LEANTLS" = "xno"])
|
||||||
AM_CONDITIONAL([BUILD_EXAMPLE_CLIENTS], [test "x$ENABLED_EXAMPLES" = "xyes"])
|
AM_CONDITIONAL([BUILD_EXAMPLE_CLIENTS], [test "x$ENABLED_EXAMPLES" = "xyes"])
|
||||||
|
38
tests/api.c
38
tests/api.c
@@ -218,7 +218,6 @@
|
|||||||
#include <wolfssl/wolfcrypt/blake2.h>
|
#include <wolfssl/wolfcrypt/blake2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
#include <wolfssl/wolfcrypt/rsa.h>
|
#include <wolfssl/wolfcrypt/rsa.h>
|
||||||
#include <wolfssl/wolfcrypt/hash.h>
|
#include <wolfssl/wolfcrypt/hash.h>
|
||||||
@@ -20136,6 +20135,41 @@ static void test_wolfSSL_i2c_ASN1_INTEGER()
|
|||||||
printf(resultFmt, passed);
|
printf(resultFmt, passed);
|
||||||
#endif /* OPENSSL_EXTRA */
|
#endif /* OPENSSL_EXTRA */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_INLINE
|
||||||
|
#define WOLFSSL_MISC_INCLUDED
|
||||||
|
#include <wolfcrypt/src/misc.c>
|
||||||
|
#else
|
||||||
|
#include <wolfssl/wolfcrypt/misc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int test_ForceZero(void)
|
||||||
|
{
|
||||||
|
unsigned char data[32];
|
||||||
|
unsigned int i, j, len;
|
||||||
|
|
||||||
|
/* Test ForceZero */
|
||||||
|
for (i = 0; i < sizeof(data); i++) {
|
||||||
|
for (len = 1; len < sizeof(data) - i; len++) {
|
||||||
|
for (j = 0; j < sizeof(data); j++)
|
||||||
|
data[j] = j + 1;
|
||||||
|
|
||||||
|
ForceZero(data + i, len);
|
||||||
|
|
||||||
|
for (j = 0; j < sizeof(data); j++) {
|
||||||
|
if (j < i || j >= i + len) {
|
||||||
|
if (data[j] == 0x00)
|
||||||
|
return -10200;
|
||||||
|
}
|
||||||
|
else if (data[j] != 0x00)
|
||||||
|
return -10201;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*
|
/*----------------------------------------------------------------------------*
|
||||||
| Main
|
| Main
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
@@ -20477,6 +20511,8 @@ void ApiTest(void)
|
|||||||
test_wc_PKCS7_EncodeDecodeEnvelopedData();
|
test_wc_PKCS7_EncodeDecodeEnvelopedData();
|
||||||
test_wc_PKCS7_EncodeEncryptedData();
|
test_wc_PKCS7_EncodeEncryptedData();
|
||||||
|
|
||||||
|
AssertIntEQ(test_ForceZero(), 0);
|
||||||
|
|
||||||
printf(" End API Tests\n");
|
printf(" End API Tests\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -123,13 +123,6 @@
|
|||||||
#include <wolfssl/wolfcrypt/cryptodev.h>
|
#include <wolfssl/wolfcrypt/cryptodev.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_INLINE
|
|
||||||
#define WOLFSSL_MISC_INCLUDED
|
|
||||||
#include <wolfcrypt/src/misc.c>
|
|
||||||
#else
|
|
||||||
#include <wolfssl/wolfcrypt/misc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* only for stack size check */
|
/* only for stack size check */
|
||||||
#ifdef HAVE_STACK_SIZE
|
#ifdef HAVE_STACK_SIZE
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
@@ -345,7 +338,6 @@ int memcb_test(void);
|
|||||||
#ifdef WOLFSSL_IMX6_CAAM_BLOB
|
#ifdef WOLFSSL_IMX6_CAAM_BLOB
|
||||||
int blob_test(void);
|
int blob_test(void);
|
||||||
#endif
|
#endif
|
||||||
int misc_test(void);
|
|
||||||
|
|
||||||
#ifdef WOLF_CRYPTO_DEV
|
#ifdef WOLF_CRYPTO_DEV
|
||||||
int cryptodev_test(void);
|
int cryptodev_test(void);
|
||||||
@@ -964,11 +956,6 @@ initDefaultName();
|
|||||||
printf( "blob test passed!\n");
|
printf( "blob test passed!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (ret = misc_test()) != 0)
|
|
||||||
return err_sys("misc test failed!\n", ret);
|
|
||||||
else
|
|
||||||
printf( "misc test passed!\n");
|
|
||||||
|
|
||||||
#ifdef WOLF_CRYPTO_DEV
|
#ifdef WOLF_CRYPTO_DEV
|
||||||
if ( (ret = cryptodev_test()) != 0)
|
if ( (ret = cryptodev_test()) != 0)
|
||||||
return err_sys("crypto dev test failed!\n", ret);
|
return err_sys("crypto dev test failed!\n", ret);
|
||||||
@@ -19662,33 +19649,6 @@ int blob_test(void)
|
|||||||
}
|
}
|
||||||
#endif /* WOLFSSL_IMX6_CAAM_BLOB */
|
#endif /* WOLFSSL_IMX6_CAAM_BLOB */
|
||||||
|
|
||||||
int misc_test(void)
|
|
||||||
{
|
|
||||||
unsigned char data[32];
|
|
||||||
unsigned int i, j, len;
|
|
||||||
|
|
||||||
/* Test ForceZero */
|
|
||||||
for (i = 0; i < sizeof(data); i++) {
|
|
||||||
for (len = 1; len < sizeof(data) - i; len++) {
|
|
||||||
for (j = 0; j < sizeof(data); j++)
|
|
||||||
data[j] = j + 1;
|
|
||||||
|
|
||||||
ForceZero(data + i, len);
|
|
||||||
|
|
||||||
for (j = 0; j < sizeof(data); j++) {
|
|
||||||
if (j < i || j >= i + len) {
|
|
||||||
if (data[j] == 0x00)
|
|
||||||
return -10200;
|
|
||||||
}
|
|
||||||
else if (data[j] != 0x00)
|
|
||||||
return -10201;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WOLF_CRYPTO_DEV
|
#ifdef WOLF_CRYPTO_DEV
|
||||||
|
|
||||||
/* Example custom context for crypto callback */
|
/* Example custom context for crypto callback */
|
||||||
|
Reference in New Issue
Block a user