aboutsummaryrefslogtreecommitdiff
path: root/crypto/asn1/t_pkey.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2002-12-04 17:43:01 +0000
committerBodo Möller <bodo@openssl.org>2002-12-04 17:43:01 +0000
commit7e8c30b5897fb9fae87e42bf19dca29ca1b0dcac (patch)
treeda5bbe57b187292af2938c242fe45eb54740d23b /crypto/asn1/t_pkey.c
parent2b32b2819187564e450539f94d5ae9716a11c757 (diff)
downloadopenssl-7e8c30b5897fb9fae87e42bf19dca29ca1b0dcac.zip
openssl-7e8c30b5897fb9fae87e42bf19dca29ca1b0dcac.tar.gz
openssl-7e8c30b5897fb9fae87e42bf19dca29ca1b0dcac.tar.bz2
In ECPKParameters_print, output the private key length correctly
(length of the order of the group, not length of the actual key, which will be shorter in some cases). Submitted by: Nils Larsch
Diffstat (limited to 'crypto/asn1/t_pkey.c')
-rw-r--r--crypto/asn1/t_pkey.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/asn1/t_pkey.c b/crypto/asn1/t_pkey.c
index b418bf0..06e85f3 100644
--- a/crypto/asn1/t_pkey.c
+++ b/crypto/asn1/t_pkey.c
@@ -479,7 +479,7 @@ int EC_KEY_print(BIO *bp, const EC_KEY *x, int off)
unsigned char *buffer=NULL;
size_t buf_len=0, i;
int ret=0, reason=ERR_R_BIO_LIB;
- BIGNUM *pub_key=NULL;
+ BIGNUM *pub_key=NULL, *order=NULL;
BN_CTX *ctx=NULL;
if (!x || !x->group)
@@ -513,8 +513,12 @@ int EC_KEY_print(BIO *bp, const EC_KEY *x, int off)
{
if (!BIO_indent(bp, off, 128))
goto err;
+ if ((order = BN_new()) == NULL)
+ goto err;
+ if (!EC_GROUP_get_order(x->group, order, NULL))
+ goto err;
if (BIO_printf(bp, "Private-Key: (%d bit)\n",
- BN_num_bits(x->priv_key)) <= 0) goto err;
+ BN_num_bits(order)) <= 0) goto err;
}
if ((x->priv_key != NULL) && !print(bp, "priv:", x->priv_key,
@@ -531,6 +535,8 @@ err:
ECerr(EC_F_EC_KEY_PRINT, reason);
if (pub_key)
BN_free(pub_key);
+ if (order)
+ BN_free(order);
if (ctx)
BN_CTX_free(ctx);
if (buffer != NULL)