From ee00ec33bf3f15a7bb82edfecbaeeda9d7c4bc61 Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Sun, 27 Jul 2008 20:10:09 +0000 Subject: Make sure to always use the initial key for decryption of mi4 files in sansapatcher. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18136 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/sansapatcher/sansapatcher.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c index 78e6e61225..4f04179064 100644 --- a/rbutil/sansapatcher/sansapatcher.c +++ b/rbutil/sansapatcher/sansapatcher.c @@ -251,7 +251,7 @@ static void chksum_crc32gentab (void) /* Known keys for Sansa E200 and C200 firmwares: */ #define NUM_KEYS ((int)(sizeof(keys)/sizeof(keys[0]))) -static uint32_t keys[][4] = { +static const uint32_t keys[][4] = { { 0xe494e96e, 0x3ee32966, 0x6f48512b, 0xa93fbb42 }, /* "sansa" */ { 0xd7b10538, 0xc662945b, 0x1b3fce68, 0xf389c0e6 }, /* "sansa_gh" */ { 0x1d29ddc0, 0x2579c2cd, 0xce339e1a, 0x75465dfe }, /* sansa 103 */ @@ -561,6 +561,7 @@ static int prepare_original_firmware(struct sansa_t* sansa, unsigned char* buf, unsigned char* tmpbuf; int i; int key_found; + uint32_t key[4]; get_mi4header(buf,mi4header); @@ -584,10 +585,11 @@ static int prepare_original_firmware(struct sansa_t* sansa, unsigned char* buf, key_found=0; for (i=0; i < NUM_KEYS && !key_found ; i++) { + memcpy(key, keys[i], sizeof(key)); tea_decrypt_buf(buf+(mi4header->plaintext+0x200), tmpbuf, mi4header->mi4size-(mi4header->plaintext+0x200), - keys[i]); + key); key_found = (le2uint(tmpbuf+mi4header->length-mi4header->plaintext-4) == 0xaa55aa55); } -- cgit v1.2.3