Skip to content

Commit

Permalink
Cleanup the AES decryption code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
juhovh committed Nov 10, 2011
1 parent 2b8602b commit 0fdae6f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions hairtunes.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,10 @@ void alac_decode(short *dest, char *buf, int len) {
assert(len<=MAX_PACKET);

unsigned char iv[16];
int i;
int aeslen = len & ~0xf;
memcpy(iv, aesiv, sizeof(iv));
for (i=0; i+16<=len; i += 16)
AES_cbc_encrypt((unsigned char*)buf+i, packet+i, 0x10, &aes, iv, AES_DECRYPT);
if (len & 0xf)
memcpy(packet+i, buf+i, len & 0xf);
AES_cbc_encrypt((unsigned char*)buf, packet, aeslen, &aes, iv, AES_DECRYPT);
memcpy(packet+aeslen, buf+aeslen, len-aeslen);

int outsize;

Expand Down

0 comments on commit 0fdae6f

Please sign in to comment.