summaryrefslogtreecommitdiff
path: root/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2016-01-29 12:45:14 -0600
committerHerbert Xu <herbert@gondor.apana.org.au>2016-02-01 22:27:05 +0800
commitd1662165ae612ec8b5f94a6b07e65ea58b6dce34 (patch)
tree7aab5279425b9e40e844c7d2237b6e952e708bb3 /drivers/crypto/ccp/ccp-crypto-aes-cmac.c
parent0529900a01cb840feb7f7e2f64ed88f7a9ed0031 (diff)
crypto: ccp - Limit the amount of information exported
Since the exported information can be exposed to user-space, instead of exporting the entire request context only export the minimum information needed. Cc: <stable@vger.kernel.org> # 3.14.x- Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp/ccp-crypto-aes-cmac.c')
-rw-r--r--drivers/crypto/ccp/ccp-crypto-aes-cmac.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
index 00207cf5c79b..6a2d836eb2d9 100644
--- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
+++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
@@ -223,9 +223,12 @@ static int ccp_aes_cmac_digest(struct ahash_request *req)
static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
{
struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
- struct ccp_aes_cmac_req_ctx *state = out;
+ struct ccp_aes_cmac_exp_ctx *state = out;
- *state = *rctx;
+ state->null_msg = rctx->null_msg;
+ memcpy(state->iv, rctx->iv, sizeof(state->iv));
+ state->buf_count = rctx->buf_count;
+ memcpy(state->buf, rctx->buf, sizeof(state->buf));
return 0;
}
@@ -233,9 +236,12 @@ static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
static int ccp_aes_cmac_import(struct ahash_request *req, const void *in)
{
struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
- const struct ccp_aes_cmac_req_ctx *state = in;
+ const struct ccp_aes_cmac_exp_ctx *state = in;
- *rctx = *state;
+ rctx->null_msg = state->null_msg;
+ memcpy(rctx->iv, state->iv, sizeof(rctx->iv));
+ rctx->buf_count = state->buf_count;
+ memcpy(rctx->buf, state->buf, sizeof(rctx->buf));
return 0;
}
@@ -378,7 +384,7 @@ int ccp_register_aes_cmac_algs(struct list_head *head)
halg = &alg->halg;
halg->digestsize = AES_BLOCK_SIZE;
- halg->statesize = sizeof(struct ccp_aes_cmac_req_ctx);
+ halg->statesize = sizeof(struct ccp_aes_cmac_exp_ctx);
base = &halg->base;
snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "cmac(aes)");