forked from wolfSSL/wolfssl
Merge pull request #2111 from SparkiDev/ed25519_fixes_1
Various improvements for testing
This commit is contained in:
@@ -1466,7 +1466,7 @@ fi
|
||||
if test "$ENABLED_ECC" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC -DTFM_ECC256"
|
||||
if test "$ENABLED_ECC_SHAMIR" = "yes"
|
||||
if test "$ENABLED_ECC_SHAMIR" = "yes" && test "$ENABLED_LOWRESOURCE" = "no"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DECC_SHAMIR"
|
||||
fi
|
||||
@@ -4202,6 +4202,10 @@ then
|
||||
then
|
||||
AC_MSG_ERROR([please use --enable-fastmath if enabling staticmemory.])
|
||||
fi
|
||||
if test "$ENABLED_LOWRESOURCE" = "yes" && test "$ENABLED_RSA" = "no"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_STATIC_MEMORY_SMALL"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
@@ -1304,7 +1304,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
char resumeMsg[32] = "resuming wolfssl!\n";
|
||||
#endif
|
||||
|
||||
char reply[80];
|
||||
char reply[128];
|
||||
int msgSz = (int)XSTRLEN(msg);
|
||||
int resumeSz = (int)XSTRLEN(resumeMsg);
|
||||
|
||||
@@ -3183,6 +3183,11 @@ exit:
|
||||
wolfAsync_DevClose(&devId);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) \
|
||||
&& defined(HAVE_STACK_SIZE)
|
||||
wc_ecc_fp_free(); /* free per thread cache */
|
||||
#endif
|
||||
|
||||
/* There are use cases when these assignments are not read. To avoid
|
||||
* potential confusion those warnings have been handled here.
|
||||
*/
|
||||
|
@@ -2279,8 +2279,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
|
||||
exit:
|
||||
|
||||
#if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \
|
||||
&& defined(HAVE_THREAD_LS)
|
||||
#if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) \
|
||||
&& (defined(NO_MAIN_DRIVER) || defined(HAVE_STACK_SIZE))
|
||||
wc_ecc_fp_free(); /* free per thread cache */
|
||||
#endif
|
||||
|
||||
|
@@ -38,7 +38,10 @@ my @fileList_ecc = (
|
||||
# Used with HAVE_ED25519 define.
|
||||
my @fileList_ed = (
|
||||
[ "./certs/ed25519/server-ed25519.der", "server_ed25519_cert" ],
|
||||
[ "./certs/ed25519/ca-ed25519.der", "ca_ed25519_cert" ]
|
||||
[ "./certs/ed25519/server-ed25519-key.der", "server_ed25519_key" ],
|
||||
[ "./certs/ed25519/ca-ed25519.der", "ca_ed25519_cert" ],
|
||||
[ "./certs/ed25519/client-ed25519.der", "client_ed25519_cert" ],
|
||||
[ "./certs/ed25519/client-ed25519-key.der", "client_ed25519_key" ]
|
||||
);
|
||||
|
||||
# 1024-bit certs/keys to be converted
|
||||
@@ -223,14 +226,17 @@ sub file_to_hex {
|
||||
for (my $i = 0, my $j = 1; $i < $fileLen; $i++, $j++)
|
||||
{
|
||||
if ($j == 1) {
|
||||
print OUT_FILE "\t";
|
||||
print OUT_FILE " ";
|
||||
}
|
||||
if ($j != 1) {
|
||||
print OUT_FILE " ";
|
||||
}
|
||||
read($fp, $byte, 1) or die "Error reading $fileName";
|
||||
my $output = sprintf("0x%02X", ord($byte));
|
||||
print OUT_FILE $output;
|
||||
|
||||
if ($i != ($fileLen - 1)) {
|
||||
print OUT_FILE ", ";
|
||||
print OUT_FILE ",";
|
||||
}
|
||||
|
||||
if ($j == 10) {
|
||||
|
@@ -1284,11 +1284,16 @@ static void test_wolfSSL_SetTmpDH_file(void)
|
||||
WOLFSSL_FILETYPE_PEM));
|
||||
AssertTrue(wolfSSL_CTX_use_PrivateKey_file(ctx, svrKeyFile,
|
||||
WOLFSSL_FILETYPE_PEM));
|
||||
#else
|
||||
#elif defined(HAVE_ECC)
|
||||
AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, eccCertFile,
|
||||
WOLFSSL_FILETYPE_PEM));
|
||||
AssertTrue(wolfSSL_CTX_use_PrivateKey_file(ctx, eccKeyFile,
|
||||
WOLFSSL_FILETYPE_PEM));
|
||||
#elif defined(HAVE_ED25519)
|
||||
AssertTrue(wolfSSL_CTX_use_certificate_file(ctx, edCertFile,
|
||||
WOLFSSL_FILETYPE_PEM));
|
||||
AssertTrue(wolfSSL_CTX_use_PrivateKey_file(ctx, edKeyFile,
|
||||
WOLFSSL_FILETYPE_PEM));
|
||||
#endif
|
||||
AssertNotNull(ssl = wolfSSL_new(ctx));
|
||||
|
||||
@@ -21587,9 +21592,11 @@ static void test_CheckCertSignature(void)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(NO_FILESYSTEM) && (!defined(NO_RSA) || defined(HAVE_ECC))
|
||||
(void)fp;
|
||||
(void)cert;
|
||||
(void)certSz;
|
||||
#endif
|
||||
|
||||
wolfSSL_CertManagerFree(cm);
|
||||
#endif
|
||||
|
@@ -193,6 +193,36 @@ static int IsValidCert(const char* line)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int IsValidCA(const char* line)
|
||||
{
|
||||
int ret = 1;
|
||||
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
|
||||
WOLFSSL_CTX* ctx;
|
||||
size_t i;
|
||||
const char* begin;
|
||||
char cert[80];
|
||||
|
||||
begin = XSTRSTR(line, "-A ");
|
||||
if (begin == NULL)
|
||||
return 1;
|
||||
|
||||
begin += 3;
|
||||
for (i = 0; i < sizeof(cert) - 1 && *begin != ' ' && *begin != '\0'; i++)
|
||||
cert[i] = *(begin++);
|
||||
cert[i] = '\0';
|
||||
|
||||
ctx = wolfSSL_CTX_new(wolfSSLv23_server_method_ex(NULL));
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
ret = wolfSSL_CTX_use_certificate_chain_file(ctx, cert) == WOLFSSL_SUCCESS;
|
||||
wolfSSL_CTX_free(ctx);
|
||||
#endif /* !NO_FILESYSTEM && !NO_CERTS */
|
||||
|
||||
(void)line;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int execute_test_case(int svr_argc, char** svr_argv,
|
||||
int cli_argc, char** cli_argv,
|
||||
int addNoVerify, int addNonBlocking,
|
||||
@@ -392,6 +422,12 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
||||
strcat(commandLine, cli_argv[i]);
|
||||
strcat(commandLine, flagSep);
|
||||
}
|
||||
if (!IsValidCA(commandLine)) {
|
||||
#ifdef DEBUG_SUITE_TESTS
|
||||
printf("certificate %s not supported in build\n", commandLine);
|
||||
#endif
|
||||
return NOT_BUILT_IN;
|
||||
}
|
||||
printf("trying client command line[%d]: %s\n", tests, commandLine);
|
||||
|
||||
/* determine based on args if this test is expected to fail */
|
||||
|
@@ -669,6 +669,12 @@ void* wolfSSL_Malloc(size_t size, void* heap, int type)
|
||||
mem->ava[i] = pt->next;
|
||||
break;
|
||||
}
|
||||
#ifdef WOLFSSL_DEBUG_STATIC_MEMORY
|
||||
else {
|
||||
printf("Size: %ld, Empty: %d\n", size,
|
||||
mem->sizeList[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -864,6 +870,14 @@ void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type)
|
||||
WOLFSSL_HEAP* mem = hint->memory;
|
||||
word32 padSz = -(int)sizeof(wc_Memory) & (WOLFSSL_STATIC_ALIGN - 1);
|
||||
|
||||
if (ptr == NULL) {
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
return wolfSSL_Malloc(size, heap, type, func, line);
|
||||
#else
|
||||
return wolfSSL_Malloc(size, heap, type);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (wc_LockMutex(&(mem->memory_mutex)) != 0) {
|
||||
WOLFSSL_MSG("Bad memory_mutex lock");
|
||||
return NULL;
|
||||
|
@@ -3036,6 +3036,21 @@ static const unsigned char server_ed25519_cert[] =
|
||||
};
|
||||
static const int sizeof_server_ed25519_cert = sizeof(server_ed25519_cert);
|
||||
|
||||
/* ./certs/ed25519/server-ed25519-key.der, ED25519 */
|
||||
static const unsigned char server_ed25519_key[] =
|
||||
{
|
||||
0x30, 0x52, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2B,
|
||||
0x65, 0x70, 0x04, 0x22, 0x04, 0x20, 0x02, 0x2F, 0xC5, 0xFF,
|
||||
0xBA, 0x8E, 0xD0, 0xD2, 0xBF, 0x03, 0x8E, 0x76, 0x8F, 0xC8,
|
||||
0x86, 0x80, 0x71, 0x87, 0x97, 0x31, 0xE2, 0x40, 0xAC, 0xDF,
|
||||
0xBB, 0x90, 0x15, 0x52, 0x6E, 0x24, 0xA1, 0x39, 0xA1, 0x22,
|
||||
0x04, 0x20, 0x61, 0x5D, 0xEC, 0xB7, 0x45, 0x93, 0xC9, 0x84,
|
||||
0x7B, 0x68, 0x21, 0x4A, 0x4D, 0xF4, 0x04, 0x8B, 0xBD, 0xCD,
|
||||
0x6C, 0x5D, 0x3D, 0xB7, 0x62, 0x2C, 0x2D, 0x25, 0xC3, 0x22,
|
||||
0x49, 0xC8, 0x86, 0xF2
|
||||
};
|
||||
static const int sizeof_server_ed25519_key = sizeof(server_ed25519_key);
|
||||
|
||||
/* ./certs/ed25519/ca-ed25519.der, ED25519 */
|
||||
static const unsigned char ca_ed25519_cert[] =
|
||||
{
|
||||
@@ -3104,6 +3119,88 @@ static const unsigned char ca_ed25519_cert[] =
|
||||
};
|
||||
static const int sizeof_ca_ed25519_cert = sizeof(ca_ed25519_cert);
|
||||
|
||||
/* ./certs/ed25519/client-ed25519.der, ED25519 */
|
||||
static const unsigned char client_ed25519_cert[] =
|
||||
{
|
||||
0x30, 0x82, 0x02, 0x58, 0x30, 0x82, 0x02, 0x0A, 0xA0, 0x03,
|
||||
0x02, 0x01, 0x02, 0x02, 0x10, 0x00, 0x8F, 0x2F, 0x35, 0xB2,
|
||||
0x53, 0xBD, 0x4F, 0x92, 0xD1, 0xFF, 0x1D, 0x4B, 0x40, 0xA5,
|
||||
0x49, 0x30, 0x05, 0x06, 0x03, 0x2B, 0x65, 0x70, 0x30, 0x81,
|
||||
0xA1, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
|
||||
0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03,
|
||||
0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61,
|
||||
0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04,
|
||||
0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E,
|
||||
0x31, 0x0F, 0x30, 0x0D, 0x06, 0x03, 0x55, 0x04, 0x04, 0x0C,
|
||||
0x06, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x31, 0x10, 0x30,
|
||||
0x0E, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x07, 0x77, 0x6F,
|
||||
0x6C, 0x66, 0x53, 0x53, 0x4C, 0x31, 0x10, 0x30, 0x0E, 0x06,
|
||||
0x03, 0x55, 0x04, 0x0B, 0x0C, 0x07, 0x45, 0x44, 0x32, 0x35,
|
||||
0x35, 0x31, 0x39, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55,
|
||||
0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F,
|
||||
0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31,
|
||||
0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7,
|
||||
0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F,
|
||||
0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x38,
|
||||
0x30, 0x34, 0x31, 0x32, 0x31, 0x36, 0x32, 0x32, 0x31, 0x37,
|
||||
0x5A, 0x18, 0x0F, 0x32, 0x30, 0x32, 0x31, 0x30, 0x31, 0x30,
|
||||
0x37, 0x31, 0x35, 0x32, 0x32, 0x31, 0x37, 0x5A, 0x30, 0x81,
|
||||
0xA1, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
|
||||
0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03,
|
||||
0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61,
|
||||
0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04,
|
||||
0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E,
|
||||
0x31, 0x0F, 0x30, 0x0D, 0x06, 0x03, 0x55, 0x04, 0x04, 0x0C,
|
||||
0x06, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x31, 0x10, 0x30,
|
||||
0x0E, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x07, 0x77, 0x6F,
|
||||
0x6C, 0x66, 0x53, 0x53, 0x4C, 0x31, 0x10, 0x30, 0x0E, 0x06,
|
||||
0x03, 0x55, 0x04, 0x0B, 0x0C, 0x07, 0x45, 0x44, 0x32, 0x35,
|
||||
0x35, 0x31, 0x39, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55,
|
||||
0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F,
|
||||
0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31,
|
||||
0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7,
|
||||
0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F,
|
||||
0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x30, 0x2A, 0x30, 0x05, 0x06, 0x03, 0x2B, 0x65,
|
||||
0x70, 0x03, 0x21, 0x00, 0xA2, 0xF1, 0x26, 0x40, 0x9B, 0xA2,
|
||||
0x59, 0xDA, 0xDB, 0xE6, 0x15, 0x7F, 0x9A, 0x11, 0xB5, 0x48,
|
||||
0x5F, 0x55, 0xBA, 0x5E, 0xED, 0x46, 0xF7, 0x98, 0x67, 0xBE,
|
||||
0x0C, 0x93, 0xE3, 0xA4, 0x8E, 0x18, 0xA3, 0x52, 0x30, 0x50,
|
||||
0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04,
|
||||
0x14, 0xFE, 0x01, 0x46, 0x7F, 0x6F, 0x2B, 0x3E, 0x1C, 0xB0,
|
||||
0x6F, 0xE1, 0xCC, 0x4D, 0x02, 0x25, 0xF7, 0x4D, 0x0A, 0x95,
|
||||
0xB8, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18,
|
||||
0x30, 0x16, 0x80, 0x14, 0xFE, 0x01, 0x46, 0x7F, 0x6F, 0x2B,
|
||||
0x3E, 0x1C, 0xB0, 0x6F, 0xE1, 0xCC, 0x4D, 0x02, 0x25, 0xF7,
|
||||
0x4D, 0x0A, 0x95, 0xB8, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D,
|
||||
0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, 0x06, 0xC0,
|
||||
0x30, 0x05, 0x06, 0x03, 0x2B, 0x65, 0x70, 0x03, 0x41, 0x00,
|
||||
0x29, 0xF6, 0x69, 0xE2, 0xB9, 0x73, 0x12, 0xD1, 0x64, 0xEB,
|
||||
0x8F, 0xE9, 0x6B, 0x61, 0xDB, 0x5F, 0xE9, 0xA7, 0x62, 0x6C,
|
||||
0x10, 0x89, 0x41, 0x80, 0xE3, 0xE8, 0xFD, 0x1F, 0xD0, 0x13,
|
||||
0xAE, 0x95, 0x00, 0xAF, 0xF7, 0x77, 0xE1, 0x22, 0x32, 0xAD,
|
||||
0x46, 0x4F, 0xDC, 0x7E, 0xFE, 0xAE, 0xBC, 0x8A, 0x1F, 0x96,
|
||||
0x0A, 0xDA, 0x9F, 0xC9, 0x93, 0x52, 0x27, 0x18, 0xB0, 0x8B,
|
||||
0xDA, 0xBE, 0x81, 0x09
|
||||
};
|
||||
static const int sizeof_client_ed25519_cert = sizeof(client_ed25519_cert);
|
||||
|
||||
/* ./certs/ed25519/client-ed25519-key.der, ED25519 */
|
||||
static const unsigned char client_ed25519_key[] =
|
||||
{
|
||||
0x30, 0x52, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2B,
|
||||
0x65, 0x70, 0x04, 0x22, 0x04, 0x20, 0x27, 0xA3, 0x34, 0x2A,
|
||||
0x35, 0xD4, 0xBB, 0xB8, 0xE1, 0xDC, 0xD8, 0xEC, 0x0F, 0xC1,
|
||||
0xA0, 0xD1, 0xA2, 0x5C, 0xF9, 0x06, 0xF0, 0x44, 0x5D, 0x3B,
|
||||
0x97, 0x4D, 0xBD, 0xDF, 0x4A, 0x3B, 0xA3, 0x4E, 0xA1, 0x22,
|
||||
0x04, 0x20, 0xA2, 0xF1, 0x26, 0x40, 0x9B, 0xA2, 0x59, 0xDA,
|
||||
0xDB, 0xE6, 0x15, 0x7F, 0x9A, 0x11, 0xB5, 0x48, 0x5F, 0x55,
|
||||
0xBA, 0x5E, 0xED, 0x46, 0xF7, 0x98, 0x67, 0xBE, 0x0C, 0x93,
|
||||
0xE3, 0xA4, 0x8E, 0x18
|
||||
};
|
||||
static const int sizeof_client_ed25519_key = sizeof(client_ed25519_key);
|
||||
|
||||
#endif /* HAVE_ED25519 */
|
||||
|
||||
#endif /* WOLFSSL_CERTS_TEST_H */
|
||||
|
@@ -327,11 +327,11 @@
|
||||
#define cliEccCertFile "./certs/client-ecc-cert.pem"
|
||||
#define caEccCertFile "./certs/ca-ecc-cert.pem"
|
||||
#define crlPemDir "./certs/crl"
|
||||
#define edCertFile "./certs/ed25519/server-ed25519.pem"
|
||||
#define edCertFile "./certs/ed25519/server-ed25519-cert.pem"
|
||||
#define edKeyFile "./certs/ed25519/server-ed25519-priv.pem"
|
||||
#define cliEdCertFile "./certs/ed25519/client-ed25519.pem"
|
||||
#define cliEdKeyFile "./certs/ed25519/client-ed25519-priv.pem"
|
||||
#define caEdCertFile "./certs/ed25519/root-ed25519.pem"
|
||||
#define caEdCertFile "./certs/ed25519/ca-ed25519.pem"
|
||||
#ifdef HAVE_WNR
|
||||
/* Whitewood netRandom default config file */
|
||||
#define wnrConfig "./wnr-example.conf"
|
||||
|
@@ -110,7 +110,12 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb*,
|
||||
#endif
|
||||
#endif
|
||||
#ifndef WOLFMEM_DIST
|
||||
#ifndef WOLFSSL_STATIC_MEMORY_SMALL
|
||||
#define WOLFMEM_DIST 49,10,6,14,5,6,9,1,1
|
||||
#else
|
||||
/* Low resource and not RSA */
|
||||
#define WOLFMEM_DIST 29, 7,6, 9,4,4,0,0,0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* flags for loading static memory (one hot bit) */
|
||||
|
Reference in New Issue
Block a user