diff options
Diffstat (limited to 'crypto/dsa/dsa_ameth.c')
-rw-r--r-- | crypto/dsa/dsa_ameth.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index 96d5c5a..65e07fd 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -132,6 +132,7 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) unsigned char *penc = NULL; int penclen; ASN1_STRING *str = NULL; + ASN1_INTEGER *pubint = NULL; dsa = pkey->pkey.dsa; if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) { @@ -149,9 +150,15 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) } else ptype = V_ASN1_UNDEF; - dsa->write_params = 0; + pubint = BN_to_ASN1_INTEGER(dsa->pub_key, NULL); - penclen = i2d_DSAPublicKey(dsa, &penc); + if (pubint == NULL) { + DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); + goto err; + } + + penclen = i2d_ASN1_INTEGER(pubint, &penc); + ASN1_INTEGER_free(pubint); if (penclen <= 0) { DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); |