diff options
author | jsing <> | 2014-07-09 19:51:38 +0000 |
---|---|---|
committer | jsing <> | 2014-07-09 19:51:38 +0000 |
commit | 912aa7ccdb6d6bc2bd2f8d06dccbb387e2e136cd (patch) | |
tree | b95d623ff1b12a60bca71b907401534e927f713b /src/lib/libcrypto/rsa/rsa_pmeth.c | |
parent | 5155b53399b3cd5c9947109652d415d6dcc6ce1d (diff) | |
download | openbsd-912aa7ccdb6d6bc2bd2f8d06dccbb387e2e136cd.tar.gz openbsd-912aa7ccdb6d6bc2bd2f8d06dccbb387e2e136cd.tar.bz2 openbsd-912aa7ccdb6d6bc2bd2f8d06dccbb387e2e136cd.zip |
More KNF.
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_pmeth.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_pmeth.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c index 4a662c2894..f35b5800ab 100644 --- a/src/lib/libcrypto/rsa/rsa_pmeth.c +++ b/src/lib/libcrypto/rsa/rsa_pmeth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_pmeth.c,v 1.9 2014/07/09 08:20:08 miod Exp $ */ | 1 | /* $OpenBSD: rsa_pmeth.c,v 1.10 2014/07/09 19:51:38 jsing 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 | */ |
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -110,7 +110,7 @@ pkey_rsa_init(EVP_PKEY_CTX *ctx) | |||
110 | ctx->data = rctx; | 110 | ctx->data = rctx; |
111 | ctx->keygen_info = rctx->gentmp; | 111 | ctx->keygen_info = rctx->gentmp; |
112 | ctx->keygen_info_count = 2; | 112 | ctx->keygen_info_count = 2; |
113 | 113 | ||
114 | return 1; | 114 | return 1; |
115 | } | 115 | } |
116 | 116 | ||
@@ -121,7 +121,7 @@ pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) | |||
121 | 121 | ||
122 | if (!pkey_rsa_init(dst)) | 122 | if (!pkey_rsa_init(dst)) |
123 | return 0; | 123 | return 0; |
124 | sctx = src->data; | 124 | sctx = src->data; |
125 | dctx = dst->data; | 125 | dctx = dst->data; |
126 | dctx->nbits = sctx->nbits; | 126 | dctx->nbits = sctx->nbits; |
127 | if (sctx->pub_exp) { | 127 | if (sctx->pub_exp) { |
@@ -236,7 +236,7 @@ pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, | |||
236 | return 0; | 236 | return 0; |
237 | ret--; | 237 | ret--; |
238 | if (rctx->tbuf[ret] != | 238 | if (rctx->tbuf[ret] != |
239 | RSA_X931_hash_id(EVP_MD_type(rctx->md))) { | 239 | RSA_X931_hash_id(EVP_MD_type(rctx->md))) { |
240 | RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER, | 240 | RSAerr(RSA_F_PKEY_RSA_VERIFYRECOVER, |
241 | RSA_R_ALGORITHM_MISMATCH); | 241 | RSA_R_ALGORITHM_MISMATCH); |
242 | return 0; | 242 | return 0; |
@@ -371,6 +371,7 @@ static int | |||
371 | pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) | 371 | pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) |
372 | { | 372 | { |
373 | RSA_PKEY_CTX *rctx = ctx->data; | 373 | RSA_PKEY_CTX *rctx = ctx->data; |
374 | |||
374 | switch (type) { | 375 | switch (type) { |
375 | case EVP_PKEY_CTRL_RSA_PADDING: | 376 | case EVP_PKEY_CTRL_RSA_PADDING: |
376 | if (p1 >= RSA_PKCS1_PADDING && p1 <= RSA_PKCS1_PSS_PADDING) { | 377 | if (p1 >= RSA_PKCS1_PADDING && p1 <= RSA_PKCS1_PSS_PADDING) { |
@@ -458,17 +459,18 @@ bad_pad: | |||
458 | return 1; | 459 | return 1; |
459 | #ifndef OPENSSL_NO_CMS | 460 | #ifndef OPENSSL_NO_CMS |
460 | case EVP_PKEY_CTRL_CMS_DECRYPT: | 461 | case EVP_PKEY_CTRL_CMS_DECRYPT: |
461 | { | 462 | { |
462 | X509_ALGOR *alg = NULL; | 463 | X509_ALGOR *alg = NULL; |
463 | ASN1_OBJECT *encalg = NULL; | 464 | ASN1_OBJECT *encalg = NULL; |
464 | 465 | ||
465 | if (p2) | 466 | if (p2) |
466 | CMS_RecipientInfo_ktri_get0_algs(p2, NULL, NULL, &alg); | 467 | CMS_RecipientInfo_ktri_get0_algs(p2, NULL, |
467 | if (alg) | 468 | NULL, &alg); |
468 | X509_ALGOR_get0(&encalg, NULL, NULL, alg); | 469 | if (alg) |
469 | if (encalg && OBJ_obj2nid(encalg) == NID_rsaesOaep) | 470 | X509_ALGOR_get0(&encalg, NULL, NULL, alg); |
470 | rctx->pad_mode = RSA_PKCS1_OAEP_PADDING; | 471 | if (encalg && OBJ_obj2nid(encalg) == NID_rsaesOaep) |
471 | } | 472 | rctx->pad_mode = RSA_PKCS1_OAEP_PADDING; |
473 | } | ||
472 | /* FALLTHROUGH */ | 474 | /* FALLTHROUGH */ |
473 | 475 | ||
474 | case EVP_PKEY_CTRL_CMS_ENCRYPT: | 476 | case EVP_PKEY_CTRL_CMS_ENCRYPT: |
@@ -477,18 +479,18 @@ bad_pad: | |||
477 | #endif | 479 | #endif |
478 | case EVP_PKEY_CTRL_PEER_KEY: | 480 | case EVP_PKEY_CTRL_PEER_KEY: |
479 | RSAerr(RSA_F_PKEY_RSA_CTRL, | 481 | RSAerr(RSA_F_PKEY_RSA_CTRL, |
480 | RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); | 482 | RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); |
481 | return -2; | 483 | return -2; |
482 | 484 | ||
483 | default: | 485 | default: |
484 | return -2; | 486 | return -2; |
485 | } | 487 | } |
486 | } | 488 | } |
487 | 489 | ||
488 | static int | 490 | static int |
489 | pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) | 491 | pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) |
490 | { | 492 | { |
491 | long lval; | 493 | long lval; |
492 | char *ep; | 494 | char *ep; |
493 | 495 | ||
494 | if (!value) { | 496 | if (!value) { |