Skip to content

Commit 144839a

Browse files
yoshizaki-snisjaeckel
authored andcommitted
ltc: ctr: update pt and ct after acceleration
Problem occurs in the condition of the following case: 1st decryption: Decrypt a ciphertext whose length is a multiple of the block size (16B) (len = n * block_size) 2nd decryption: Decrypt the continuing ciphertext whose length is not a multiple of the block size (len = m * block_size + l) In this case accel_ctr_encrypt() is firstly used at the 2nd decryption. If pt and ct are not updated, the top (l = len % block_size) bytes of decryption result are sometimes destroyed. From: Tetsuya Yoshizaki <yoshizaki.tetsuya@socionext.com> Signed-off-by: Tetsuya Yoshizaki <yoshizaki.tetsuya@socionext.com> Signed-off-by: Victor Chong <victor.chong@linaro.org> (cherry picked from commit d1d3ae2)
1 parent 5501572 commit 144839a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/modes/ctr/ctr_encrypt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, s
5353
if ((err = cipher_descriptor[ctr->cipher].accel_ctr_encrypt(pt, ct, len/ctr->blocklen, ctr->ctr, ctr->mode, &ctr->key)) != CRYPT_OK) {
5454
return err;
5555
}
56+
pt += (len / ctr->blocklen) * ctr->blocklen;
57+
ct += (len / ctr->blocklen) * ctr->blocklen;
5658
len %= ctr->blocklen;
5759
}
5860

0 commit comments

Comments
 (0)