summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-11-07 16:12:36 +0000
committertb <>2023-11-07 16:12:36 +0000
commit1a74897e4aa5cbc7fde75fd64e73e5b2d8984ba2 (patch)
treefe3f17f13a64c62feb943ed73949f66cdbb1416a /src/lib
parent4982e9f4e24ca44cc8c4dbb7f3450197e6e86205 (diff)
downloadopenbsd-1a74897e4aa5cbc7fde75fd64e73e5b2d8984ba2.tar.gz
openbsd-1a74897e4aa5cbc7fde75fd64e73e5b2d8984ba2.tar.bz2
openbsd-1a74897e4aa5cbc7fde75fd64e73e5b2d8984ba2.zip
Rename pkctx to pkey_ctx in rsa_{cms,item}_sign()
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/rsa/rsa_ameth.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c
index b742134509..0c27ee621e 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.38 2023/11/07 16:09:13 tb Exp $ */ 1/* $OpenBSD: rsa_ameth.c,v 1.39 2023/11/07 16:12:36 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 */
@@ -673,17 +673,17 @@ rsa_algor_to_md(X509_ALGOR *alg)
673 * suitable for setting an AlgorithmIdentifier. 673 * suitable for setting an AlgorithmIdentifier.
674 */ 674 */
675static RSA_PSS_PARAMS * 675static RSA_PSS_PARAMS *
676rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx) 676rsa_ctx_to_pss(EVP_PKEY_CTX *pkey_ctx)
677{ 677{
678 const EVP_MD *sigmd, *mgf1md; 678 const EVP_MD *sigmd, *mgf1md;
679 EVP_PKEY *pk = EVP_PKEY_CTX_get0_pkey(pkctx); 679 EVP_PKEY *pk = EVP_PKEY_CTX_get0_pkey(pkey_ctx);
680 int saltlen; 680 int saltlen;
681 681
682 if (EVP_PKEY_CTX_get_signature_md(pkctx, &sigmd) <= 0) 682 if (EVP_PKEY_CTX_get_signature_md(pkey_ctx, &sigmd) <= 0)
683 return NULL; 683 return NULL;
684 if (EVP_PKEY_CTX_get_rsa_mgf1_md(pkctx, &mgf1md) <= 0) 684 if (EVP_PKEY_CTX_get_rsa_mgf1_md(pkey_ctx, &mgf1md) <= 0)
685 return NULL; 685 return NULL;
686 if (!EVP_PKEY_CTX_get_rsa_pss_saltlen(pkctx, &saltlen)) 686 if (!EVP_PKEY_CTX_get_rsa_pss_saltlen(pkey_ctx, &saltlen))
687 return NULL; 687 return NULL;
688 if (saltlen == -1) { 688 if (saltlen == -1) {
689 saltlen = EVP_MD_size(sigmd); 689 saltlen = EVP_MD_size(sigmd);
@@ -735,9 +735,9 @@ rsa_pss_params_create(const EVP_MD *sigmd, const EVP_MD *mgf1md, int saltlen)
735} 735}
736 736
737static ASN1_STRING * 737static ASN1_STRING *
738rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkctx) 738rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkey_ctx)
739{ 739{
740 RSA_PSS_PARAMS *pss = rsa_ctx_to_pss(pkctx); 740 RSA_PSS_PARAMS *pss = rsa_ctx_to_pss(pkey_ctx);
741 ASN1_STRING *os; 741 ASN1_STRING *os;
742 742
743 if (pss == NULL) 743 if (pss == NULL)
@@ -751,11 +751,11 @@ rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkctx)
751/* 751/*
752 * From PSS AlgorithmIdentifier set public key parameters. If pkey isn't NULL 752 * From PSS AlgorithmIdentifier set public key parameters. If pkey isn't NULL
753 * then the EVP_MD_CTX is setup and initialised. If it is NULL parameters are 753 * then the EVP_MD_CTX is setup and initialised. If it is NULL parameters are
754 * passed to pkctx instead. 754 * passed to pkey_ctx instead.
755 */ 755 */
756 756
757static int 757static int
758rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx, 758rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkey_ctx,
759 X509_ALGOR *sigalg, EVP_PKEY *pkey) 759 X509_ALGOR *sigalg, EVP_PKEY *pkey)
760{ 760{
761 int rv = -1; 761 int rv = -1;
@@ -778,11 +778,11 @@ rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx,
778 778
779 /* We have all parameters now set up context */ 779 /* We have all parameters now set up context */
780 if (pkey) { 780 if (pkey) {
781 if (!EVP_DigestVerifyInit(ctx, &pkctx, md, NULL, pkey)) 781 if (!EVP_DigestVerifyInit(ctx, &pkey_ctx, md, NULL, pkey))
782 goto err; 782 goto err;
783 } else { 783 } else {
784 const EVP_MD *checkmd; 784 const EVP_MD *checkmd;
785 if (EVP_PKEY_CTX_get_signature_md(pkctx, &checkmd) <= 0) 785 if (EVP_PKEY_CTX_get_signature_md(pkey_ctx, &checkmd) <= 0)
786 goto err; 786 goto err;
787 if (EVP_MD_type(md) != EVP_MD_type(checkmd)) { 787 if (EVP_MD_type(md) != EVP_MD_type(checkmd)) {
788 RSAerror(RSA_R_DIGEST_DOES_NOT_MATCH); 788 RSAerror(RSA_R_DIGEST_DOES_NOT_MATCH);
@@ -790,13 +790,13 @@ rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx,
790 } 790 }
791 } 791 }
792 792
793 if (EVP_PKEY_CTX_set_rsa_padding(pkctx, RSA_PKCS1_PSS_PADDING) <= 0) 793 if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) <= 0)
794 goto err; 794 goto err;
795 795
796 if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkctx, saltlen) <= 0) 796 if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, saltlen) <= 0)
797 goto err; 797 goto err;
798 798
799 if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkctx, mgf1md) <= 0) 799 if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) <= 0)
800 goto err; 800 goto err;
801 /* Carry on */ 801 /* Carry on */
802 rv = 1; 802 rv = 1;
@@ -846,14 +846,14 @@ rsa_cms_verify(CMS_SignerInfo *si)
846{ 846{
847 int nid, nid2; 847 int nid, nid2;
848 X509_ALGOR *alg; 848 X509_ALGOR *alg;
849 EVP_PKEY_CTX *pkctx = CMS_SignerInfo_get0_pkey_ctx(si); 849 EVP_PKEY_CTX *pkey_ctx = CMS_SignerInfo_get0_pkey_ctx(si);
850 850
851 CMS_SignerInfo_get0_algs(si, NULL, NULL, NULL, &alg); 851 CMS_SignerInfo_get0_algs(si, NULL, NULL, NULL, &alg);
852 nid = OBJ_obj2nid(alg->algorithm); 852 nid = OBJ_obj2nid(alg->algorithm);
853 if (nid == EVP_PKEY_RSA_PSS) 853 if (nid == EVP_PKEY_RSA_PSS)
854 return rsa_pss_to_ctx(NULL, pkctx, alg, NULL); 854 return rsa_pss_to_ctx(NULL, pkey_ctx, alg, NULL);
855 /* Only PSS allowed for PSS keys */ 855 /* Only PSS allowed for PSS keys */
856 if (pkey_ctx_is_pss(pkctx)) { 856 if (pkey_ctx_is_pss(pkey_ctx)) {
857 RSAerror(RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE); 857 RSAerror(RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE);
858 return 0; 858 return 0;
859 } 859 }
@@ -921,12 +921,12 @@ rsa_alg_set_pss_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx)
921static int 921static int
922rsa_cms_sign(CMS_SignerInfo *si) 922rsa_cms_sign(CMS_SignerInfo *si)
923{ 923{
924 EVP_PKEY_CTX *pkctx; 924 EVP_PKEY_CTX *pkey_ctx;
925 X509_ALGOR *alg; 925 X509_ALGOR *alg;
926 int pad_mode = RSA_PKCS1_PADDING; 926 int pad_mode = RSA_PKCS1_PADDING;
927 927
928 if ((pkctx = CMS_SignerInfo_get0_pkey_ctx(si)) != NULL) { 928 if ((pkey_ctx = CMS_SignerInfo_get0_pkey_ctx(si)) != NULL) {
929 if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) 929 if (EVP_PKEY_CTX_get_rsa_padding(pkey_ctx, &pad_mode) <= 0)
930 return 0; 930 return 0;
931 } 931 }
932 932
@@ -934,7 +934,7 @@ rsa_cms_sign(CMS_SignerInfo *si)
934 if (pad_mode == RSA_PKCS1_PADDING) 934 if (pad_mode == RSA_PKCS1_PADDING)
935 return rsa_alg_set_pkcs1_padding(alg); 935 return rsa_alg_set_pkcs1_padding(alg);
936 if (pad_mode == RSA_PKCS1_PSS_PADDING) 936 if (pad_mode == RSA_PKCS1_PSS_PADDING)
937 return rsa_alg_set_pss_padding(alg, pkctx); 937 return rsa_alg_set_pss_padding(alg, pkey_ctx);
938 938
939 return 0; 939 return 0;
940} 940}
@@ -944,18 +944,18 @@ static int
944rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, 944rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
945 X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig) 945 X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig)
946{ 946{
947 EVP_PKEY_CTX *pkctx = ctx->pctx; 947 EVP_PKEY_CTX *pkey_ctx = ctx->pctx;
948 int pad_mode; 948 int pad_mode;
949 949
950 if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) 950 if (EVP_PKEY_CTX_get_rsa_padding(pkey_ctx, &pad_mode) <= 0)
951 return 0; 951 return 0;
952 if (pad_mode == RSA_PKCS1_PADDING) 952 if (pad_mode == RSA_PKCS1_PADDING)
953 return 2; 953 return 2;
954 if (pad_mode == RSA_PKCS1_PSS_PADDING) { 954 if (pad_mode == RSA_PKCS1_PSS_PADDING) {
955 if (!rsa_alg_set_pss_padding(alg1, pkctx)) 955 if (!rsa_alg_set_pss_padding(alg1, pkey_ctx))
956 return 0; 956 return 0;
957 if (alg2 != NULL) { 957 if (alg2 != NULL) {
958 if (!rsa_alg_set_pss_padding(alg2, pkctx)) 958 if (!rsa_alg_set_pss_padding(alg2, pkey_ctx))
959 return 0; 959 return 0;
960 } 960 }
961 return 3; 961 return 3;