aboutsummaryrefslogtreecommitdiff
path: root/test/dhtest.c
diff options
context:
space:
mode:
authorPhil Mesnier <mesnierp@objectcomputing.com>2021-10-27 04:26:45 -0500
committerPauli <pauli@openssl.org>2021-11-05 10:54:35 +1000
commit07e6c857364770f6e986b5d8ceb9fbe296f3c6d0 (patch)
treebd1c7faa3dce43b14cf42e1a186a3a2d4ab3ae6f /test/dhtest.c
parentd355c879b64e99194db8b943c6efc4b1a38740e5 (diff)
downloadopenssl-07e6c857364770f6e986b5d8ceb9fbe296f3c6d0.zip
openssl-07e6c857364770f6e986b5d8ceb9fbe296f3c6d0.tar.gz
openssl-07e6c857364770f6e986b5d8ceb9fbe296f3c6d0.tar.bz2
Fix for a segv interrupt that occurs when fix_dh_rfc5114 is called with
ctx->p2 being a null pointer. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16913)
Diffstat (limited to 'test/dhtest.c')
-rw-r--r--test/dhtest.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/dhtest.c b/test/dhtest.c
index cb8d9a7..71c95b1 100644
--- a/test/dhtest.c
+++ b/test/dhtest.c
@@ -730,6 +730,27 @@ err:
return ok;
}
+static int dh_rfc5114_fix_nid_test(void)
+{
+ int ok = 0;
+ EVP_PKEY_CTX *paramgen_ctx;
+
+ /* Run the test. Success is any time the test does not cause a SIGSEGV interrupt */
+ paramgen_ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_DHX, 0);
+ if (!TEST_ptr(paramgen_ctx))
+ goto err;
+ if (!TEST_int_eq(EVP_PKEY_paramgen_init(paramgen_ctx), 1))
+ goto err;
+ /* Tested function is called here */
+ if (!TEST_int_eq(EVP_PKEY_CTX_set_dhx_rfc5114(paramgen_ctx, 3), 1))
+ goto err;
+ /* If we're still running then the test passed. */
+ ok = 1;
+err:
+ EVP_PKEY_CTX_free(paramgen_ctx);
+ return ok;
+}
+
static int dh_get_nid(void)
{
int ok = 0;
@@ -876,6 +897,7 @@ int setup_tests(void)
ADD_ALL_TESTS(dh_test_prime_groups, OSSL_NELEM(prime_groups));
ADD_TEST(dh_get_nid);
ADD_TEST(dh_load_pkcs3_namedgroup_privlen_test);
+ ADD_TEST(dh_rfc5114_fix_nid_test);
#endif
return 1;
}