aboutsummaryrefslogtreecommitdiff
path: root/test/dhtest.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-01-31 08:18:46 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-01-31 08:18:46 +1000
commitca2bf555cd64bc9624af1259ce3cd27f95a5763e (patch)
treee02beb157e56973ada62c679cb7b3b8756e86dfe /test/dhtest.c
parentcd624ccd41ac3ac779c1c7a7a1e63427ce9588dd (diff)
downloadopenssl-ca2bf555cd64bc9624af1259ce3cd27f95a5763e.zip
openssl-ca2bf555cd64bc9624af1259ce3cd27f95a5763e.tar.gz
openssl-ca2bf555cd64bc9624af1259ce3cd27f95a5763e.tar.bz2
Add support for DH 'modp' group parameters (RFC 3526)
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10897)
Diffstat (limited to 'test/dhtest.c')
-rw-r--r--test/dhtest.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/dhtest.c b/test/dhtest.c
index e8a91f1..a357d02 100644
--- a/test/dhtest.c
+++ b/test/dhtest.c
@@ -676,6 +676,38 @@ static int rfc7919_test(void)
DH_free(b);
return ret;
}
+
+static int prime_groups[] = {
+ NID_ffdhe2048,
+ NID_ffdhe3072,
+ NID_ffdhe4096,
+ NID_ffdhe6144,
+ NID_ffdhe8192,
+ NID_modp_2048,
+ NID_modp_3072,
+ NID_modp_4096,
+ NID_modp_6144,
+};
+
+static int dh_test_prime_groups(int index)
+{
+ int ok = 0;
+ DH *dh = NULL;
+ const BIGNUM *p, *q, *g;
+
+ if (!TEST_ptr(dh = DH_new_by_nid(prime_groups[index])))
+ goto err;
+ DH_get0_pqg(dh, &p, &q, &g);
+ if (!TEST_ptr(p) || !TEST_ptr(q) || !TEST_ptr(g))
+ goto err;
+
+ if (!TEST_int_eq(DH_get_nid(dh), prime_groups[index]))
+ goto err;
+ ok = 1;
+err:
+ DH_free(dh);
+ return ok;
+}
#endif
@@ -687,6 +719,7 @@ int setup_tests(void)
ADD_TEST(dh_test);
ADD_TEST(rfc5114_test);
ADD_TEST(rfc7919_test);
+ ADD_ALL_TESTS(dh_test_prime_groups, OSSL_NELEM(prime_groups));
#endif
return 1;
}