summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dsa/dsa_ameth.c
diff options
context:
space:
mode:
authortb <>2022-01-14 08:29:06 +0000
committertb <>2022-01-14 08:29:06 +0000
commit82f4ff947f0f70daa31c164267dbb748f7c3c7ee (patch)
treebf869887a478042f2d395ff26cb94929bc51b5e8 /src/lib/libcrypto/dsa/dsa_ameth.c
parent96b331528b7ab48983a3d8cb43fcf82cd8f322c3 (diff)
downloadopenbsd-82f4ff947f0f70daa31c164267dbb748f7c3c7ee.tar.gz
openbsd-82f4ff947f0f70daa31c164267dbb748f7c3c7ee.tar.bz2
openbsd-82f4ff947f0f70daa31c164267dbb748f7c3c7ee.zip
Simplify DSAPublicKey_it
This was obtained by porting the OpenSSL commit below and then using expand_crypto_asn1.go to unroll the new ASN.1 macros - actually the ones from 987157f6f63 which fixed the omission of dsa_cb() in the first commit. ok inoguchi jsing commit ea6b07b54c1f8fc2275a121cdda071e2df7bd6c1 Author: Dr. Stephen Henson <steve@openssl.org> Date: Thu Mar 26 14:35:49 2015 +0000 Simplify DSA public key handling. DSA public keys could exist in two forms: a single Integer type or a SEQUENCE containing the parameters and public key with a field called "write_params" deciding which form to use. These forms are non standard and were only used by functions containing "DSAPublicKey" in the name. Simplify code to only use the parameter form and encode the public key component directly in the DSA public key method. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_ameth.c')
-rw-r--r--src/lib/libcrypto/dsa/dsa_ameth.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c
index 3c7644d251..5fff2890a2 100644
--- a/src/lib/libcrypto/dsa/dsa_ameth.c
+++ b/src/lib/libcrypto/dsa/dsa_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dsa_ameth.c,v 1.30 2022/01/07 09:35:36 tb Exp $ */ 1/* $OpenBSD: dsa_ameth.c,v 1.31 2022/01/14 08:29:06 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -133,6 +133,7 @@ static int
133dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) 133dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
134{ 134{
135 DSA *dsa; 135 DSA *dsa;
136 ASN1_INTEGER *pubint = NULL;
136 void *pval = NULL; 137 void *pval = NULL;
137 int ptype; 138 int ptype;
138 unsigned char *penc = NULL; 139 unsigned char *penc = NULL;
@@ -158,9 +159,14 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
158 } else 159 } else
159 ptype = V_ASN1_UNDEF; 160 ptype = V_ASN1_UNDEF;
160 161
161 dsa->write_params = 0;
162 162
163 penclen = i2d_DSAPublicKey(dsa, &penc); 163 if ((pubint = BN_to_ASN1_INTEGER(dsa->pub_key, NULL)) == NULL) {
164 DSAerror(ERR_R_MALLOC_FAILURE);
165 goto err;
166 }
167
168 penclen = i2d_ASN1_INTEGER(pubint, &penc);
169 ASN1_INTEGER_free(pubint);
164 170
165 if (penclen <= 0) { 171 if (penclen <= 0) {
166 DSAerror(ERR_R_MALLOC_FAILURE); 172 DSAerror(ERR_R_MALLOC_FAILURE);