summaryrefslogtreecommitdiff
path: root/drivers/crypto/ccp/ccp-crypto-rsa.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2022-12-02 17:20:49 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2022-12-09 18:45:00 +0800
commit99c6b20edfc031610240afca97ba9be5ec6f5750 (patch)
treed915c78e08364358e435944bb5b994ffa354616c /drivers/crypto/ccp/ccp-crypto-rsa.c
parent1c64a7e1f931821acadf964c5ddb0dc41abf9e20 (diff)
crypto: ccp - Set DMA alignment explicitly
This driver has been implicitly relying on kmalloc alignment to be sufficient for DMA. This may no longer be the case with upcoming arm64 changes. This patch changes it to explicitly request DMA alignment from the Crypto API. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp/ccp-crypto-rsa.c')
-rw-r--r--drivers/crypto/ccp/ccp-crypto-rsa.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/crypto/ccp/ccp-crypto-rsa.c b/drivers/crypto/ccp/ccp-crypto-rsa.c
index 1223ac70aea2..a14f85512cf4 100644
--- a/drivers/crypto/ccp/ccp-crypto-rsa.c
+++ b/drivers/crypto/ccp/ccp-crypto-rsa.c
@@ -44,7 +44,7 @@ static inline int ccp_copy_and_save_keypart(u8 **kpbuf, unsigned int *kplen,
static int ccp_rsa_complete(struct crypto_async_request *async_req, int ret)
{
struct akcipher_request *req = akcipher_request_cast(async_req);
- struct ccp_rsa_req_ctx *rctx = akcipher_request_ctx(req);
+ struct ccp_rsa_req_ctx *rctx = akcipher_request_ctx_dma(req);
if (ret)
return ret;
@@ -56,7 +56,7 @@ static int ccp_rsa_complete(struct crypto_async_request *async_req, int ret)
static unsigned int ccp_rsa_maxsize(struct crypto_akcipher *tfm)
{
- struct ccp_ctx *ctx = akcipher_tfm_ctx(tfm);
+ struct ccp_ctx *ctx = akcipher_tfm_ctx_dma(tfm);
return ctx->u.rsa.n_len;
}
@@ -64,8 +64,8 @@ static unsigned int ccp_rsa_maxsize(struct crypto_akcipher *tfm)
static int ccp_rsa_crypt(struct akcipher_request *req, bool encrypt)
{
struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req);
- struct ccp_ctx *ctx = akcipher_tfm_ctx(tfm);
- struct ccp_rsa_req_ctx *rctx = akcipher_request_ctx(req);
+ struct ccp_ctx *ctx = akcipher_tfm_ctx_dma(tfm);
+ struct ccp_rsa_req_ctx *rctx = akcipher_request_ctx_dma(req);
int ret = 0;
memset(&rctx->cmd, 0, sizeof(rctx->cmd));
@@ -126,7 +126,7 @@ static void ccp_rsa_free_key_bufs(struct ccp_ctx *ctx)
static int ccp_rsa_setkey(struct crypto_akcipher *tfm, const void *key,
unsigned int keylen, bool private)
{
- struct ccp_ctx *ctx = akcipher_tfm_ctx(tfm);
+ struct ccp_ctx *ctx = akcipher_tfm_ctx_dma(tfm);
struct rsa_key raw_key;
int ret;
@@ -192,9 +192,9 @@ static int ccp_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key,
static int ccp_rsa_init_tfm(struct crypto_akcipher *tfm)
{
- struct ccp_ctx *ctx = akcipher_tfm_ctx(tfm);
+ struct ccp_ctx *ctx = akcipher_tfm_ctx_dma(tfm);
- akcipher_set_reqsize(tfm, sizeof(struct ccp_rsa_req_ctx));
+ akcipher_set_reqsize_dma(tfm, sizeof(struct ccp_rsa_req_ctx));
ctx->complete = ccp_rsa_complete;
return 0;
@@ -202,7 +202,7 @@ static int ccp_rsa_init_tfm(struct crypto_akcipher *tfm)
static void ccp_rsa_exit_tfm(struct crypto_akcipher *tfm)
{
- struct ccp_ctx *ctx = crypto_tfm_ctx(&tfm->base);
+ struct ccp_ctx *ctx = akcipher_tfm_ctx_dma(tfm);
ccp_rsa_free_key_bufs(ctx);
}
@@ -220,7 +220,7 @@ static struct akcipher_alg ccp_rsa_defaults = {
.cra_driver_name = "rsa-ccp",
.cra_priority = CCP_CRA_PRIORITY,
.cra_module = THIS_MODULE,
- .cra_ctxsize = 2 * sizeof(struct ccp_ctx),
+ .cra_ctxsize = 2 * sizeof(struct ccp_ctx) + CRYPTO_DMA_PADDING,
},
};