diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-11-14 10:11:44 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-11-14 10:11:44 +0000 |
commit | 2cc0f187016b686ee098b1e3ae24801d9fd4db0e (patch) | |
tree | f35c7686fbafd28c76ec4759f2e3a619b1a29637 | |
parent | d7b3c49cb9e1a166b75ae7328bd8d697543ef039 (diff) |
eck_prn: shuffle printing functions into a better order
-rw-r--r-- | lib/libcrypto/ec/eck_prn.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/lib/libcrypto/ec/eck_prn.c b/lib/libcrypto/ec/eck_prn.c index 847dc0a159a..e30b8bab0a4 100644 --- a/lib/libcrypto/ec/eck_prn.c +++ b/lib/libcrypto/ec/eck_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eck_prn.c,v 1.31 2024/10/22 12:06:08 tb Exp $ */ +/* $OpenBSD: eck_prn.c,v 1.32 2024/11/14 10:11:43 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -72,21 +72,23 @@ #include "ec_local.h" int -ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) +EC_KEY_print(BIO *bp, const EC_KEY *x, int off) { - BIO *b; - int ret; + EVP_PKEY *pk; + int ret = 0; - if ((b = BIO_new(BIO_s_file())) == NULL) { - ECerror(ERR_R_BUF_LIB); - return (0); - } - BIO_set_fp(b, fp, BIO_NOCLOSE); - ret = ECPKParameters_print(b, x, off); - BIO_free(b); - return (ret); + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) + goto err; + + ret = EVP_PKEY_print_private(bp, pk, off, NULL); + err: + EVP_PKEY_free(pk); + return ret; } -LCRYPTO_ALIAS(ECPKParameters_print_fp); +LCRYPTO_ALIAS(EC_KEY_print); int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) @@ -106,24 +108,7 @@ EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) LCRYPTO_ALIAS(EC_KEY_print_fp); int -ECParameters_print_fp(FILE *fp, const EC_KEY *x) -{ - BIO *b; - int ret; - - if ((b = BIO_new(BIO_s_file())) == NULL) { - ECerror(ERR_R_BIO_LIB); - return (0); - } - BIO_set_fp(b, fp, BIO_NOCLOSE); - ret = ECParameters_print(b, x); - BIO_free(b); - return (ret); -} -LCRYPTO_ALIAS(ECParameters_print_fp); - -int -EC_KEY_print(BIO *bp, const EC_KEY *x, int off) +ECParameters_print(BIO *bp, const EC_KEY *x) { EVP_PKEY *pk; int ret = 0; @@ -134,31 +119,29 @@ EC_KEY_print(BIO *bp, const EC_KEY *x, int off) if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) goto err; - ret = EVP_PKEY_print_private(bp, pk, off, NULL); + ret = EVP_PKEY_print_params(bp, pk, 4, NULL); err: EVP_PKEY_free(pk); return ret; } -LCRYPTO_ALIAS(EC_KEY_print); +LCRYPTO_ALIAS(ECParameters_print); int -ECParameters_print(BIO *bp, const EC_KEY *x) +ECParameters_print_fp(FILE *fp, const EC_KEY *x) { - EVP_PKEY *pk; - int ret = 0; - - if ((pk = EVP_PKEY_new()) == NULL) - goto err; - - if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) - goto err; + BIO *b; + int ret; - ret = EVP_PKEY_print_params(bp, pk, 4, NULL); - err: - EVP_PKEY_free(pk); - return ret; + if ((b = BIO_new(BIO_s_file())) == NULL) { + ECerror(ERR_R_BIO_LIB); + return (0); + } + BIO_set_fp(b, fp, BIO_NOCLOSE); + ret = ECParameters_print(b, x); + BIO_free(b); + return (ret); } -LCRYPTO_ALIAS(ECParameters_print); +LCRYPTO_ALIAS(ECParameters_print_fp); static int ecpk_print_asn1_parameters(BIO *bp, const EC_GROUP *group, int off) @@ -337,3 +320,20 @@ ECPKParameters_print(BIO *bp, const EC_GROUP *group, int off) return ecpk_print_explicit_parameters(bp, group, off); } LCRYPTO_ALIAS(ECPKParameters_print); + +int +ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) +{ + BIO *b; + int ret; + + if ((b = BIO_new(BIO_s_file())) == NULL) { + ECerror(ERR_R_BUF_LIB); + return (0); + } + BIO_set_fp(b, fp, BIO_NOCLOSE); + ret = ECPKParameters_print(b, x, off); + BIO_free(b); + return (ret); +} +LCRYPTO_ALIAS(ECPKParameters_print_fp); |