diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2008-07-27 20:10:09 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2008-07-27 20:10:09 +0000 |
commit | ee00ec33bf3f15a7bb82edfecbaeeda9d7c4bc61 (patch) | |
tree | ed75631faa0cba93ce0207eeafe4466e3f9241ec /rbutil/sansapatcher/sansapatcher.c | |
parent | 95f906d1b0c1eddd5ffcdabec74b152b830fa213 (diff) | |
download | rockbox-ee00ec33bf3f15a7bb82edfecbaeeda9d7c4bc61.tar.gz rockbox-ee00ec33bf3f15a7bb82edfecbaeeda9d7c4bc61.zip |
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
Diffstat (limited to 'rbutil/sansapatcher/sansapatcher.c')
-rw-r--r-- | rbutil/sansapatcher/sansapatcher.c | 6 |
1 files 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) | |||
251 | 251 | ||
252 | /* Known keys for Sansa E200 and C200 firmwares: */ | 252 | /* Known keys for Sansa E200 and C200 firmwares: */ |
253 | #define NUM_KEYS ((int)(sizeof(keys)/sizeof(keys[0]))) | 253 | #define NUM_KEYS ((int)(sizeof(keys)/sizeof(keys[0]))) |
254 | static uint32_t keys[][4] = { | 254 | static const uint32_t keys[][4] = { |
255 | { 0xe494e96e, 0x3ee32966, 0x6f48512b, 0xa93fbb42 }, /* "sansa" */ | 255 | { 0xe494e96e, 0x3ee32966, 0x6f48512b, 0xa93fbb42 }, /* "sansa" */ |
256 | { 0xd7b10538, 0xc662945b, 0x1b3fce68, 0xf389c0e6 }, /* "sansa_gh" */ | 256 | { 0xd7b10538, 0xc662945b, 0x1b3fce68, 0xf389c0e6 }, /* "sansa_gh" */ |
257 | { 0x1d29ddc0, 0x2579c2cd, 0xce339e1a, 0x75465dfe }, /* sansa 103 */ | 257 | { 0x1d29ddc0, 0x2579c2cd, 0xce339e1a, 0x75465dfe }, /* sansa 103 */ |
@@ -561,6 +561,7 @@ static int prepare_original_firmware(struct sansa_t* sansa, unsigned char* buf, | |||
561 | unsigned char* tmpbuf; | 561 | unsigned char* tmpbuf; |
562 | int i; | 562 | int i; |
563 | int key_found; | 563 | int key_found; |
564 | uint32_t key[4]; | ||
564 | 565 | ||
565 | get_mi4header(buf,mi4header); | 566 | get_mi4header(buf,mi4header); |
566 | 567 | ||
@@ -584,10 +585,11 @@ static int prepare_original_firmware(struct sansa_t* sansa, unsigned char* buf, | |||
584 | 585 | ||
585 | key_found=0; | 586 | key_found=0; |
586 | for (i=0; i < NUM_KEYS && !key_found ; i++) { | 587 | for (i=0; i < NUM_KEYS && !key_found ; i++) { |
588 | memcpy(key, keys[i], sizeof(key)); | ||
587 | tea_decrypt_buf(buf+(mi4header->plaintext+0x200), | 589 | tea_decrypt_buf(buf+(mi4header->plaintext+0x200), |
588 | tmpbuf, | 590 | tmpbuf, |
589 | mi4header->mi4size-(mi4header->plaintext+0x200), | 591 | mi4header->mi4size-(mi4header->plaintext+0x200), |
590 | keys[i]); | 592 | key); |
591 | key_found = (le2uint(tmpbuf+mi4header->length-mi4header->plaintext-4) == 0xaa55aa55); | 593 | key_found = (le2uint(tmpbuf+mi4header->length-mi4header->plaintext-4) == 0xaa55aa55); |
592 | } | 594 | } |
593 | 595 | ||