char *str;
const char *s;
int ret = 0, mod_len = 0;
- int is_pss = pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS;
if (x->n != NULL)
mod_len = BN_num_bits(x->n);
if (!BIO_indent(bp, off, 128))
goto err;
- if (BIO_printf(bp, "%s ", is_pss ? "RSA-PSS" : "RSA") <= 0)
+ if (BIO_printf(bp, "%s ", pkey_is_pss(pkey) ? "RSA-PSS" : "RSA") <= 0)
goto err;
if (priv && x->d) {
if (!ASN1_bn_print(bp, "coefficient:", x->iqmp, NULL, off))
goto err;
}
- if (is_pss && !rsa_pss_param_print(bp, 1, x->pss, off))
+ if (pkey_is_pss(pkey) && !rsa_pss_param_print(bp, 1, x->pss, off))
goto err;
ret = 1;
err:
unsigned int m_len, unsigned char *rm,
size_t *prm_len, const unsigned char *sigbuf,
size_t siglen, RSA *rsa);
+/* Macros to test if a pkey or ctx is for a PSS key */
+#define pkey_is_pss(pkey) (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS)
+#define pkey_ctx_is_pss(ctx) (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS)
RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd,
const EVP_MD *mgf1md, int saltlen);
if (rctx == NULL)
return 0;
rctx->nbits = 1024;
- if (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS)
+ if (pkey_ctx_is_pss(ctx))
rctx->pad_mode = RSA_PKCS1_PSS_PADDING;
else
rctx->pad_mode = RSA_PKCS1_PADDING;
goto bad_pad;
if (!rctx->md)
rctx->md = EVP_sha1();
- } else if (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS) {
+ } else if (pkey_ctx_is_pss(ctx)) {
goto bad_pad;
}
if (p1 == RSA_PKCS1_OAEP_PADDING) {
EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT,
EVP_PKEY_CTRL_RSA_MGF1_MD, value);
- if (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS) {
+ if (pkey_ctx_is_pss(ctx)) {
if (strcmp(type, "rsa_pss_keygen_mgf1_md") == 0)
return EVP_PKEY_CTX_md(ctx, EVP_PKEY_OP_KEYGEN,
static int rsa_set_pss_param(RSA *rsa, EVP_PKEY_CTX *ctx)
{
RSA_PKEY_CTX *rctx = ctx->data;
- if (ctx->pmeth->pkey_id != EVP_PKEY_RSA_PSS)
+ if (!pkey_ctx_is_pss(ctx))
return 1;
+ /* If all parameters are default values don't set pss */
if (rctx->md == NULL && rctx->mgf1md == NULL && rctx->saltlen == -2)
return 1;
rsa->pss = rsa_pss_params_create(rctx->md, rctx->mgf1md,