summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-11-29 15:59:57 +0000
committertb <>2024-11-29 15:59:57 +0000
commit0c4bef0c67554c96db6dc257452593c5a9b573ec (patch)
tree22254e07ec11cf2eb4ce6ceccc43ec3534201a43 /src
parent7bf674fac288e15425988251ece54449f398a71c (diff)
downloadopenbsd-0c4bef0c67554c96db6dc257452593c5a9b573ec.tar.gz
openbsd-0c4bef0c67554c96db6dc257452593c5a9b573ec.tar.bz2
openbsd-0c4bef0c67554c96db6dc257452593c5a9b573ec.zip
Remove X9.42 DH rudiments
In the unlikely event that we should ever decide to implement this after a quarter century of not needing it, we can readily put this back. Until then this is dead weight. prompted by a question by djm ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/dh/dh_check.c10
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c7
-rw-r--r--src/lib/libcrypto/dh/dh_local.h9
3 files changed, 7 insertions, 19 deletions
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c
index 57330b2068..a880f9fca1 100644
--- a/src/lib/libcrypto/dh/dh_check.c
+++ b/src/lib/libcrypto/dh/dh_check.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_check.c,v 1.29 2024/08/30 17:44:56 tb Exp $ */ 1/* $OpenBSD: dh_check.c,v 1.30 2024/11/29 15:59:57 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -127,10 +127,8 @@ DH_check(const DH *dh, int *flags)
127 BN_CTX_start(ctx); 127 BN_CTX_start(ctx);
128 128
129 if (dh->q != NULL) { 129 if (dh->q != NULL) {
130 BIGNUM *quotient, *residue; 130 BIGNUM *residue;
131 131
132 if ((quotient = BN_CTX_get(ctx)) == NULL)
133 goto err;
134 if ((residue = BN_CTX_get(ctx)) == NULL) 132 if ((residue = BN_CTX_get(ctx)) == NULL)
135 goto err; 133 goto err;
136 if ((*flags & DH_NOT_SUITABLE_GENERATOR) == 0) { 134 if ((*flags & DH_NOT_SUITABLE_GENERATOR) == 0) {
@@ -147,12 +145,10 @@ DH_check(const DH *dh, int *flags)
147 if (is_prime == 0) 145 if (is_prime == 0)
148 *flags |= DH_CHECK_Q_NOT_PRIME; 146 *flags |= DH_CHECK_Q_NOT_PRIME;
149 /* Check p == 1 mod q, i.e., q divides p - 1 */ 147 /* Check p == 1 mod q, i.e., q divides p - 1 */
150 if (!BN_div_ct(quotient, residue, dh->p, dh->q, ctx)) 148 if (!BN_div_ct(NULL, residue, dh->p, dh->q, ctx))
151 goto err; 149 goto err;
152 if (!BN_is_one(residue)) 150 if (!BN_is_one(residue))
153 *flags |= DH_CHECK_INVALID_Q_VALUE; 151 *flags |= DH_CHECK_INVALID_Q_VALUE;
154 if (dh->j != NULL && BN_cmp(dh->j, quotient) != 0)
155 *flags |= DH_CHECK_INVALID_J_VALUE;
156 } 152 }
157 153
158 is_prime = BN_is_prime_ex(dh->p, DH_NUMBER_ITERATIONS_FOR_PRIME, 154 is_prime = BN_is_prime_ex(dh->p, DH_NUMBER_ITERATIONS_FOR_PRIME,
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 86503bc4e0..803aca6421 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_lib.c,v 1.45 2024/03/27 01:26:30 tb Exp $ */ 1/* $OpenBSD: dh_lib.c,v 1.46 2024/11/29 15:59:57 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -154,11 +154,8 @@ DH_free(DH *dh)
154 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, dh, &dh->ex_data); 154 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, dh, &dh->ex_data);
155 155
156 BN_free(dh->p); 156 BN_free(dh->p);
157 BN_free(dh->g);
158 BN_free(dh->q); 157 BN_free(dh->q);
159 BN_free(dh->j); 158 BN_free(dh->g);
160 free(dh->seed);
161 BN_free(dh->counter);
162 BN_free(dh->pub_key); 159 BN_free(dh->pub_key);
163 BN_free(dh->priv_key); 160 BN_free(dh->priv_key);
164 free(dh); 161 free(dh);
diff --git a/src/lib/libcrypto/dh/dh_local.h b/src/lib/libcrypto/dh/dh_local.h
index efbc08b356..2c89f10127 100644
--- a/src/lib/libcrypto/dh/dh_local.h
+++ b/src/lib/libcrypto/dh/dh_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_local.h,v 1.6 2024/11/29 07:42:35 tb Exp $ */ 1/* $OpenBSD: dh_local.h,v 1.7 2024/11/29 15:59:57 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -80,6 +80,7 @@ struct dh_method {
80struct dh_st { 80struct dh_st {
81 int version; 81 int version;
82 BIGNUM *p; 82 BIGNUM *p;
83 BIGNUM *q;
83 BIGNUM *g; 84 BIGNUM *g;
84 long length; /* optional */ 85 long length; /* optional */
85 BIGNUM *pub_key; /* g^x */ 86 BIGNUM *pub_key; /* g^x */
@@ -87,12 +88,6 @@ struct dh_st {
87 88
88 int flags; 89 int flags;
89 BN_MONT_CTX *method_mont_p; 90 BN_MONT_CTX *method_mont_p;
90 /* Place holders if we want to do X9.42 DH */
91 BIGNUM *q;
92 BIGNUM *j;
93 unsigned char *seed;
94 int seedlen;
95 BIGNUM *counter;
96 91
97 int references; 92 int references;
98 CRYPTO_EX_DATA ex_data; 93 CRYPTO_EX_DATA ex_data;