p5-Crypt-OpenSSL-DSA: don't set dummy public key to 0

When the Richards added setters for DSA parameters to OpenSSL 1.1, they
added a check that disallows setting a private key without a corresponding
public key. This was incompatible with existing API surface of the Perl
bindings, so they added a hack. This hack no longer works since we added
a check to the DSA signing operation.

Set the public key to 2 instead, which is good enough to pass the new
checks. This workaround will have to be revisited soon, but it is good
enough for now.

Discussed at length with beck, bluhm, jsing
reported by and ok bluhm (maintainer)
This commit is contained in:
tb
2023-03-14 06:56:22 +00:00
parent 4e78594305
commit af31309bce
2 changed files with 27 additions and 0 deletions
+1
View File
@@ -2,6 +2,7 @@ MODULES= cpan
COMMENT= implements DSA using OpenSSL
DISTNAME = Crypt-OpenSSL-DSA-0.20
CATEGORIES= security
REVISION = 0
# perl
PERMIT_PACKAGE= Yes
@@ -0,0 +1,26 @@
Use a dummy public key that has a chance of being an actual public key.
This works around an expected test failure until we add a check that a
signature can be verified with the provided DSA parameters.
It would probably make more sense to mark the failing test without this
diff as XFAIL.
Index: DSA.xs
--- DSA.xs.orig
+++ DSA.xs
@@ -601,12 +601,12 @@ set_priv_key(dsa, priv_key_SV)
PREINIT:
STRLEN len;
const BIGNUM *old_pub_key;
- BIGNUM *pub_key;
+ BIGNUM *pub_key = NULL;
BIGNUM *priv_key;
CODE:
DSA_get0_key(dsa, &old_pub_key, NULL);
if (NULL == old_pub_key) {
- pub_key = BN_new();
+ BN_dec2bn(&pub_key, "2");
if (NULL == pub_key) {
croak("Could not create a dummy public key");
}