summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-11-14 10:11:43 +0000
committertb <>2024-11-14 10:11:43 +0000
commit9919e862a068e33660e015b9e612aa23baa7bdb0 (patch)
treec30e2c35ea182d30ed156a1067bc4bfd2b0bb3aa /src/lib
parentd2c652739f18510504765da19ffa9ecbe9939a26 (diff)
downloadopenbsd-9919e862a068e33660e015b9e612aa23baa7bdb0.tar.gz
openbsd-9919e862a068e33660e015b9e612aa23baa7bdb0.tar.bz2
openbsd-9919e862a068e33660e015b9e612aa23baa7bdb0.zip
eck_prn: shuffle printing functions into a better order
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ec/eck_prn.c94
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
74int 74int
75ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) 75EC_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}
89LCRYPTO_ALIAS(ECPKParameters_print_fp); 91LCRYPTO_ALIAS(EC_KEY_print);
90 92
91int 93int
92EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) 94EC_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)
106LCRYPTO_ALIAS(EC_KEY_print_fp); 108LCRYPTO_ALIAS(EC_KEY_print_fp);
107 109
108int 110int
109ECParameters_print_fp(FILE *fp, const EC_KEY *x) 111ECParameters_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}
123LCRYPTO_ALIAS(ECParameters_print_fp);
124
125int
126EC_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}
142LCRYPTO_ALIAS(EC_KEY_print); 127LCRYPTO_ALIAS(ECParameters_print);
143 128
144int 129int
145ECParameters_print(BIO *bp, const EC_KEY *x) 130ECParameters_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}
161LCRYPTO_ALIAS(ECParameters_print); 144LCRYPTO_ALIAS(ECParameters_print_fp);
162 145
163static int 146static int
164ecpk_print_asn1_parameters(BIO *bp, const EC_GROUP *group, int off) 147ecpk_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}
339LCRYPTO_ALIAS(ECPKParameters_print); 322LCRYPTO_ALIAS(ECPKParameters_print);
323
324int
325ECPKParameters_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}
339LCRYPTO_ALIAS(ECPKParameters_print_fp);