diff options
| author | tb <> | 2024-11-14 10:11:43 +0000 |
|---|---|---|
| committer | tb <> | 2024-11-14 10:11:43 +0000 |
| commit | 99d66d57856f34362a5acfdd54edeb0205179d4f (patch) | |
| tree | c30e2c35ea182d30ed156a1067bc4bfd2b0bb3aa /src | |
| parent | d8e54cade97b8f765d30971932b197d0f67e46a3 (diff) | |
| download | openbsd-99d66d57856f34362a5acfdd54edeb0205179d4f.tar.gz openbsd-99d66d57856f34362a5acfdd54edeb0205179d4f.tar.bz2 openbsd-99d66d57856f34362a5acfdd54edeb0205179d4f.zip | |
eck_prn: shuffle printing functions into a better order
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/eck_prn.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/lib/libcrypto/ec/eck_prn.c b/src/lib/libcrypto/ec/eck_prn.c index 847dc0a159..e30b8bab0a 100644 --- a/src/lib/libcrypto/ec/eck_prn.c +++ b/src/lib/libcrypto/ec/eck_prn.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: eck_prn.c,v 1.31 2024/10/22 12:06:08 tb Exp $ */ | 1 | /* $OpenBSD: eck_prn.c,v 1.32 2024/11/14 10:11:43 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -72,21 +72,23 @@ | |||
| 72 | #include "ec_local.h" | 72 | #include "ec_local.h" |
| 73 | 73 | ||
| 74 | int | 74 | int |
| 75 | ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) | 75 | EC_KEY_print(BIO *bp, const EC_KEY *x, int off) |
| 76 | { | 76 | { |
| 77 | BIO *b; | 77 | EVP_PKEY *pk; |
| 78 | int ret; | 78 | int ret = 0; |
| 79 | 79 | ||
| 80 | if ((b = BIO_new(BIO_s_file())) == NULL) { | 80 | if ((pk = EVP_PKEY_new()) == NULL) |
| 81 | ECerror(ERR_R_BUF_LIB); | 81 | goto err; |
| 82 | return (0); | 82 | |
| 83 | } | 83 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) |
| 84 | BIO_set_fp(b, fp, BIO_NOCLOSE); | 84 | goto err; |
| 85 | ret = ECPKParameters_print(b, x, off); | 85 | |
| 86 | BIO_free(b); | 86 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); |
| 87 | return (ret); | 87 | err: |
| 88 | EVP_PKEY_free(pk); | ||
| 89 | return ret; | ||
| 88 | } | 90 | } |
| 89 | LCRYPTO_ALIAS(ECPKParameters_print_fp); | 91 | LCRYPTO_ALIAS(EC_KEY_print); |
| 90 | 92 | ||
| 91 | int | 93 | int |
| 92 | EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) | 94 | 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) | |||
| 106 | LCRYPTO_ALIAS(EC_KEY_print_fp); | 108 | LCRYPTO_ALIAS(EC_KEY_print_fp); |
| 107 | 109 | ||
| 108 | int | 110 | int |
| 109 | ECParameters_print_fp(FILE *fp, const EC_KEY *x) | 111 | ECParameters_print(BIO *bp, const EC_KEY *x) |
| 110 | { | ||
| 111 | BIO *b; | ||
| 112 | int ret; | ||
| 113 | |||
| 114 | if ((b = BIO_new(BIO_s_file())) == NULL) { | ||
| 115 | ECerror(ERR_R_BIO_LIB); | ||
| 116 | return (0); | ||
| 117 | } | ||
| 118 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
| 119 | ret = ECParameters_print(b, x); | ||
| 120 | BIO_free(b); | ||
| 121 | return (ret); | ||
| 122 | } | ||
| 123 | LCRYPTO_ALIAS(ECParameters_print_fp); | ||
| 124 | |||
| 125 | int | ||
| 126 | EC_KEY_print(BIO *bp, const EC_KEY *x, int off) | ||
| 127 | { | 112 | { |
| 128 | EVP_PKEY *pk; | 113 | EVP_PKEY *pk; |
| 129 | int ret = 0; | 114 | int ret = 0; |
| @@ -134,31 +119,29 @@ EC_KEY_print(BIO *bp, const EC_KEY *x, int off) | |||
| 134 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | 119 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) |
| 135 | goto err; | 120 | goto err; |
| 136 | 121 | ||
| 137 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); | 122 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); |
| 138 | err: | 123 | err: |
| 139 | EVP_PKEY_free(pk); | 124 | EVP_PKEY_free(pk); |
| 140 | return ret; | 125 | return ret; |
| 141 | } | 126 | } |
| 142 | LCRYPTO_ALIAS(EC_KEY_print); | 127 | LCRYPTO_ALIAS(ECParameters_print); |
| 143 | 128 | ||
| 144 | int | 129 | int |
| 145 | ECParameters_print(BIO *bp, const EC_KEY *x) | 130 | ECParameters_print_fp(FILE *fp, const EC_KEY *x) |
| 146 | { | 131 | { |
| 147 | EVP_PKEY *pk; | 132 | BIO *b; |
| 148 | int ret = 0; | 133 | int ret; |
| 149 | |||
| 150 | if ((pk = EVP_PKEY_new()) == NULL) | ||
| 151 | goto err; | ||
| 152 | |||
| 153 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | ||
| 154 | goto err; | ||
| 155 | 134 | ||
| 156 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); | 135 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
| 157 | err: | 136 | ECerror(ERR_R_BIO_LIB); |
| 158 | EVP_PKEY_free(pk); | 137 | return (0); |
| 159 | return ret; | 138 | } |
| 139 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
| 140 | ret = ECParameters_print(b, x); | ||
| 141 | BIO_free(b); | ||
| 142 | return (ret); | ||
| 160 | } | 143 | } |
| 161 | LCRYPTO_ALIAS(ECParameters_print); | 144 | LCRYPTO_ALIAS(ECParameters_print_fp); |
| 162 | 145 | ||
| 163 | static int | 146 | static int |
| 164 | ecpk_print_asn1_parameters(BIO *bp, const EC_GROUP *group, int off) | 147 | 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) | |||
| 337 | return ecpk_print_explicit_parameters(bp, group, off); | 320 | return ecpk_print_explicit_parameters(bp, group, off); |
| 338 | } | 321 | } |
| 339 | LCRYPTO_ALIAS(ECPKParameters_print); | 322 | LCRYPTO_ALIAS(ECPKParameters_print); |
| 323 | |||
| 324 | int | ||
| 325 | ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) | ||
| 326 | { | ||
| 327 | BIO *b; | ||
| 328 | int ret; | ||
| 329 | |||
| 330 | if ((b = BIO_new(BIO_s_file())) == NULL) { | ||
| 331 | ECerror(ERR_R_BUF_LIB); | ||
| 332 | return (0); | ||
| 333 | } | ||
| 334 | BIO_set_fp(b, fp, BIO_NOCLOSE); | ||
| 335 | ret = ECPKParameters_print(b, x, off); | ||
| 336 | BIO_free(b); | ||
| 337 | return (ret); | ||
| 338 | } | ||
| 339 | LCRYPTO_ALIAS(ECPKParameters_print_fp); | ||
