]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
csrypto: ccp - Expand RSA support for a v5 ccp
authorGary R Hook <gary.hook@amd.com>
Mon, 17 Jul 2017 20:16:42 +0000 (15:16 -0500)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 28 Jul 2017 09:58:06 +0000 (17:58 +0800)
A version 5 CCP can handle an RSA modulus up to 16k bits.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/ccp-crypto-rsa.c
drivers/crypto/ccp/ccp-crypto.h
drivers/crypto/ccp/ccp-dev-v3.c
drivers/crypto/ccp/ccp-dev-v5.c
drivers/crypto/ccp/ccp-dev.h
drivers/crypto/ccp/ccp-ops.c
drivers/crypto/ccp/sp-dev.h

index d5544943f5f0c258d7b033a6114039c51a250225..e6db8672d89c436f2559522cf14e98fe05159dc0 100644 (file)
@@ -60,7 +60,10 @@ static int ccp_rsa_complete(struct crypto_async_request *async_req, int ret)
 
 static unsigned int ccp_rsa_maxsize(struct crypto_akcipher *tfm)
 {
-       return CCP_RSA_MAXMOD;
+       if (ccp_version() > CCP_VERSION(3, 0))
+               return CCP5_RSA_MAXMOD;
+       else
+               return CCP_RSA_MAXMOD;
 }
 
 static int ccp_rsa_crypt(struct akcipher_request *req, bool encrypt)
index aa53b97f6f006b1b8b193d9cf90b33727ba427f9..67c7620029e38df7f4fa8517bd77e5a6d98066b6 100644 (file)
@@ -255,6 +255,7 @@ struct ccp_rsa_req_ctx {
 };
 
 #define        CCP_RSA_MAXMOD  (4 * 1024 / 8)
+#define        CCP5_RSA_MAXMOD (16 * 1024 / 8)
 
 /***** Common Context Structure *****/
 struct ccp_ctx {
index c2861749e2ad36edd87126dec7f9d8b597a9f277..240bebbcb8ac7c52eb7dfa2b93a00b5b9cb53cc9 100644 (file)
@@ -597,4 +597,5 @@ const struct ccp_vdata ccpv3 = {
        .setup = NULL,
        .perform = &ccp3_actions,
        .offset = 0x20000,
+       .rsamax = CCP_RSA_MAX_WIDTH,
 };
index 5f9e82beadfd25530b0bfcffcdccdff41ed08343..6ace6dd5a239c6c1995e065b6745bc6082a5e0d7 100644 (file)
@@ -1112,6 +1112,7 @@ const struct ccp_vdata ccpv5a = {
        .setup = ccp5_config,
        .perform = &ccp5_actions,
        .offset = 0x0,
+       .rsamax = CCP5_RSA_MAX_WIDTH,
 };
 
 const struct ccp_vdata ccpv5b = {
@@ -1120,4 +1121,5 @@ const struct ccp_vdata ccpv5b = {
        .setup = ccp5other_config,
        .perform = &ccp5_actions,
        .offset = 0x0,
+       .rsamax = CCP5_RSA_MAX_WIDTH,
 };
index 9320931d89dae94670b3fdbb9699ba3b89dc7a18..1f6deee117a73968b141fe8a9c3cb438e1f24ef1 100644 (file)
 #define CCP_SHA_SB_COUNT               1
 
 #define CCP_RSA_MAX_WIDTH              4096
+#define CCP5_RSA_MAX_WIDTH             16384
 
 #define CCP_PASSTHRU_BLOCKSIZE         256
 #define CCP_PASSTHRU_MASKSIZE          32
index 1b757531f79a067d0a65e37a66dfcb83105c46c2..40c062ad872632ed703b3bfe508fcfde4b15e852 100644 (file)
@@ -1736,7 +1736,8 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
        unsigned int sb_count, i_len, o_len;
        int ret;
 
-       if (rsa->key_size > CCP_RSA_MAX_WIDTH)
+       /* Check against the maximum allowable size, in bits */
+       if (rsa->key_size > cmd_q->ccp->vdata->rsamax)
                return -EINVAL;
 
        if (!rsa->exp || !rsa->mod || !rsa->src || !rsa->dst)
index 3520da4e20cfaaca8d1bb90b42e29f9d47bc0a15..5ab486ade1ad9376b8d9024bed0ee03f1d48ff2f 100644 (file)
@@ -40,6 +40,7 @@ struct ccp_vdata {
        void (*setup)(struct ccp_device *);
        const struct ccp_actions *perform;
        const unsigned int offset;
+       const unsigned int rsamax;
 };
 /* Structure to hold SP device data */
 struct sp_dev_vdata {