From c2500b138a502f1af9601564479170088391b6a5 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Thu, 1 Dec 2016 01:14:47 +0100 Subject: [PATCH] Fix: crashes on A:/B: hex viewer repeated searches --- source/nand/aes.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/nand/aes.c b/source/nand/aes.c index 6bad542..e7ee103 100644 --- a/source/nand/aes.c +++ b/source/nand/aes.c @@ -126,18 +126,23 @@ void ctr_decrypt_boffset(void *inbuf, void *outbuf, size_t size, size_t off, uin if (off_fix) // handle misaligned offset (at beginning) { - for (i=off_fix; i= AES_BLOCK_SIZE) ? + AES_BLOCK_SIZE : off_fix + bytes_left; + for (i=off_fix; i= AES_BLOCK_SIZE) + { + ctr_decrypt(in, out, bytes_left / AES_BLOCK_SIZE, mode, ctr_local); + in += AES_BLOCK_SIZE * (uint32_t) (bytes_left / AES_BLOCK_SIZE); + out += AES_BLOCK_SIZE * (uint32_t) (bytes_left / AES_BLOCK_SIZE); + bytes_left -= AES_BLOCK_SIZE * (uint32_t) (bytes_left / AES_BLOCK_SIZE); + } if (bytes_left) // handle misaligned offset (at end) {