Skip to content

Commit 27f4adf

Browse files
ambarusherbertx
authored andcommitted
crypto: atmel-{aes,tdes} - Update the IV only when the op succeeds
Do not update the IV in case of errors. Signed-off-by: Tudor Ambarus <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent e9ce6ae commit 27f4adf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/crypto/atmel-aes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err)
546546
clk_disable(dd->iclk);
547547
dd->flags &= ~AES_FLAGS_BUSY;
548548

549-
if (!dd->ctx->is_aead &&
549+
if (!err && !dd->ctx->is_aead &&
550550
(rctx->mode & AES_FLAGS_OPMODE_MASK) != AES_FLAGS_ECB) {
551551
if ((rctx->mode & AES_FLAGS_OPMODE_MASK) != AES_FLAGS_CTR)
552552
atmel_aes_set_iv_as_last_ciphertext_block(dd);

drivers/crypto/atmel-tdes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static void atmel_tdes_finish_req(struct atmel_tdes_dev *dd, int err)
597597

598598
dd->flags &= ~TDES_FLAGS_BUSY;
599599

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

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

0 commit comments

Comments
 (0)