Skip to content

Commit 0a6a28f

Browse files
committed
crypto: atmel-aes - Detecting in-place operations 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. 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 edf64f3 commit 0a6a28f

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

drivers/crypto/atmel-aes.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -493,17 +493,11 @@ static void atmel_aes_set_iv_as_last_ciphertext_block(struct atmel_aes_dev *dd)
493493
if (req->cryptlen < ivsize)
494494
return;
495495

496-
if (rctx->mode & AES_FLAGS_ENCRYPT) {
496+
if (rctx->mode & AES_FLAGS_ENCRYPT)
497497
scatterwalk_map_and_copy(req->iv, req->dst,
498498
req->cryptlen - ivsize, ivsize, 0);
499-
} else {
500-
if (req->src == req->dst)
501-
memcpy(req->iv, rctx->lastc, ivsize);
502-
else
503-
scatterwalk_map_and_copy(req->iv, req->src,
504-
req->cryptlen - ivsize,
505-
ivsize, 0);
506-
}
499+
else
500+
memcpy(req->iv, rctx->lastc, ivsize);
507501
}
508502

509503
static inline struct atmel_aes_ctr_ctx *
@@ -1146,7 +1140,7 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode)
11461140
rctx->mode = mode;
11471141

11481142
if (opmode != AES_FLAGS_ECB &&
1149-
!(mode & AES_FLAGS_ENCRYPT) && req->src == req->dst) {
1143+
!(mode & AES_FLAGS_ENCRYPT)) {
11501144
unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
11511145

11521146
if (req->cryptlen >= ivsize)

0 commit comments

Comments
 (0)