Skip to content

Commit

Permalink
crypto: chelsio - Fix wrong error counter increments
Browse files Browse the repository at this point in the history
Fix error counter increment in AEAD decrypt operation when
validation of tag is done in Driver instead of H/W.

Signed-off-by: Harsh Jain <harsh@chelsio.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Harsh Jain authored and herbertx committed Dec 23, 2018
1 parent 6501ab5 commit f31ba0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 5 additions & 4 deletions drivers/crypto/chelsio/chcr_algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static inline void chcr_dec_wrcount(struct chcr_dev *dev)
atomic_dec(&dev->inflight);
}

static inline void chcr_handle_aead_resp(struct aead_request *req,
static inline int chcr_handle_aead_resp(struct aead_request *req,
unsigned char *input,
int err)
{
Expand All @@ -233,6 +233,8 @@ static inline void chcr_handle_aead_resp(struct aead_request *req,
}
chcr_dec_wrcount(dev);
req->base.complete(&req->base, err);

return err;
}

static void get_aes_decrypt_key(unsigned char *dec_key,
Expand Down Expand Up @@ -2072,14 +2074,13 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,

switch (tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
case CRYPTO_ALG_TYPE_AEAD:
chcr_handle_aead_resp(aead_request_cast(req), input, err);
err = chcr_handle_aead_resp(aead_request_cast(req), input, err);
break;

case CRYPTO_ALG_TYPE_ABLKCIPHER:
err = chcr_handle_cipher_resp(ablkcipher_request_cast(req),
chcr_handle_cipher_resp(ablkcipher_request_cast(req),
input, err);
break;

case CRYPTO_ALG_TYPE_AHASH:
chcr_handle_ahash_resp(ahash_request_cast(req), input, err);
}
Expand Down
11 changes: 5 additions & 6 deletions drivers/crypto/chelsio/chcr_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,18 @@ static int cpl_fw6_pld_handler(struct chcr_dev *dev,

ack_err_status =
ntohl(*(__be32 *)((unsigned char *)&fw6_pld->data[0] + 4));
if (ack_err_status) {
if (CHK_MAC_ERR_BIT(ack_err_status) ||
CHK_PAD_ERR_BIT(ack_err_status))
error_status = -EBADMSG;
atomic_inc(&adap->chcr_stats.error);
}
if (CHK_MAC_ERR_BIT(ack_err_status) || CHK_PAD_ERR_BIT(ack_err_status))
error_status = -EBADMSG;
/* call completion callback with failure status */
if (req) {
error_status = chcr_handle_resp(req, input, error_status);
} else {
pr_err("Incorrect request address from the firmware\n");
return -EFAULT;
}
if (error_status)
atomic_inc(&adap->chcr_stats.error);

return 0;
}

Expand Down

0 comments on commit f31ba0f

Please sign in to comment.