Skip to content

Commit 9d0718c

Browse files
committed
pkey/dsa: do not create legacy DSA pkey
1 parent 5892958 commit 9d0718c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/openssl/ossl_pkey_dsa.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ static VALUE
8484
ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
8585
{
8686
EVP_PKEY *pkey;
87+
#ifndef OSSL_HAVE_PROVIDER
8788
DSA *dsa;
89+
#endif
8890
BIO *in = NULL;
8991
VALUE arg, pass;
9092
int type;
@@ -96,23 +98,29 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
9698
/* The DSA.new(size, generator) form is handled by lib/openssl/pkey.rb */
9799
rb_scan_args(argc, argv, "02", &arg, &pass);
98100
if (argc == 0) {
101+
#ifdef OSSL_HAVE_PROVIDER
102+
rb_raise(eDHError, "empty DSA cannot be created");
103+
#else
99104
dsa = DSA_new();
100105
if (!dsa)
101106
ossl_raise(eDSAError, "DSA_new");
102107
goto legacy;
108+
#endif
103109
}
104110

105111
pass = ossl_pem_passwd_value(pass);
106112
arg = ossl_to_der_if_possible(arg);
107113
in = ossl_obj2bio(&arg);
108114

115+
#ifndef OSSL_HAVE_PROVIDER
109116
/* DER-encoded DSAPublicKey format isn't supported by the generic routine */
110117
dsa = (DSA *)PEM_ASN1_read_bio((d2i_of_void *)d2i_DSAPublicKey,
111118
PEM_STRING_DSA_PUBLIC,
112119
in, NULL, NULL, NULL);
113120
if (dsa)
114121
goto legacy;
115122
OSSL_BIO_reset(in);
123+
#endif
116124

117125
pkey = ossl_pkey_read_generic(in, pass);
118126
BIO_free(in);
@@ -127,6 +135,7 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
127135
RTYPEDDATA_DATA(self) = pkey;
128136
return self;
129137

138+
#ifndef OSSL_HAVE_PROVIDER
130139
legacy:
131140
BIO_free(in);
132141
pkey = EVP_PKEY_new();
@@ -137,6 +146,7 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
137146
}
138147
RTYPEDDATA_DATA(self) = pkey;
139148
return self;
149+
#endif
140150
}
141151

142152
#ifndef HAVE_EVP_PKEY_DUP

0 commit comments

Comments
 (0)