diff --git a/src/tls.c b/src/tls.c index 9af895eef..dd1149ae9 100644 --- a/src/tls.c +++ b/src/tls.c @@ -8454,7 +8454,7 @@ static int server_generate_pqc_ciphertext(WOLFSSL* ssl, if (ret == 0) { ret = wc_KyberKey_Init(type, kem, ssl->heap, INVALID_DEVID); - if (ret == 0) { + if (ret != 0) { WOLFSSL_MSG("Error creating Kyber KEM"); } } diff --git a/tests/suites.c b/tests/suites.c index 92877ce64..dca563fe7 100644 --- a/tests/suites.c +++ b/tests/suites.c @@ -927,6 +927,50 @@ int SuiteTest(int argc, char** argv) } #endif #endif + #ifdef HAVE_PQC + /* add TLSv13 pq tests */ + XSTRLCPY(argv0[1], "tests/test-tls13-pq.conf", sizeof(argv0[1])); + printf("starting TLSv13 post-quantum groups tests\n"); + test_harness(&args); + if (args.return_code != 0) { + printf("error from script %d\n", args.return_code); + args.return_code = EXIT_FAILURE; + goto exit; + } + #ifdef HAVE_LIBOQS + /* add TLSv13 pq tests */ + XSTRLCPY(argv0[1], "tests/test-tls13-pq-2.conf", sizeof(argv0[1])); + printf("starting TLSv13 post-quantum groups tests\n"); + test_harness(&args); + if (args.return_code != 0) { + printf("error from script %d\n", args.return_code); + args.return_code = EXIT_FAILURE; + goto exit; + } + #endif + #endif + #if defined(HAVE_PQC) && defined(WOLFSSL_DTLS13) + /* add DTLSv13 pq tests */ + XSTRLCPY(argv0[1], "tests/test-dtls13-pq.conf", sizeof(argv0[1])); + printf("starting DTLSv13 post-quantum groups tests\n"); + test_harness(&args); + if (args.return_code != 0) { + printf("error from script %d\n", args.return_code); + args.return_code = EXIT_FAILURE; + goto exit; + } + #ifdef HAVE_LIBOQS + /* add DTLSv13 pq tests */ + XSTRLCPY(argv0[1], "tests/test-dtls13-pq-2.conf", sizeof(argv0[1])); + printf("starting DTLSv13 post-quantum groups tests\n"); + test_harness(&args); + if (args.return_code != 0) { + printf("error from script %d\n", args.return_code); + args.return_code = EXIT_FAILURE; + goto exit; + } + #endif + #endif #endif #if defined(WC_RSA_PSS) && (!defined(HAVE_FIPS) || \ (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION > 2))) && \ diff --git a/tests/test-dtls13-pq-2.conf b/tests/test-dtls13-pq-2.conf new file mode 100644 index 000000000..6a4bfac08 --- /dev/null +++ b/tests/test-dtls13-pq-2.conf @@ -0,0 +1,13 @@ +# server DTLSv1.3 with post-quantum group +-u +-v 4 +-l TLS13-AES256-GCM-SHA384 +--pqc P256_KYBER_LEVEL1 + +# client DTLSv1.3 with post-quantum group +-u +-v 4 +-l TLS13-AES256-GCM-SHA384 +--pqc P256_KYBER_LEVEL1 + +# P384_KYBER_LEVEL3 and P521_KYBER_LEVEL5 would fragment the ClientHello. diff --git a/tests/test-dtls13-pq.conf b/tests/test-dtls13-pq.conf new file mode 100644 index 000000000..c84ab819d --- /dev/null +++ b/tests/test-dtls13-pq.conf @@ -0,0 +1,13 @@ +# server DTLSv1.3 with post-quantum group +-u +-v 4 +-l TLS13-AES256-GCM-SHA384 +--pqc KYBER_LEVEL1 + +# client DTLSv1.3 with post-quantum group +-u +-v 4 +-l TLS13-AES256-GCM-SHA384 +--pqc KYBER_LEVEL1 + +# KYBER_LEVEL3 and KYBER_LEVEL5 would fragment the ClientHello.