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_ameth.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_ameth.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_ameth.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c index 8e15e3f535..813c634f31 100644 --- a/src/lib/libcrypto/rsa/rsa_ameth.c +++ b/src/lib/libcrypto/rsa/rsa_ameth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_ameth.c,v 1.7 2014/07/09 08:20:08 miod Exp $ */ | 1 | /* $OpenBSD: rsa_ameth.c,v 1.8 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 |
@@ -104,8 +104,8 @@ rsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | |||
104 | static int | 104 | static int |
105 | rsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) | 105 | rsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) |
106 | { | 106 | { |
107 | if (BN_cmp(b->pkey.rsa->n,a->pkey.rsa->n) != 0 || | 107 | if (BN_cmp(b->pkey.rsa->n, a->pkey.rsa->n) != 0 || |
108 | BN_cmp(b->pkey.rsa->e,a->pkey.rsa->e) != 0) | 108 | BN_cmp(b->pkey.rsa->e, a->pkey.rsa->e) != 0) |
109 | return 0; | 109 | return 0; |
110 | return 1; | 110 | return 1; |
111 | } | 111 | } |
@@ -256,7 +256,7 @@ do_rsa_print(BIO *bp, const RSA *x, int off, int priv) | |||
256 | ret = 1; | 256 | ret = 1; |
257 | err: | 257 | err: |
258 | free(m); | 258 | free(m); |
259 | return(ret); | 259 | return (ret); |
260 | } | 260 | } |
261 | 261 | ||
262 | static int | 262 | static int |
@@ -282,13 +282,14 @@ rsa_pss_decode(const X509_ALGOR *alg, X509_ALGOR **pmaskHash) | |||
282 | 282 | ||
283 | if (!alg->parameter || alg->parameter->type != V_ASN1_SEQUENCE) | 283 | if (!alg->parameter || alg->parameter->type != V_ASN1_SEQUENCE) |
284 | return NULL; | 284 | return NULL; |
285 | |||
285 | p = alg->parameter->value.sequence->data; | 286 | p = alg->parameter->value.sequence->data; |
286 | plen = alg->parameter->value.sequence->length; | 287 | plen = alg->parameter->value.sequence->length; |
287 | pss = d2i_RSA_PSS_PARAMS(NULL, &p, plen); | 288 | pss = d2i_RSA_PSS_PARAMS(NULL, &p, plen); |
288 | 289 | ||
289 | if (!pss) | 290 | if (!pss) |
290 | return NULL; | 291 | return NULL; |
291 | 292 | ||
292 | if (pss->maskGenAlgorithm) { | 293 | if (pss->maskGenAlgorithm) { |
293 | ASN1_TYPE *param = pss->maskGenAlgorithm->parameter; | 294 | ASN1_TYPE *param = pss->maskGenAlgorithm->parameter; |
294 | if (OBJ_obj2nid(pss->maskGenAlgorithm->algorithm) == NID_mgf1 && | 295 | if (OBJ_obj2nid(pss->maskGenAlgorithm->algorithm) == NID_mgf1 && |
@@ -351,7 +352,7 @@ rsa_pss_param_print(BIO *bp, RSA_PSS_PARAMS *pss, X509_ALGOR *maskHash, | |||
351 | if (!BIO_indent(bp, indent, 128)) | 352 | if (!BIO_indent(bp, indent, 128)) |
352 | goto err; | 353 | goto err; |
353 | if (BIO_puts(bp, "Salt Length: 0x") <= 0) | 354 | if (BIO_puts(bp, "Salt Length: 0x") <= 0) |
354 | goto err; | 355 | goto err; |
355 | if (pss->saltLength) { | 356 | if (pss->saltLength) { |
356 | if (i2a_ASN1_INTEGER(bp, pss->saltLength) <= 0) | 357 | if (i2a_ASN1_INTEGER(bp, pss->saltLength) <= 0) |
357 | goto err; | 358 | goto err; |
@@ -369,7 +370,7 @@ rsa_pss_param_print(BIO *bp, RSA_PSS_PARAMS *pss, X509_ALGOR *maskHash, | |||
369 | } else if (BIO_puts(bp, "BC (default)") <= 0) | 370 | } else if (BIO_puts(bp, "BC (default)") <= 0) |
370 | goto err; | 371 | goto err; |
371 | BIO_puts(bp, "\n"); | 372 | BIO_puts(bp, "\n"); |
372 | 373 | ||
373 | rv = 1; | 374 | rv = 1; |
374 | 375 | ||
375 | err: | 376 | err: |
@@ -403,6 +404,7 @@ static int | |||
403 | rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | 404 | rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) |
404 | { | 405 | { |
405 | X509_ALGOR *alg = NULL; | 406 | X509_ALGOR *alg = NULL; |
407 | |||
406 | switch (op) { | 408 | switch (op) { |
407 | case ASN1_PKEY_CTRL_PKCS7_SIGN: | 409 | case ASN1_PKEY_CTRL_PKCS7_SIGN: |
408 | if (arg1 == 0) | 410 | if (arg1 == 0) |
@@ -422,7 +424,7 @@ rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | |||
422 | case ASN1_PKEY_CTRL_CMS_ENVELOPE: | 424 | case ASN1_PKEY_CTRL_CMS_ENVELOPE: |
423 | if (arg1 == 0) | 425 | if (arg1 == 0) |
424 | CMS_RecipientInfo_ktri_get0_algs(arg2, NULL, NULL, &alg); | 426 | CMS_RecipientInfo_ktri_get0_algs(arg2, NULL, NULL, &alg); |
425 | break; | 427 | break; |
426 | #endif | 428 | #endif |
427 | 429 | ||
428 | case ASN1_PKEY_CTRL_DEFAULT_MD_NID: | 430 | case ASN1_PKEY_CTRL_DEFAULT_MD_NID: |
@@ -440,8 +442,8 @@ rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | |||
440 | return 1; | 442 | return 1; |
441 | } | 443 | } |
442 | 444 | ||
443 | /* Customised RSA item verification routine. This is called | 445 | /* Customised RSA item verification routine. This is called |
444 | * when a signature is encountered requiring special handling. We | 446 | * when a signature is encountered requiring special handling. We |
445 | * currently only handle PSS. | 447 | * currently only handle PSS. |
446 | */ | 448 | */ |
447 | static int | 449 | static int |
@@ -460,6 +462,7 @@ rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |||
460 | RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNSUPPORTED_SIGNATURE_TYPE); | 462 | RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNSUPPORTED_SIGNATURE_TYPE); |
461 | return -1; | 463 | return -1; |
462 | } | 464 | } |
465 | |||
463 | /* Decode PSS parameters */ | 466 | /* Decode PSS parameters */ |
464 | pss = rsa_pss_decode(sigalg, &maskHash); | 467 | pss = rsa_pss_decode(sigalg, &maskHash); |
465 | 468 | ||
@@ -544,7 +547,7 @@ err: | |||
544 | 547 | ||
545 | static int | 548 | static int |
546 | rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | 549 | rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, |
547 | X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig) | 550 | X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig) |
548 | { | 551 | { |
549 | int pad_mode; | 552 | int pad_mode; |
550 | EVP_PKEY_CTX *pkctx = ctx->pctx; | 553 | EVP_PKEY_CTX *pkctx = ctx->pctx; |