diff options
Diffstat (limited to '')
| -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 43f52f749a..35adcb391e 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.34 2023/10/26 07:57:54 tb Exp $ */ | 1 | /* $OpenBSD: rsa_ameth.c,v 1.35 2023/11/07 15:45:41 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 | */ |
| @@ -83,6 +83,8 @@ static int rsa_cms_encrypt(CMS_RecipientInfo *ri); | |||
| 83 | 83 | ||
| 84 | static RSA_PSS_PARAMS *rsa_pss_decode(const X509_ALGOR *alg); | 84 | static RSA_PSS_PARAMS *rsa_pss_decode(const X509_ALGOR *alg); |
| 85 | 85 | ||
| 86 | static int rsa_alg_set_pkcs1_padding(X509_ALGOR *alg); | ||
| 87 | |||
| 86 | /* Set any parameters associated with pkey */ | 88 | /* Set any parameters associated with pkey */ |
| 87 | static int | 89 | static int |
| 88 | rsa_param_encode(const EVP_PKEY *pkey, ASN1_STRING **pstr, int *pstrtype) | 90 | rsa_param_encode(const EVP_PKEY *pkey, ASN1_STRING **pstr, int *pstrtype) |
| @@ -568,9 +570,8 @@ rsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) | |||
| 568 | return -2; | 570 | return -2; |
| 569 | } | 571 | } |
| 570 | 572 | ||
| 571 | if (alg) | 573 | if (alg != NULL) |
| 572 | X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), | 574 | return rsa_alg_set_pkcs1_padding(alg); |
| 573 | V_ASN1_NULL, 0); | ||
| 574 | 575 | ||
| 575 | return 1; | 576 | return 1; |
| 576 | } | 577 | } |
| @@ -887,6 +888,12 @@ rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |||
| 887 | return -1; | 888 | return -1; |
| 888 | } | 889 | } |
| 889 | 890 | ||
| 891 | static int | ||
| 892 | rsa_alg_set_pkcs1_padding(X509_ALGOR *alg) | ||
| 893 | { | ||
| 894 | return X509_ALGOR_set0_by_nid(alg, NID_rsaEncryption, V_ASN1_NULL, NULL); | ||
| 895 | } | ||
| 896 | |||
| 890 | #ifndef OPENSSL_NO_CMS | 897 | #ifndef OPENSSL_NO_CMS |
| 891 | static int | 898 | static int |
| 892 | rsa_cms_sign(CMS_SignerInfo *si) | 899 | rsa_cms_sign(CMS_SignerInfo *si) |
| @@ -901,10 +908,8 @@ rsa_cms_sign(CMS_SignerInfo *si) | |||
| 901 | if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) | 908 | if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) |
| 902 | return 0; | 909 | return 0; |
| 903 | } | 910 | } |
| 904 | if (pad_mode == RSA_PKCS1_PADDING) { | 911 | if (pad_mode == RSA_PKCS1_PADDING) |
| 905 | X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), V_ASN1_NULL, 0); | 912 | return rsa_alg_set_pkcs1_padding(alg); |
| 906 | return 1; | ||
| 907 | } | ||
| 908 | /* We don't support it */ | 913 | /* We don't support it */ |
| 909 | if (pad_mode != RSA_PKCS1_PSS_PADDING) | 914 | if (pad_mode != RSA_PKCS1_PSS_PADDING) |
| 910 | return 0; | 915 | return 0; |
| @@ -1067,10 +1072,8 @@ rsa_cms_encrypt(CMS_RecipientInfo *ri) | |||
| 1067 | if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) | 1072 | if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0) |
| 1068 | return 0; | 1073 | return 0; |
| 1069 | } | 1074 | } |
| 1070 | if (pad_mode == RSA_PKCS1_PADDING) { | 1075 | if (pad_mode == RSA_PKCS1_PADDING) |
| 1071 | X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), V_ASN1_NULL, 0); | 1076 | return rsa_alg_set_pkcs1_padding(alg); |
| 1072 | return 1; | ||
| 1073 | } | ||
| 1074 | /* Not supported */ | 1077 | /* Not supported */ |
| 1075 | if (pad_mode != RSA_PKCS1_OAEP_PADDING) | 1078 | if (pad_mode != RSA_PKCS1_OAEP_PADDING) |
| 1076 | return 0; | 1079 | return 0; |
