From fc8d0881c9975138fd5b86f91a92ab8ec93c9ce5 Mon Sep 17 00:00:00 2001 From: Quim Muntal Date: Mon, 22 Jan 2024 15:36:29 +0000 Subject: [PATCH] fix dsa selection --- dsa.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dsa.go b/dsa.go index 1339cb17..b52da6a3 100644 --- a/dsa.go +++ b/dsa.go @@ -260,16 +260,14 @@ func newDSA3(params DSAParameters, X, Y BigInt) (C.GO_EVP_PKEY_PTR, error) { C.go_openssl_OSSL_PARAM_BLD_push_BN(bld, paramG, g) != 1 { return nil, newOpenSSLError("OSSL_PARAM_BLD_push_BN") } - selection := C.int(C.GO_EVP_PKEY_KEYPAIR) + selection := C.int(C.GO_EVP_PKEY_KEY_PARAMETERS) if Y != nil { pub := bigToBN(Y) defer C.go_openssl_BN_free(pub) if C.go_openssl_OSSL_PARAM_BLD_push_BN(bld, paramPubKey, pub) != 1 { return nil, newOpenSSLError("OSSL_PARAM_BLD_push_BN") } - if X == nil { - selection = C.int(C.GO_EVP_PKEY_PUBLIC_KEY) - } + selection = C.int(C.GO_EVP_PKEY_PUBLIC_KEY) } if X != nil { priv := bigToBN(X) @@ -277,6 +275,7 @@ func newDSA3(params DSAParameters, X, Y BigInt) (C.GO_EVP_PKEY_PTR, error) { if C.go_openssl_OSSL_PARAM_BLD_push_BN(bld, paramPrivKey, priv) != 1 { return nil, newOpenSSLError("OSSL_PARAM_BLD_push_BN") } + selection = C.int(C.GO_EVP_PKEY_KEYPAIR) } bldparams := C.go_openssl_OSSL_PARAM_BLD_to_param(bld) if bldparams == nil { @@ -297,7 +296,6 @@ func newDSA3(params DSAParameters, X, Y BigInt) (C.GO_EVP_PKEY_PTR, error) { if ctx == nil { return nil, newOpenSSLError("EVP_PKEY_CTX_new_from_pkey") } - defer C.go_openssl_EVP_PKEY_CTX_free(ctx) if C.go_openssl_EVP_PKEY_keygen_init(ctx) != 1 { return nil, newOpenSSLError("EVP_PKEY_keygen_init") }