Skip to content

Commit

Permalink
crypto: atmel-{aes,tdes} - Update the IV only when the op succeeds
Browse files Browse the repository at this point in the history
Do not update the IV in case of errors.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Tudor Ambarus authored and Herbert Xu committed Dec 20, 2019
1 parent e9ce6ae commit 27f4adf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/crypto/atmel-aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err)
clk_disable(dd->iclk);
dd->flags &= ~AES_FLAGS_BUSY;

if (!dd->ctx->is_aead &&
if (!err && !dd->ctx->is_aead &&
(rctx->mode & AES_FLAGS_OPMODE_MASK) != AES_FLAGS_ECB) {
if ((rctx->mode & AES_FLAGS_OPMODE_MASK) != AES_FLAGS_CTR)
atmel_aes_set_iv_as_last_ciphertext_block(dd);
Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/atmel-tdes.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ static void atmel_tdes_finish_req(struct atmel_tdes_dev *dd, int err)

dd->flags &= ~TDES_FLAGS_BUSY;

if ((rctx->mode & TDES_FLAGS_OPMODE_MASK) != TDES_FLAGS_ECB)
if (!err && (rctx->mode & TDES_FLAGS_OPMODE_MASK) != TDES_FLAGS_ECB)
atmel_tdes_set_iv_as_last_ciphertext_block(dd);

req->base.complete(&req->base, err);
Expand Down

0 comments on commit 27f4adf

Please sign in to comment.