Skip to content

Commit 5b762b1

Browse files
committed
get rid of bad tests
1 parent 728d695 commit 5b762b1

1 file changed

Lines changed: 0 additions & 97 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -30493,53 +30493,6 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t pwdbased_test(void)
3049330493
if (ret != 0)
3049430494
return ret;
3049530495
#endif
30496-
#if defined(HAVE_PKCS12) && !defined(NO_ASN) && !defined(NO_PWDBASED) && \
30497-
!defined(NO_HMAC) && !defined(NO_CERTS)
30498-
/* Test that a crafted PKCS#12 with INT_MAX MAC iterations is rejected
30499-
* immediately rather than hanging in DoPKCS12Hash(). */
30500-
{
30501-
static const byte evil_p12[] = {
30502-
0x30, 0x58, 0x02, 0x01, 0x03, 0x30, 0x1e, 0x06,
30503-
0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
30504-
0x07, 0x01, 0xa0, 0x11, 0x04, 0x0f, 0x30, 0x0d,
30505-
0x30, 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
30506-
0xf7, 0x0d, 0x01, 0x07, 0x01, 0x30, 0x33, 0x30,
30507-
0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
30508-
0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x00, 0x00,
30509-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30510-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30511-
0x00, 0x00, 0x04, 0x08, 0x41, 0x41, 0x41, 0x41,
30512-
0x41, 0x41, 0x41, 0x41, 0x02, 0x04, 0x7f, 0xff,
30513-
0xff, 0xff
30514-
};
30515-
WC_PKCS12* evilPkcs12 = wc_PKCS12_new_ex(HEAP_HINT);
30516-
if (evilPkcs12 == NULL)
30517-
return WC_TEST_RET_ENC_EC(MEMORY_E);
30518-
30519-
ret = wc_d2i_PKCS12(evil_p12, (word32)sizeof(evil_p12), evilPkcs12);
30520-
if (ret == 0) {
30521-
byte* evilKey = NULL;
30522-
byte* evilCert = NULL;
30523-
word32 evilKeySz = 0, evilCertSz = 0;
30524-
WC_DerCertList* evilCa = NULL;
30525-
30526-
ret = wc_PKCS12_parse(evilPkcs12, "test", &evilKey, &evilKeySz,
30527-
&evilCert, &evilCertSz, &evilCa);
30528-
XFREE(evilKey, HEAP_HINT, DYNAMIC_TYPE_PKCS);
30529-
XFREE(evilCert, HEAP_HINT, DYNAMIC_TYPE_PKCS);
30530-
if (evilCa)
30531-
wc_FreeCertList(evilCa, HEAP_HINT);
30532-
wc_PKCS12_free(evilPkcs12);
30533-
/* Parse must fail (iteration cap), not succeed or hang */
30534-
if (ret == 0)
30535-
return WC_TEST_RET_ENC_NC;
30536-
}
30537-
else {
30538-
wc_PKCS12_free(evilPkcs12);
30539-
}
30540-
ret = 0;
30541-
}
30542-
#endif /* HAVE_PKCS12 && !NO_ASN && !NO_PWDBASED && !NO_HMAC && !NO_CERTS */
3054330496
#ifdef HAVE_SCRYPT
3054430497
ret = scrypt_test();
3054530498
if (ret != 0)
@@ -30639,56 +30592,6 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t pkcs12_test(void)
3063930592
goto out;
3064030593
}
3064130594

30642-
/* Test that a crafted PKCS#12 with INT_MAX MAC iterations is rejected
30643-
* immediately rather than hanging in DoPKCS12Hash(). This is a 90-byte
30644-
* minimal PKCS#12 with mac->itt = 0x7FFFFFFF (2,147,483,647). */
30645-
{
30646-
static const byte evil_p12[] = {
30647-
0x30, 0x58, 0x02, 0x01, 0x03, 0x30, 0x1e, 0x06,
30648-
0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
30649-
0x07, 0x01, 0xa0, 0x11, 0x04, 0x0f, 0x30, 0x0d,
30650-
0x30, 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
30651-
0xf7, 0x0d, 0x01, 0x07, 0x01, 0x30, 0x33, 0x30,
30652-
0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
30653-
0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, 0x00, 0x00,
30654-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30655-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30656-
0x00, 0x00, 0x04, 0x08, 0x41, 0x41, 0x41, 0x41,
30657-
0x41, 0x41, 0x41, 0x41, 0x02, 0x04, 0x7f, 0xff,
30658-
0xff, 0xff
30659-
};
30660-
WC_PKCS12* evilPkcs12 = wc_PKCS12_new_ex(HEAP_HINT);
30661-
if (evilPkcs12 == NULL) {
30662-
ret = WC_TEST_RET_ENC_EC(MEMORY_E);
30663-
goto out;
30664-
}
30665-
ret = wc_d2i_PKCS12(evil_p12, (word32)sizeof(evil_p12), evilPkcs12);
30666-
if (ret != 0) {
30667-
wc_PKCS12_free(evilPkcs12);
30668-
ret = WC_TEST_RET_ENC_EC(ret);
30669-
goto out;
30670-
}
30671-
{
30672-
byte* evilKey = NULL;
30673-
byte* evilCert = NULL;
30674-
word32 evilKeySz = 0, evilCertSz = 0;
30675-
WC_DerCertList* evilCa = NULL;
30676-
ret = wc_PKCS12_parse(evilPkcs12, "test", &evilKey, &evilKeySz,
30677-
&evilCert, &evilCertSz, &evilCa);
30678-
XFREE(evilKey, HEAP_HINT, DYNAMIC_TYPE_PKCS);
30679-
XFREE(evilCert, HEAP_HINT, DYNAMIC_TYPE_PKCS);
30680-
if (evilCa)
30681-
wc_FreeCertList(evilCa, HEAP_HINT);
30682-
}
30683-
wc_PKCS12_free(evilPkcs12);
30684-
/* Must have been rejected (not hung) */
30685-
if (ret == 0) {
30686-
ret = WC_TEST_RET_ENC_NC;
30687-
goto out;
30688-
}
30689-
ret = 0; /* rejection is the expected outcome */
30690-
}
30691-
3069230595
out:
3069330596

3069430597
if (derCaListOut)

0 commit comments

Comments
 (0)