summaryrefslogtreecommitdiff
path: root/drivers/crypto/caam
diff options
context:
space:
mode:
authorVakul Garg <vakul@freescale.com>2014-04-25 21:22:31 (GMT)
committerJose Rivera <German.Rivera@freescale.com>2014-04-26 02:04:05 (GMT)
commit139ba80dd8dfe49189c638e787867dc69e6b7874 (patch)
tree1d052f5474e81b51c5b268dc9781c40574c9bfc0 /drivers/crypto/caam
parent50b963557ed5df3f6296e7d0c90e73da24cd7feb (diff)
downloadlinux-fsl-qoriq-139ba80dd8dfe49189c638e787867dc69e6b7874.tar.xz
crypto: caam - Fix key inlining in AEAD shared descriptors
The variable 'keys_fit_inline' is initialised correctly to avoid using its stale value while creating shared descriptor for decryption and given-iv-encryption. Signed-off-by: Vakul Garg <vakul@freescale.com> Change-Id: I4e1482a7c9ea21b02523f90fc9ed68a61817c0be Reviewed-on: http://git.am.freescale.net:8181/11546 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Jose Rivera <German.Rivera@freescale.com>
Diffstat (limited to 'drivers/crypto/caam')
-rw-r--r--drivers/crypto/caam/caamalg.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index c41d284..2a4eb70 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -216,7 +216,7 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead)
struct aead_tfm *tfm = &aead->base.crt_aead;
struct caam_ctx *ctx = crypto_aead_ctx(aead);
struct device *jrdev = ctx->jrdev;
- bool keys_fit_inline = false;
+ bool keys_fit_inline;
u32 *key_jump_cmd, *jump_cmd, *read_move_cmd, *write_move_cmd;
u32 *desc;
@@ -227,6 +227,8 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead)
if (DESC_AEAD_NULL_ENC_LEN + DESC_JOB_IO_LEN +
ctx->split_key_pad_len <= CAAM_DESC_BYTES_MAX)
keys_fit_inline = true;
+ else
+ keys_fit_inline = false;
/* aead_encrypt shared descriptor */
desc = ctx->sh_desc_enc;
@@ -313,6 +315,8 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead)
if (DESC_AEAD_NULL_DEC_LEN + DESC_JOB_IO_LEN +
ctx->split_key_pad_len <= CAAM_DESC_BYTES_MAX)
keys_fit_inline = true;
+ else
+ keys_fit_inline = false;
desc = ctx->sh_desc_dec;
@@ -406,7 +410,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
struct aead_tfm *tfm = &aead->base.crt_aead;
struct caam_ctx *ctx = crypto_aead_ctx(aead);
struct device *jrdev = ctx->jrdev;
- bool keys_fit_inline = false;
+ bool keys_fit_inline;
u32 geniv, moveiv;
u32 *desc;
@@ -425,6 +429,9 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
ctx->split_key_pad_len + ctx->enckeylen <=
CAAM_DESC_BYTES_MAX)
keys_fit_inline = true;
+ else
+ keys_fit_inline = false;
+
/* aead_encrypt shared descriptor */
desc = ctx->sh_desc_enc;
@@ -483,6 +490,8 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
ctx->split_key_pad_len + ctx->enckeylen <=
CAAM_DESC_BYTES_MAX)
keys_fit_inline = true;
+ else
+ keys_fit_inline = false;
/* aead_decrypt shared descriptor */
desc = ctx->sh_desc_dec;
@@ -538,6 +547,8 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
ctx->split_key_pad_len + ctx->enckeylen <=
CAAM_DESC_BYTES_MAX)
keys_fit_inline = true;
+ else
+ keys_fit_inline = false;
/* aead_givencrypt shared descriptor */
desc = ctx->sh_desc_givenc;
@@ -632,7 +643,7 @@ static int tls_set_sh_desc(struct crypto_aead *aead)
struct aead_tfm *tfm = &aead->base.crt_aead;
struct caam_ctx *ctx = crypto_aead_ctx(aead);
struct device *jrdev = ctx->jrdev;
- bool keys_fit_inline = false;
+ bool keys_fit_inline;
u32 *key_jump_cmd, *zero_payload_jump_cmd, *skip_zero_jump_cmd;
u32 genpad, idx_ld_datasz, idx_ld_pad, jumpback, stidx;
u32 *desc;
@@ -663,6 +674,8 @@ static int tls_set_sh_desc(struct crypto_aead *aead)
idx_ld_pad = DESC_TLS10_ENC_LEN + ctx->split_key_pad_len +
ctx->enckeylen - 2 * CAAM_CMD_SZ;
} else {
+ keys_fit_inline = false;
+
idx_ld_datasz = DESC_TLS10_ENC_LEN + 2 * CAAM_PTR_SZ -
4 * CAAM_CMD_SZ;
idx_ld_pad = DESC_TLS10_ENC_LEN + 2 * CAAM_PTR_SZ -