diff options
author | beck <> | 2017-01-29 17:49:23 +0000 |
---|---|---|
committer | beck <> | 2017-01-29 17:49:23 +0000 |
commit | 957b11334a7afb14537322f0e4795b2e368b3f59 (patch) | |
tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/evp/pmeth_lib.c | |
parent | df96e020e729c6c37a8c7fe311fdd1fe6a8718c5 (diff) | |
download | openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.gz openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.tar.bz2 openbsd-957b11334a7afb14537322f0e4795b2e368b3f59.zip |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'src/lib/libcrypto/evp/pmeth_lib.c')
-rw-r--r-- | src/lib/libcrypto/evp/pmeth_lib.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c index 1d64edcbeb..fc5f4ef91e 100644 --- a/src/lib/libcrypto/evp/pmeth_lib.c +++ b/src/lib/libcrypto/evp/pmeth_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pmeth_lib.c,v 1.12 2017/01/21 04:38:23 jsing Exp $ */ | 1 | /* $OpenBSD: pmeth_lib.c,v 1.13 2017/01/29 17:49:23 beck 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 | */ |
@@ -166,7 +166,7 @@ int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) | |||
166 | /* Try to find an ENGINE which implements this method */ | 166 | /* Try to find an ENGINE which implements this method */ |
167 | if (e) { | 167 | if (e) { |
168 | if (!ENGINE_init(e)) { | 168 | if (!ENGINE_init(e)) { |
169 | EVPerr(EVP_F_INT_CTX_NEW, ERR_R_ENGINE_LIB); | 169 | EVPerror(ERR_R_ENGINE_LIB); |
170 | return NULL; | 170 | return NULL; |
171 | } | 171 | } |
172 | } else | 172 | } else |
@@ -183,7 +183,7 @@ int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) | |||
183 | pmeth = EVP_PKEY_meth_find(id); | 183 | pmeth = EVP_PKEY_meth_find(id); |
184 | 184 | ||
185 | if (pmeth == NULL) { | 185 | if (pmeth == NULL) { |
186 | EVPerr(EVP_F_INT_CTX_NEW, EVP_R_UNSUPPORTED_ALGORITHM); | 186 | EVPerror(EVP_R_UNSUPPORTED_ALGORITHM); |
187 | return NULL; | 187 | return NULL; |
188 | } | 188 | } |
189 | 189 | ||
@@ -193,7 +193,7 @@ int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) | |||
193 | if (e) | 193 | if (e) |
194 | ENGINE_finish(e); | 194 | ENGINE_finish(e); |
195 | #endif | 195 | #endif |
196 | EVPerr(EVP_F_INT_CTX_NEW, ERR_R_MALLOC_FAILURE); | 196 | EVPerror(ERR_R_MALLOC_FAILURE); |
197 | return NULL; | 197 | return NULL; |
198 | } | 198 | } |
199 | ret->engine = e; | 199 | ret->engine = e; |
@@ -336,7 +336,7 @@ EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx) | |||
336 | #ifndef OPENSSL_NO_ENGINE | 336 | #ifndef OPENSSL_NO_ENGINE |
337 | /* Make sure it's safe to copy a pkey context using an ENGINE */ | 337 | /* Make sure it's safe to copy a pkey context using an ENGINE */ |
338 | if (pctx->engine && !ENGINE_init(pctx->engine)) { | 338 | if (pctx->engine && !ENGINE_init(pctx->engine)) { |
339 | EVPerr(EVP_F_EVP_PKEY_CTX_DUP, ERR_R_ENGINE_LIB); | 339 | EVPerror(ERR_R_ENGINE_LIB); |
340 | return 0; | 340 | return 0; |
341 | } | 341 | } |
342 | #endif | 342 | #endif |
@@ -409,26 +409,26 @@ EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, | |||
409 | int ret; | 409 | int ret; |
410 | 410 | ||
411 | if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl) { | 411 | if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl) { |
412 | EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_COMMAND_NOT_SUPPORTED); | 412 | EVPerror(EVP_R_COMMAND_NOT_SUPPORTED); |
413 | return -2; | 413 | return -2; |
414 | } | 414 | } |
415 | if ((keytype != -1) && (ctx->pmeth->pkey_id != keytype)) | 415 | if ((keytype != -1) && (ctx->pmeth->pkey_id != keytype)) |
416 | return -1; | 416 | return -1; |
417 | 417 | ||
418 | if (ctx->operation == EVP_PKEY_OP_UNDEFINED) { | 418 | if (ctx->operation == EVP_PKEY_OP_UNDEFINED) { |
419 | EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_NO_OPERATION_SET); | 419 | EVPerror(EVP_R_NO_OPERATION_SET); |
420 | return -1; | 420 | return -1; |
421 | } | 421 | } |
422 | 422 | ||
423 | if ((optype != -1) && !(ctx->operation & optype)) { | 423 | if ((optype != -1) && !(ctx->operation & optype)) { |
424 | EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_INVALID_OPERATION); | 424 | EVPerror(EVP_R_INVALID_OPERATION); |
425 | return -1; | 425 | return -1; |
426 | } | 426 | } |
427 | 427 | ||
428 | ret = ctx->pmeth->ctrl(ctx, cmd, p1, p2); | 428 | ret = ctx->pmeth->ctrl(ctx, cmd, p1, p2); |
429 | 429 | ||
430 | if (ret == -2) | 430 | if (ret == -2) |
431 | EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_COMMAND_NOT_SUPPORTED); | 431 | EVPerror(EVP_R_COMMAND_NOT_SUPPORTED); |
432 | 432 | ||
433 | return ret; | 433 | return ret; |
434 | 434 | ||
@@ -438,15 +438,13 @@ int | |||
438 | EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *name, const char *value) | 438 | EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *name, const char *value) |
439 | { | 439 | { |
440 | if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl_str) { | 440 | if (!ctx || !ctx->pmeth || !ctx->pmeth->ctrl_str) { |
441 | EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, | 441 | EVPerror(EVP_R_COMMAND_NOT_SUPPORTED); |
442 | EVP_R_COMMAND_NOT_SUPPORTED); | ||
443 | return -2; | 442 | return -2; |
444 | } | 443 | } |
445 | if (!strcmp(name, "digest")) { | 444 | if (!strcmp(name, "digest")) { |
446 | const EVP_MD *md; | 445 | const EVP_MD *md; |
447 | if (!value || !(md = EVP_get_digestbyname(value))) { | 446 | if (!value || !(md = EVP_get_digestbyname(value))) { |
448 | EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, | 447 | EVPerror(EVP_R_INVALID_DIGEST); |
449 | EVP_R_INVALID_DIGEST); | ||
450 | return 0; | 448 | return 0; |
451 | } | 449 | } |
452 | return EVP_PKEY_CTX_set_signature_md(ctx, md); | 450 | return EVP_PKEY_CTX_set_signature_md(ctx, md); |