diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/evp/evp_local.h | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/pmeth_fn.c | 42 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/pmeth_gn.c | 28 |
3 files changed, 24 insertions, 53 deletions
diff --git a/src/lib/libcrypto/evp/evp_local.h b/src/lib/libcrypto/evp/evp_local.h index b1c0c9b14e..9631992a28 100644 --- a/src/lib/libcrypto/evp/evp_local.h +++ b/src/lib/libcrypto/evp/evp_local.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: evp_local.h,v 1.21 2024/03/26 01:41:06 tb Exp $ */ | 1 | /* $OpenBSD: evp_local.h,v 1.22 2024/04/12 09:41:39 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -283,10 +283,8 @@ struct evp_pkey_method_st { | |||
283 | int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); | 283 | int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); |
284 | void (*cleanup)(EVP_PKEY_CTX *ctx); | 284 | void (*cleanup)(EVP_PKEY_CTX *ctx); |
285 | 285 | ||
286 | int (*paramgen_init)(EVP_PKEY_CTX *ctx); | ||
287 | int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); | 286 | int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); |
288 | 287 | ||
289 | int (*keygen_init)(EVP_PKEY_CTX *ctx); | ||
290 | int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); | 288 | int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); |
291 | 289 | ||
292 | int (*sign_init)(EVP_PKEY_CTX *ctx); | 290 | int (*sign_init)(EVP_PKEY_CTX *ctx); |
@@ -298,7 +296,6 @@ struct evp_pkey_method_st { | |||
298 | const unsigned char *sig, size_t siglen, | 296 | const unsigned char *sig, size_t siglen, |
299 | const unsigned char *tbs, size_t tbslen); | 297 | const unsigned char *tbs, size_t tbslen); |
300 | 298 | ||
301 | int (*verify_recover_init)(EVP_PKEY_CTX *ctx); | ||
302 | int (*verify_recover)(EVP_PKEY_CTX *ctx, | 299 | int (*verify_recover)(EVP_PKEY_CTX *ctx, |
303 | unsigned char *rout, size_t *routlen, | 300 | unsigned char *rout, size_t *routlen, |
304 | const unsigned char *sig, size_t siglen); | 301 | const unsigned char *sig, size_t siglen); |
@@ -307,11 +304,9 @@ struct evp_pkey_method_st { | |||
307 | int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | 304 | int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, |
308 | EVP_MD_CTX *mctx); | 305 | EVP_MD_CTX *mctx); |
309 | 306 | ||
310 | int (*encrypt_init)(EVP_PKEY_CTX *ctx); | ||
311 | int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, | 307 | int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, |
312 | const unsigned char *in, size_t inlen); | 308 | const unsigned char *in, size_t inlen); |
313 | 309 | ||
314 | int (*decrypt_init)(EVP_PKEY_CTX *ctx); | ||
315 | int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, | 310 | int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, |
316 | const unsigned char *in, size_t inlen); | 311 | const unsigned char *in, size_t inlen); |
317 | 312 | ||
diff --git a/src/lib/libcrypto/evp/pmeth_fn.c b/src/lib/libcrypto/evp/pmeth_fn.c index f8ed555fda..308c434f0d 100644 --- a/src/lib/libcrypto/evp/pmeth_fn.c +++ b/src/lib/libcrypto/evp/pmeth_fn.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pmeth_fn.c,v 1.10 2024/04/09 13:52:41 beck Exp $ */ | 1 | /* $OpenBSD: pmeth_fn.c,v 1.11 2024/04/12 09:41:39 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2006. | 3 | * project 2006. |
4 | */ | 4 | */ |
@@ -155,19 +155,15 @@ LCRYPTO_ALIAS(EVP_PKEY_verify); | |||
155 | int | 155 | int |
156 | EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx) | 156 | EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx) |
157 | { | 157 | { |
158 | int ret; | 158 | if (ctx == NULL || ctx->pmeth == NULL || |
159 | 159 | ctx->pmeth->verify_recover == NULL) { | |
160 | if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover) { | ||
161 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); | 160 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); |
162 | return -2; | 161 | return -2; |
163 | } | 162 | } |
163 | |||
164 | ctx->operation = EVP_PKEY_OP_VERIFYRECOVER; | 164 | ctx->operation = EVP_PKEY_OP_VERIFYRECOVER; |
165 | if (!ctx->pmeth->verify_recover_init) | 165 | |
166 | return 1; | 166 | return 1; |
167 | ret = ctx->pmeth->verify_recover_init(ctx); | ||
168 | if (ret <= 0) | ||
169 | ctx->operation = EVP_PKEY_OP_UNDEFINED; | ||
170 | return ret; | ||
171 | } | 167 | } |
172 | LCRYPTO_ALIAS(EVP_PKEY_verify_recover_init); | 168 | LCRYPTO_ALIAS(EVP_PKEY_verify_recover_init); |
173 | 169 | ||
@@ -191,19 +187,14 @@ LCRYPTO_ALIAS(EVP_PKEY_verify_recover); | |||
191 | int | 187 | int |
192 | EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx) | 188 | EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx) |
193 | { | 189 | { |
194 | int ret; | 190 | if (ctx == NULL || ctx->pmeth == NULL || ctx->pmeth->encrypt == NULL) { |
195 | |||
196 | if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt) { | ||
197 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); | 191 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); |
198 | return -2; | 192 | return -2; |
199 | } | 193 | } |
194 | |||
200 | ctx->operation = EVP_PKEY_OP_ENCRYPT; | 195 | ctx->operation = EVP_PKEY_OP_ENCRYPT; |
201 | if (!ctx->pmeth->encrypt_init) | 196 | |
202 | return 1; | 197 | return 1; |
203 | ret = ctx->pmeth->encrypt_init(ctx); | ||
204 | if (ret <= 0) | ||
205 | ctx->operation = EVP_PKEY_OP_UNDEFINED; | ||
206 | return ret; | ||
207 | } | 198 | } |
208 | LCRYPTO_ALIAS(EVP_PKEY_encrypt_init); | 199 | LCRYPTO_ALIAS(EVP_PKEY_encrypt_init); |
209 | 200 | ||
@@ -227,19 +218,14 @@ LCRYPTO_ALIAS(EVP_PKEY_encrypt); | |||
227 | int | 218 | int |
228 | EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx) | 219 | EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx) |
229 | { | 220 | { |
230 | int ret; | 221 | if (ctx == NULL || ctx->pmeth == NULL || ctx->pmeth->decrypt == NULL) { |
231 | |||
232 | if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) { | ||
233 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); | 222 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); |
234 | return -2; | 223 | return -2; |
235 | } | 224 | } |
225 | |||
236 | ctx->operation = EVP_PKEY_OP_DECRYPT; | 226 | ctx->operation = EVP_PKEY_OP_DECRYPT; |
237 | if (!ctx->pmeth->decrypt_init) | 227 | |
238 | return 1; | 228 | return 1; |
239 | ret = ctx->pmeth->decrypt_init(ctx); | ||
240 | if (ret <= 0) | ||
241 | ctx->operation = EVP_PKEY_OP_UNDEFINED; | ||
242 | return ret; | ||
243 | } | 229 | } |
244 | LCRYPTO_ALIAS(EVP_PKEY_decrypt_init); | 230 | LCRYPTO_ALIAS(EVP_PKEY_decrypt_init); |
245 | 231 | ||
diff --git a/src/lib/libcrypto/evp/pmeth_gn.c b/src/lib/libcrypto/evp/pmeth_gn.c index b86ecc6811..b8b51ced3d 100644 --- a/src/lib/libcrypto/evp/pmeth_gn.c +++ b/src/lib/libcrypto/evp/pmeth_gn.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pmeth_gn.c,v 1.17 2024/04/12 02:56:15 tb Exp $ */ | 1 | /* $OpenBSD: pmeth_gn.c,v 1.18 2024/04/12 09:41:39 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2006. | 3 | * project 2006. |
4 | */ | 4 | */ |
@@ -71,19 +71,14 @@ | |||
71 | int | 71 | int |
72 | EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx) | 72 | EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx) |
73 | { | 73 | { |
74 | int ret; | 74 | if (ctx == NULL || ctx->pmeth == NULL || ctx->pmeth->paramgen == NULL) { |
75 | |||
76 | if (!ctx || !ctx->pmeth || !ctx->pmeth->paramgen) { | ||
77 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); | 75 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); |
78 | return -2; | 76 | return -2; |
79 | } | 77 | } |
78 | |||
80 | ctx->operation = EVP_PKEY_OP_PARAMGEN; | 79 | ctx->operation = EVP_PKEY_OP_PARAMGEN; |
81 | if (!ctx->pmeth->paramgen_init) | 80 | |
82 | return 1; | 81 | return 1; |
83 | ret = ctx->pmeth->paramgen_init(ctx); | ||
84 | if (ret <= 0) | ||
85 | ctx->operation = EVP_PKEY_OP_UNDEFINED; | ||
86 | return ret; | ||
87 | } | 82 | } |
88 | LCRYPTO_ALIAS(EVP_PKEY_paramgen_init); | 83 | LCRYPTO_ALIAS(EVP_PKEY_paramgen_init); |
89 | 84 | ||
@@ -120,19 +115,14 @@ LCRYPTO_ALIAS(EVP_PKEY_paramgen); | |||
120 | int | 115 | int |
121 | EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx) | 116 | EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx) |
122 | { | 117 | { |
123 | int ret; | 118 | if (ctx == NULL || ctx->pmeth == NULL || ctx->pmeth->keygen == NULL) { |
124 | |||
125 | if (!ctx || !ctx->pmeth || !ctx->pmeth->keygen) { | ||
126 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); | 119 | EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); |
127 | return -2; | 120 | return -2; |
128 | } | 121 | } |
122 | |||
129 | ctx->operation = EVP_PKEY_OP_KEYGEN; | 123 | ctx->operation = EVP_PKEY_OP_KEYGEN; |
130 | if (!ctx->pmeth->keygen_init) | 124 | |
131 | return 1; | 125 | return 1; |
132 | ret = ctx->pmeth->keygen_init(ctx); | ||
133 | if (ret <= 0) | ||
134 | ctx->operation = EVP_PKEY_OP_UNDEFINED; | ||
135 | return ret; | ||
136 | } | 126 | } |
137 | LCRYPTO_ALIAS(EVP_PKEY_keygen_init); | 127 | LCRYPTO_ALIAS(EVP_PKEY_keygen_init); |
138 | 128 | ||