From b2c0518e6ae73f09abadaac3d00e65ee0c315f14 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 23 Mar 2006 14:04:39 +0000 Subject: [PATCH] Fix bug in DSA, EC methods. --- crypto/dsa/dsa_ameth.c | 3 ++- crypto/ec/ec_ameth.c | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index 26e274f859..ed0ab2b712 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -108,7 +108,7 @@ static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) } ASN1_INTEGER_free(public_key); - + EVP_PKEY_assign_DSA(pkey, dsa); return 1; err: @@ -139,6 +139,7 @@ static int dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } + pval = str; ptype = V_ASN1_SEQUENCE; } else diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index da437faf2b..4a136619ab 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -445,7 +445,6 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) goto err; } - if (ktype > 0) { public_key = EC_KEY_get0_public_key(x); @@ -455,15 +454,15 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) reason = ERR_R_EC_LIB; goto err; } - buf_len = (size_t)BN_num_bytes(pub_key); + if (pub_key) + buf_len = (size_t)BN_num_bytes(pub_key); } - else if (ktype == 2) { - if ((i = (size_t)BN_num_bytes(priv_key)) > buf_len) - buf_len = i; priv_key = EC_KEY_get0_private_key(x); + if (priv_key && (i = (size_t)BN_num_bytes(priv_key)) > buf_len) + buf_len = i; } else priv_key = NULL; -- 2.25.1