diff options
Diffstat (limited to 'src/lib/libcrypto/evp/pmeth_fn.c')
| -rw-r--r-- | src/lib/libcrypto/evp/pmeth_fn.c | 42 |
1 files changed, 14 insertions, 28 deletions
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 | ||
