Skip to content

Commit

Permalink
ctrls to set PSS salt length.
Browse files Browse the repository at this point in the history
  • Loading branch information
snhenson committed Apr 10, 2006
1 parent a7ffd9d commit f9a6348
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions crypto/rsa/rsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,14 @@ struct rsa_st
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \
pad, NULL)

#define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \
(EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \
len, NULL)

#define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1)
#define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2)

#define RSA_PKCS1_PADDING 1
#define RSA_SSLV23_PADDING 2
Expand Down
18 changes: 15 additions & 3 deletions crypto/rsa/rsa_pmeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,11 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
case EVP_PKEY_CTRL_RSA_PADDING:
if ((p1 >= RSA_PKCS1_PADDING) && (p1 <= RSA_PKCS1_PSS_PADDING))
{
if (ctx->operation & EVP_PKEY_OP_TYPE_GEN)
return -2;
if (!check_padding_md(rctx->md, p1))
return 0;
if (p1 == RSA_PKCS1_PSS_PADDING)
{
if (!(ctx->operation & EVP_PKEY_OP_TYPE_SIG))
if (ctx->operation == EVP_PKEY_OP_VERIFYRECOVER)
return -2;
if (!rctx->md)
rctx->md = EVP_sha1();
Expand All @@ -376,6 +374,14 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
}
return -2;

case EVP_PKEY_CTRL_RSA_PSS_SALTLEN:
if (p1 < -2)
return -2;
if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING)
return -2;
rctx->saltlen = p1;
return 1;

case EVP_PKEY_CTRL_MD:
if (!check_padding_md(p2, rctx->pad_mode))
return 0;
Expand Down Expand Up @@ -412,6 +418,12 @@ static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx,
return -2;
return EVP_PKEY_CTX_set_rsa_padding(ctx, pm);
}
if (!strcmp(type, "rsa_pss_saltlen"))
{
int saltlen;
saltlen = atoi(value);
return EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, saltlen);
}
return -2;
}

Expand Down

0 comments on commit f9a6348

Please sign in to comment.