ctrls to set PSS salt length.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 10 Apr 2006 12:55:04 +0000 (12:55 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 10 Apr 2006 12:55:04 +0000 (12:55 +0000)
crypto/rsa/rsa.h
crypto/rsa/rsa_pmeth.c

index 6df1e67..e9225a5 100644 (file)
@@ -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
index f8ce45c..378bfe4 100644 (file)
@@ -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();
@@ -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;
@@ -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;
        }