Commit 177e358c authored by Pascal van Leeuwen's avatar Pascal van Leeuwen Committed by Herbert Xu

crypto: inside-secure - Fix hang case on EIP97 with basic DES/3DES ops

This patch fixes another hang case on the EIP97 caused by sending
invalidation tokens to the hardware when doing basic (3)DES ECB/CBC
operations. Invalidation tokens are an EIP197 feature and needed nor
supported by the EIP97. So they should not be sent for that device.
Signed-off-by: default avatarPascal van Leeuwen <pvanleeuwen@rambus.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent cb97aa94
...@@ -1509,6 +1509,7 @@ static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key, ...@@ -1509,6 +1509,7 @@ static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key,
unsigned int len) unsigned int len)
{ {
struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm); struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm);
struct safexcel_crypto_priv *priv = ctx->priv;
int ret; int ret;
ret = verify_skcipher_des_key(ctfm, key); ret = verify_skcipher_des_key(ctfm, key);
...@@ -1516,7 +1517,7 @@ static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key, ...@@ -1516,7 +1517,7 @@ static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key,
return ret; return ret;
/* if context exits and key changed, need to invalidate it */ /* if context exits and key changed, need to invalidate it */
if (ctx->base.ctxr_dma) if (priv->flags & EIP197_TRC_CACHE && ctx->base.ctxr_dma)
if (memcmp(ctx->key, key, len)) if (memcmp(ctx->key, key, len))
ctx->base.needs_inv = true; ctx->base.needs_inv = true;
...@@ -1605,6 +1606,7 @@ static int safexcel_des3_ede_setkey(struct crypto_skcipher *ctfm, ...@@ -1605,6 +1606,7 @@ static int safexcel_des3_ede_setkey(struct crypto_skcipher *ctfm,
const u8 *key, unsigned int len) const u8 *key, unsigned int len)
{ {
struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm); struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm);
struct safexcel_crypto_priv *priv = ctx->priv;
int err; int err;
err = verify_skcipher_des3_key(ctfm, key); err = verify_skcipher_des3_key(ctfm, key);
...@@ -1612,7 +1614,7 @@ static int safexcel_des3_ede_setkey(struct crypto_skcipher *ctfm, ...@@ -1612,7 +1614,7 @@ static int safexcel_des3_ede_setkey(struct crypto_skcipher *ctfm,
return err; return err;
/* if context exits and key changed, need to invalidate it */ /* if context exits and key changed, need to invalidate it */
if (ctx->base.ctxr_dma) if (priv->flags & EIP197_TRC_CACHE && ctx->base.ctxr_dma)
if (memcmp(ctx->key, key, len)) if (memcmp(ctx->key, key, len))
ctx->base.needs_inv = true; ctx->base.needs_inv = true;
......
...@@ -282,7 +282,8 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv, ...@@ -282,7 +282,8 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv,
sreq->processed = sreq->block_sz; sreq->processed = sreq->block_sz;
sreq->hmac = 0; sreq->hmac = 0;
ctx->base.needs_inv = true; if (priv->flags & EIP197_TRC_CACHE)
ctx->base.needs_inv = true;
areq->nbytes = 0; areq->nbytes = 0;
safexcel_ahash_enqueue(areq); safexcel_ahash_enqueue(areq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment