sync
This commit is contained in:
parent
2a351e0cdc
commit
f57be82572
704 changed files with 20524 additions and 10572 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ec_ameth.c,v 1.40 2023/07/03 09:25:44 tb Exp $ */
|
||||
/* $OpenBSD: ec_ameth.c,v 1.41 2023/07/07 06:59:18 tb Exp $ */
|
||||
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
|
||||
* project 2006.
|
||||
*/
|
||||
|
@ -427,9 +427,7 @@ int_ec_free(EVP_PKEY *pkey)
|
|||
static int
|
||||
do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype)
|
||||
{
|
||||
unsigned char *buffer = NULL;
|
||||
const char *ecstr;
|
||||
size_t buf_len = 0, i;
|
||||
int ret = 0, reason = ERR_R_BIO_LIB;
|
||||
BIGNUM *pub_key = NULL;
|
||||
BN_CTX *ctx = NULL;
|
||||
|
@ -454,24 +452,13 @@ do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype)
|
|||
reason = ERR_R_EC_LIB;
|
||||
goto err;
|
||||
}
|
||||
if (pub_key)
|
||||
buf_len = (size_t) BN_num_bytes(pub_key);
|
||||
}
|
||||
}
|
||||
if (ktype == 2) {
|
||||
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;
|
||||
|
||||
if (ktype > 0) {
|
||||
buf_len += 10;
|
||||
if ((buffer = malloc(buf_len)) == NULL) {
|
||||
reason = ERR_R_MALLOC_FAILURE;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (ktype == 2)
|
||||
ecstr = "Private-Key";
|
||||
else if (ktype == 1)
|
||||
|
@ -485,19 +472,21 @@ do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype)
|
|||
EC_GROUP_order_bits(group)) <= 0)
|
||||
goto err;
|
||||
|
||||
if (!ASN1_bn_print(bp, "priv:", priv_key, buffer, off))
|
||||
if (!bn_printf(bp, priv_key, off, "priv:"))
|
||||
goto err;
|
||||
if (!ASN1_bn_print(bp, "pub: ", pub_key, buffer, off))
|
||||
if (!bn_printf(bp, pub_key, off, "pub: "))
|
||||
goto err;
|
||||
if (!ECPKParameters_print(bp, group, off))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
if (!ret)
|
||||
ECerror(reason);
|
||||
BN_free(pub_key);
|
||||
BN_CTX_free(ctx);
|
||||
free(buffer);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue