forked from wolfSSL/wolfssl
Merge pull request #1707 from kaleb-himes/ARM_GCC_EX_FIXES
Fixes for building without DRBG and ForceZero test
This commit is contained in:
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");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -576,7 +576,9 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
|
|||||||
void* heap, int devId)
|
void* heap, int devId)
|
||||||
{
|
{
|
||||||
int ret = RNG_FAILURE_E;
|
int ret = RNG_FAILURE_E;
|
||||||
|
#ifdef HAVE_HASHDRBG
|
||||||
word32 entropySz = ENTROPY_SZ;
|
word32 entropySz = ENTROPY_SZ;
|
||||||
|
#endif
|
||||||
|
|
||||||
(void)nonce;
|
(void)nonce;
|
||||||
(void)nonceSz;
|
(void)nonceSz;
|
||||||
|
@@ -123,10 +123,6 @@
|
|||||||
#include <wolfssl/wolfcrypt/cryptodev.h>
|
#include <wolfssl/wolfcrypt/cryptodev.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WOLFSSL_MISC_INCLUDED
|
|
||||||
#include <wolfcrypt/src/misc.c>
|
|
||||||
|
|
||||||
|
|
||||||
/* 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>
|
||||||
@@ -342,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);
|
||||||
@@ -961,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);
|
||||||
@@ -17515,6 +17505,7 @@ int ed25519_test(void)
|
|||||||
0 /*sizeof(msg1)*/,
|
0 /*sizeof(msg1)*/,
|
||||||
sizeof(msg4)
|
sizeof(msg4)
|
||||||
};
|
};
|
||||||
|
#ifndef NO_ASN
|
||||||
static byte privateEd25519[] = {
|
static byte privateEd25519[] = {
|
||||||
0x30,0x2e,0x02,0x01,0x00,0x30,0x05,0x06,
|
0x30,0x2e,0x02,0x01,0x00,0x30,0x05,0x06,
|
||||||
0x03,0x2b,0x65,0x70,0x04,0x22,0x04,0x20,
|
0x03,0x2b,0x65,0x70,0x04,0x22,0x04,0x20,
|
||||||
@@ -17544,9 +17535,10 @@ int ed25519_test(void)
|
|||||||
0xda,0xa6,0x23,0x25,0xaf,0x02,0x1a,0x68,
|
0xda,0xa6,0x23,0x25,0xaf,0x02,0x1a,0x68,
|
||||||
0xf7,0x07,0x51,0x1a
|
0xf7,0x07,0x51,0x1a
|
||||||
};
|
};
|
||||||
|
|
||||||
word32 idx;
|
word32 idx;
|
||||||
ed25519_key key3;
|
ed25519_key key3;
|
||||||
|
#endif /* NO_ASN */
|
||||||
#endif /* HAVE_ED25519_SIGN && HAVE_ED25519_KEY_EXPORT && HAVE_ED25519_KEY_IMPORT */
|
#endif /* HAVE_ED25519_SIGN && HAVE_ED25519_KEY_EXPORT && HAVE_ED25519_KEY_IMPORT */
|
||||||
|
|
||||||
/* create ed25519 keys */
|
/* create ed25519 keys */
|
||||||
@@ -17560,7 +17552,9 @@ int ed25519_test(void)
|
|||||||
|
|
||||||
wc_ed25519_init(&key);
|
wc_ed25519_init(&key);
|
||||||
wc_ed25519_init(&key2);
|
wc_ed25519_init(&key2);
|
||||||
|
#ifndef NO_ASN
|
||||||
wc_ed25519_init(&key3);
|
wc_ed25519_init(&key3);
|
||||||
|
#endif
|
||||||
wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key);
|
wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key);
|
||||||
wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key2);
|
wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key2);
|
||||||
|
|
||||||
@@ -17629,6 +17623,7 @@ int ed25519_test(void)
|
|||||||
#endif /* HAVE_ED25519_VERIFY */
|
#endif /* HAVE_ED25519_VERIFY */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_ASN
|
||||||
/* Try ASN.1 encoded private-only key and public key. */
|
/* Try ASN.1 encoded private-only key and public key. */
|
||||||
idx = 0;
|
idx = 0;
|
||||||
if (wc_Ed25519PrivateKeyDecode(privateEd25519, &idx, &key3,
|
if (wc_Ed25519PrivateKeyDecode(privateEd25519, &idx, &key3,
|
||||||
@@ -17672,6 +17667,7 @@ int ed25519_test(void)
|
|||||||
return -7234 - i;
|
return -7234 - i;
|
||||||
|
|
||||||
wc_ed25519_free(&key3);
|
wc_ed25519_free(&key3);
|
||||||
|
#endif /* NO_ASN */
|
||||||
#endif /* HAVE_ED25519_SIGN && HAVE_ED25519_KEY_EXPORT && HAVE_ED25519_KEY_IMPORT */
|
#endif /* HAVE_ED25519_SIGN && HAVE_ED25519_KEY_EXPORT && HAVE_ED25519_KEY_IMPORT */
|
||||||
|
|
||||||
/* clean up keys when done */
|
/* clean up keys when done */
|
||||||
@@ -19653,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