Skip to content

Commit edf64f3

Browse files
committed
crypto: atmel-tdes - Detecting in-place operations with two sg lists
Avoiding detecting finely in-place operations with different scatter lists. Copying the source data for decryption into rctx->lastc regardless if the operation is in-place or not. This allows in-place operations with different scatter lists without affecting other operations. This approach takes less resources than parsing both scatter lists to check if they are equal. Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
1 parent 2d73e1b commit edf64f3

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

drivers/crypto/atmel-tdes.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -565,17 +565,12 @@ atmel_tdes_set_iv_as_last_ciphertext_block(struct atmel_tdes_dev *dd)
565565
if (req->cryptlen < ivsize)
566566
return;
567567

568-
if (rctx->mode & TDES_FLAGS_ENCRYPT) {
568+
if (rctx->mode & TDES_FLAGS_ENCRYPT)
569569
scatterwalk_map_and_copy(req->iv, req->dst,
570570
req->cryptlen - ivsize, ivsize, 0);
571-
} else {
572-
if (req->src == req->dst)
573-
memcpy(req->iv, rctx->lastc, ivsize);
574-
else
575-
scatterwalk_map_and_copy(req->iv, req->src,
576-
req->cryptlen - ivsize,
577-
ivsize, 0);
578-
}
571+
else
572+
memcpy(req->iv, rctx->lastc, ivsize);
573+
579574
}
580575

581576
static void atmel_tdes_finish_req(struct atmel_tdes_dev *dd, int err)
@@ -722,7 +717,7 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode)
722717
rctx->mode = mode;
723718

724719
if ((mode & TDES_FLAGS_OPMODE_MASK) != TDES_FLAGS_ECB &&
725-
!(mode & TDES_FLAGS_ENCRYPT) && req->src == req->dst) {
720+
!(mode & TDES_FLAGS_ENCRYPT)) {
726721
unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
727722

728723
if (req->cryptlen >= ivsize)

0 commit comments

Comments
 (0)