-/* $OpenBSD: rsa_ameth.c,v 1.34 2023/10/26 07:57:54 tb Exp $ */
+/* $OpenBSD: rsa_ameth.c,v 1.35 2023/11/07 15:45:41 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
static RSA_PSS_PARAMS *rsa_pss_decode(const X509_ALGOR *alg);
+static int rsa_alg_set_pkcs1_padding(X509_ALGOR *alg);
+
/* Set any parameters associated with pkey */
static int
rsa_param_encode(const EVP_PKEY *pkey, ASN1_STRING **pstr, int *pstrtype)
return -2;
}
- if (alg)
- X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption),
- V_ASN1_NULL, 0);
+ if (alg != NULL)
+ return rsa_alg_set_pkcs1_padding(alg);
return 1;
}
return -1;
}
+static int
+rsa_alg_set_pkcs1_padding(X509_ALGOR *alg)
+{
+ return X509_ALGOR_set0_by_nid(alg, NID_rsaEncryption, V_ASN1_NULL, NULL);
+}
+
#ifndef OPENSSL_NO_CMS
static int
rsa_cms_sign(CMS_SignerInfo *si)
if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0)
return 0;
}
- if (pad_mode == RSA_PKCS1_PADDING) {
- X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), V_ASN1_NULL, 0);
- return 1;
- }
+ if (pad_mode == RSA_PKCS1_PADDING)
+ return rsa_alg_set_pkcs1_padding(alg);
/* We don't support it */
if (pad_mode != RSA_PKCS1_PSS_PADDING)
return 0;
if (EVP_PKEY_CTX_get_rsa_padding(pkctx, &pad_mode) <= 0)
return 0;
}
- if (pad_mode == RSA_PKCS1_PADDING) {
- X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), V_ASN1_NULL, 0);
- return 1;
- }
+ if (pad_mode == RSA_PKCS1_PADDING)
+ return rsa_alg_set_pkcs1_padding(alg);
/* Not supported */
if (pad_mode != RSA_PKCS1_OAEP_PADDING)
return 0;