diff options
| author | Bertrik Sikken <bertrik@sikken.nl> | 2008-07-28 19:43:32 +0000 |
|---|---|---|
| committer | Bertrik Sikken <bertrik@sikken.nl> | 2008-07-28 19:43:32 +0000 |
| commit | c323d533c29fcf420df6b63ccf5c37340c7ba6c5 (patch) | |
| tree | c126261549ad5ec4c41e204a6f2bd06193647134 | |
| parent | 9b7566e3ec6586e0fc9df82e9cb1650287419308 (diff) | |
| download | rockbox-c323d533c29fcf420df6b63ccf5c37340c7ba6c5.zip rockbox-c323d533c29fcf420df6b63ccf5c37340c7ba6c5.tar.gz rockbox-c323d533c29fcf420df6b63ccf5c37340c7ba6c5.tar.bz2 rockbox-c323d533c29fcf420df6b63ccf5c37340c7ba6c5.tar.xz | |
Redo r18136 a little cleaner
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18141 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | rbutil/sansapatcher/sansapatcher.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c index 4f04179..eb6f7d1 100644 --- a/rbutil/sansapatcher/sansapatcher.c +++ b/rbutil/sansapatcher/sansapatcher.c @@ -292,11 +292,14 @@ static void tea_decrypt(uint32_t* v0, uint32_t* v1, const uint32_t* k) { integers) and the key is incremented after each block */ -static void tea_decrypt_buf(const unsigned char* src, unsigned char* dest, size_t n, uint32_t * key) +static void tea_decrypt_buf(const unsigned char* src, unsigned char* dest, + size_t n, const uint32_t * initial_key) { uint32_t v0, v1; unsigned int i; + uint32_t key[4]; + memcpy(key, initial_key, sizeof(key)); for (i = 0; i < (n / 8); i++) { v0 = le2int(src); v1 = le2int(src+4); @@ -561,7 +564,6 @@ 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); @@ -585,11 +587,10 @@ 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), - key); + keys[i]); key_found = (le2uint(tmpbuf+mi4header->length-mi4header->plaintext-4) == 0xaa55aa55); } |