mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
Add a test
This commit is contained in:
30
tests/api.c
30
tests/api.c
@@ -1084,6 +1084,21 @@ static int do_dual_alg_tls13_connection(byte *caCert, word32 caCertSz,
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
static int extCount = 0;
|
||||
static int myUnknownExtCallback(const word16* oid, word32 oidSz, int crit,
|
||||
const unsigned char* der, word32 derSz)
|
||||
{
|
||||
(void) oid;
|
||||
(void) oidSz;
|
||||
(void) crit;
|
||||
(void) der;
|
||||
(void) derSz;
|
||||
extCount ++;
|
||||
/* Accept all extensions. This is only a test. Normally we would be much more
|
||||
* careful about critical extensions. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_dual_alg_support(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
@@ -1099,6 +1114,7 @@ static int test_dual_alg_support(void)
|
||||
int rootSz = 0;
|
||||
byte *server = NULL;
|
||||
int serverSz = 0;
|
||||
WOLFSSL_CERT_MANAGER* cm = NULL;
|
||||
|
||||
ExpectIntEQ(load_file(keyFile, &serverKey, &serverKeySz), 0);
|
||||
|
||||
@@ -1130,6 +1146,20 @@ static int test_dual_alg_support(void)
|
||||
ExpectIntEQ(do_dual_alg_tls13_connection(root, rootSz,
|
||||
server, serverSz, serverKey, (word32)serverKeySz, 1),
|
||||
TEST_SUCCESS);
|
||||
|
||||
/* Lets see if CertManager can find the new extensions */
|
||||
extCount = 0;
|
||||
ExpectNotNull(cm = wolfSSL_CertManagerNew());
|
||||
wolfSSL_CertManagerSetUnknownExtCallback(cm, myUnknownExtCallback);
|
||||
ExpectIntEQ(wolfSSL_CertManagerLoadCABuffer(cm, root, rootSz,
|
||||
SSL_FILETYPE_ASN1), WOLFSSL_SUCCESS);
|
||||
ExpectIntEQ(wolfSSL_CertManagerVerifyBuffer(cm, server, serverSz,
|
||||
SSL_FILETYPE_ASN1), WOLFSSL_SUCCESS);
|
||||
/* There is only 1 unknown exension (1.2.3.4.5). The other ones are known
|
||||
* because they are for the dual alg extensions. */
|
||||
ExpectIntEQ(extCount, 1);
|
||||
wolfSSL_CertManagerFree(cm);
|
||||
|
||||
XFREE(root, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
XFREE(server, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
|
@@ -348,6 +348,9 @@
|
||||
|
||||
#undef OPENSSL_EXTRA
|
||||
#define OPENSSL_EXTRA
|
||||
|
||||
#undef HAVE_OID_DECODING
|
||||
#define HAVE_OID_DECODING
|
||||
#endif /* WOLFSSL_DUAL_ALG_CERTS */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user