Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

csrypto: ccp - Expand RSA support for a v5 ccp

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>

authored by

Gary R Hook and committed by
Herbert Xu
e28c190d ceeec0af

+12 -2
+4 -1
drivers/crypto/ccp/ccp-crypto-rsa.c
··· 60 60 61 61 static unsigned int ccp_rsa_maxsize(struct crypto_akcipher *tfm) 62 62 { 63 - return CCP_RSA_MAXMOD; 63 + if (ccp_version() > CCP_VERSION(3, 0)) 64 + return CCP5_RSA_MAXMOD; 65 + else 66 + return CCP_RSA_MAXMOD; 64 67 } 65 68 66 69 static int ccp_rsa_crypt(struct akcipher_request *req, bool encrypt)
+1
drivers/crypto/ccp/ccp-crypto.h
··· 255 255 }; 256 256 257 257 #define CCP_RSA_MAXMOD (4 * 1024 / 8) 258 + #define CCP5_RSA_MAXMOD (16 * 1024 / 8) 258 259 259 260 /***** Common Context Structure *****/ 260 261 struct ccp_ctx {
+1
drivers/crypto/ccp/ccp-dev-v3.c
··· 597 597 .setup = NULL, 598 598 .perform = &ccp3_actions, 599 599 .offset = 0x20000, 600 + .rsamax = CCP_RSA_MAX_WIDTH, 600 601 };
+2
drivers/crypto/ccp/ccp-dev-v5.c
··· 1112 1112 .setup = ccp5_config, 1113 1113 .perform = &ccp5_actions, 1114 1114 .offset = 0x0, 1115 + .rsamax = CCP5_RSA_MAX_WIDTH, 1115 1116 }; 1116 1117 1117 1118 const struct ccp_vdata ccpv5b = { ··· 1121 1120 .setup = ccp5other_config, 1122 1121 .perform = &ccp5_actions, 1123 1122 .offset = 0x0, 1123 + .rsamax = CCP5_RSA_MAX_WIDTH, 1124 1124 };
+1
drivers/crypto/ccp/ccp-dev.h
··· 202 202 #define CCP_SHA_SB_COUNT 1 203 203 204 204 #define CCP_RSA_MAX_WIDTH 4096 205 + #define CCP5_RSA_MAX_WIDTH 16384 205 206 206 207 #define CCP_PASSTHRU_BLOCKSIZE 256 207 208 #define CCP_PASSTHRU_MASKSIZE 32
+2 -1
drivers/crypto/ccp/ccp-ops.c
··· 1736 1736 unsigned int sb_count, i_len, o_len; 1737 1737 int ret; 1738 1738 1739 - if (rsa->key_size > CCP_RSA_MAX_WIDTH) 1739 + /* Check against the maximum allowable size, in bits */ 1740 + if (rsa->key_size > cmd_q->ccp->vdata->rsamax) 1740 1741 return -EINVAL; 1741 1742 1742 1743 if (!rsa->exp || !rsa->mod || !rsa->src || !rsa->dst)
+1
drivers/crypto/ccp/sp-dev.h
··· 40 40 void (*setup)(struct ccp_device *); 41 41 const struct ccp_actions *perform; 42 42 const unsigned int offset; 43 + const unsigned int rsamax; 43 44 }; 44 45 /* Structure to hold SP device data */ 45 46 struct sp_dev_vdata {