summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/rsa/rsa_ameth.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c
index 0c27ee621e..b4dbff2683 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.39 2023/11/07 16:12:36 tb Exp $ */ 1/* $OpenBSD: rsa_ameth.c,v 1.40 2023/11/07 16:22:04 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 */
@@ -734,20 +734,6 @@ rsa_pss_params_create(const EVP_MD *sigmd, const EVP_MD *mgf1md, int saltlen)
734 return NULL; 734 return NULL;
735} 735}
736 736
737static ASN1_STRING *
738rsa_ctx_to_pss_string(EVP_PKEY_CTX *pkey_ctx)
739{
740 RSA_PSS_PARAMS *pss = rsa_ctx_to_pss(pkey_ctx);
741 ASN1_STRING *os;
742
743 if (pss == NULL)
744 return NULL;
745
746 os = ASN1_item_pack(pss, &RSA_PSS_PARAMS_it, NULL);
747 RSA_PSS_PARAMS_free(pss);
748 return os;
749}
750
751/* 737/*
752 * From PSS AlgorithmIdentifier set public key parameters. If pkey isn't NULL 738 * 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 739 * then the EVP_MD_CTX is setup and initialised. If it is NULL parameters are
@@ -897,13 +883,16 @@ rsa_alg_set_pkcs1_padding(X509_ALGOR *alg)
897static int 883static int
898rsa_alg_set_pss_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx) 884rsa_alg_set_pss_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx)
899{ 885{
886 RSA_PSS_PARAMS *pss = NULL;
900 ASN1_STRING *astr = NULL; 887 ASN1_STRING *astr = NULL;
901 int ret = 0; 888 int ret = 0;
902 889
903 if (pkey_ctx == NULL) 890 if (pkey_ctx == NULL)
904 goto err; 891 goto err;
905 892
906 if ((astr = rsa_ctx_to_pss_string(pkey_ctx)) == NULL) 893 if ((pss = rsa_ctx_to_pss(pkey_ctx)) == NULL)
894 goto err;
895 if ((astr = ASN1_item_pack(pss, &RSA_PSS_PARAMS_it, NULL)) == NULL)
907 goto err; 896 goto err;
908 if (!X509_ALGOR_set0_by_nid(alg, EVP_PKEY_RSA_PSS, V_ASN1_SEQUENCE, astr)) 897 if (!X509_ALGOR_set0_by_nid(alg, EVP_PKEY_RSA_PSS, V_ASN1_SEQUENCE, astr))
909 goto err; 898 goto err;
@@ -913,6 +902,7 @@ rsa_alg_set_pss_padding(X509_ALGOR *alg, EVP_PKEY_CTX *pkey_ctx)
913 902
914 err: 903 err:
915 ASN1_STRING_free(astr); 904 ASN1_STRING_free(astr);
905 RSA_PSS_PARAMS_free(pss);
916 906
917 return ret; 907 return ret;
918} 908}