summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-01-10 14:59:19 +0000
committertb <>2024-01-10 14:59:19 +0000
commitfbef5c2170a79b6796e612aabcc265b143bfa91e (patch)
tree552cef0c7a228903101cb0b5808d8fc672da1c1b /src/lib
parentfef73867fcbc2519f78d60048c4735f3819ea1f3 (diff)
downloadopenbsd-fbef5c2170a79b6796e612aabcc265b143bfa91e.tar.gz
openbsd-fbef5c2170a79b6796e612aabcc265b143bfa91e.tar.bz2
openbsd-fbef5c2170a79b6796e612aabcc265b143bfa91e.zip
Inline rsa_is_pss() and rsa_pkey_is_pss()
It's more explicit and not that much longer. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/rsa/rsa_ameth.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c
index b8957c0d1c..0c351f49ef 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.56 2024/01/04 17:01:26 tb Exp $ */ 1/* $OpenBSD: rsa_ameth.c,v 1.57 2024/01/10 14:59:19 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 */
@@ -74,10 +74,6 @@
74#include "rsa_local.h" 74#include "rsa_local.h"
75#include "x509_local.h" 75#include "x509_local.h"
76 76
77/* Macros to test if a pkey or ctx is for a PSS key */
78#define pkey_is_pss(pkey) (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
79#define pkey_ctx_is_pss(ctx) (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS)
80
81#ifndef OPENSSL_NO_CMS 77#ifndef OPENSSL_NO_CMS
82static int rsa_cms_sign(CMS_SignerInfo *si); 78static int rsa_cms_sign(CMS_SignerInfo *si);
83static int rsa_cms_verify(CMS_SignerInfo *si); 79static int rsa_cms_verify(CMS_SignerInfo *si);
@@ -453,7 +449,8 @@ pkey_rsa_print(BIO *bp, const EVP_PKEY *pkey, int off, int priv)
453 if (!BIO_indent(bp, off, 128)) 449 if (!BIO_indent(bp, off, 128))
454 goto err; 450 goto err;
455 451
456 if (BIO_printf(bp, "%s ", pkey_is_pss(pkey) ? "RSA-PSS" : "RSA") <= 0) 452 if (BIO_printf(bp, "%s ",
453 pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS ? "RSA-PSS" : "RSA") <= 0)
457 goto err; 454 goto err;
458 455
459 if (priv && x->d != NULL) { 456 if (priv && x->d != NULL) {
@@ -485,7 +482,8 @@ pkey_rsa_print(BIO *bp, const EVP_PKEY *pkey, int off, int priv)
485 if (!bn_printf(bp, x->iqmp, off, "coefficient:")) 482 if (!bn_printf(bp, x->iqmp, off, "coefficient:"))
486 goto err; 483 goto err;
487 } 484 }
488 if (pkey_is_pss(pkey) && !rsa_pss_param_print(bp, 1, x->pss, off)) 485 if (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS &&
486 !rsa_pss_param_print(bp, 1, x->pss, off))
489 goto err; 487 goto err;
490 ret = 1; 488 ret = 1;
491 err: 489 err:
@@ -539,7 +537,7 @@ rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
539 break; 537 break;
540 538
541 case ASN1_PKEY_CTRL_PKCS7_ENCRYPT: 539 case ASN1_PKEY_CTRL_PKCS7_ENCRYPT:
542 if (pkey_is_pss(pkey)) 540 if (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
543 return -2; 541 return -2;
544 if (arg1 == 0) 542 if (arg1 == 0)
545 PKCS7_RECIP_INFO_get0_alg(arg2, &alg); 543 PKCS7_RECIP_INFO_get0_alg(arg2, &alg);
@@ -553,7 +551,7 @@ rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
553 break; 551 break;
554 552
555 case ASN1_PKEY_CTRL_CMS_ENVELOPE: 553 case ASN1_PKEY_CTRL_CMS_ENVELOPE:
556 if (pkey_is_pss(pkey)) 554 if (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
557 return -2; 555 return -2;
558 if (arg1 == 0) 556 if (arg1 == 0)
559 return rsa_cms_encrypt(arg2); 557 return rsa_cms_encrypt(arg2);
@@ -562,7 +560,7 @@ rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
562 break; 560 break;
563 561
564 case ASN1_PKEY_CTRL_CMS_RI_TYPE: 562 case ASN1_PKEY_CTRL_CMS_RI_TYPE:
565 if (pkey_is_pss(pkey)) 563 if (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
566 return -2; 564 return -2;
567 *(int *)arg2 = CMS_RECIPINFO_TRANS; 565 *(int *)arg2 = CMS_RECIPINFO_TRANS;
568 return 1; 566 return 1;
@@ -852,7 +850,7 @@ rsa_cms_verify(CMS_SignerInfo *si)
852 if (nid == EVP_PKEY_RSA_PSS) 850 if (nid == EVP_PKEY_RSA_PSS)
853 return rsa_pss_to_ctx(NULL, pkey_ctx, alg, NULL); 851 return rsa_pss_to_ctx(NULL, pkey_ctx, alg, NULL);
854 /* Only PSS allowed for PSS keys */ 852 /* Only PSS allowed for PSS keys */
855 if (pkey_ctx_is_pss(pkey_ctx)) { 853 if (pkey_ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS) {
856 RSAerror(RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE); 854 RSAerror(RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE);
857 return 0; 855 return 0;
858 } 856 }