summaryrefslogtreecommitdiff
path: root/utils/zenutils/source/shared
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-26 13:21:52 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-26 13:21:52 +0000
commitbea2ab2398ca116a5cb3c62901769a1031b7d359 (patch)
treea91302573f14bd7f88b6aa12f751a83287a67785 /utils/zenutils/source/shared
parentaf5f8665e85cb2b151cd394b9209da6f6b03efb1 (diff)
downloadrockbox-bea2ab2398ca116a5cb3c62901769a1031b7d359.zip
rockbox-bea2ab2398ca116a5cb3c62901769a1031b7d359.tar.gz
rockbox-bea2ab2398ca116a5cb3c62901769a1031b7d359.tar.bz2
rockbox-bea2ab2398ca116a5cb3c62901769a1031b7d359.tar.xz
ZenUtils:
* add FRESC encryption * clean up code a bit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18345 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/source/shared')
-rw-r--r--utils/zenutils/source/shared/updater.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/utils/zenutils/source/shared/updater.cpp b/utils/zenutils/source/shared/updater.cpp
index 7efac3d..6f200e3 100644
--- a/utils/zenutils/source/shared/updater.cpp
+++ b/utils/zenutils/source/shared/updater.cpp
@@ -115,18 +115,18 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len)
return true;
#else
- // Determine if the key length is dword aligned.
+ /* Determine if the key length is dword aligned. */
int keylen = strlen(key);
int keylen_rem = keylen % sizeof(dword);
- // Determine how many times the key must be repeated to be dword aligned.
+ /* Determine how many times the key must be repeated to be dword aligned. */
int keycycle = keylen_rem ? (sizeof(dword) / keylen_rem) : 1;
int keyscount = (keylen * keycycle) / sizeof(dword);
- // Allocate a buffer to hold the key as an array of dwords.
+ /* Allocate a buffer to hold the key as an array of dwords. */
dword* keys = new dword[keyscount];
- // Copy the key into the key array, whilst mutating it.
+ /* Copy the key into the key array, whilst mutating it. */
for (int i = 0; i < keyscount; i++)
{
dword val;
@@ -145,19 +145,19 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len)
keys[i] = (val - 0x01010101) | 0x80808080;
}
- // Determine the number of dwords in the buffer.
+ /* Determine the number of dwords in the buffer. */
int len_div = len / sizeof(dword);
- // Decrypt all dwords of the buffer.
+ /* Decrypt all dwords of the buffer. */
for (int i = 0; i < len_div; i++)
{
((dword*)buffer)[i] ^= keys[i % keyscount];
}
- // Determine the remaining number of bytes in the buffer.
+ /* Determine the remaining number of bytes in the buffer. */
int len_rem = len % sizeof(dword);
- // Decrypt the remaining number of bytes in the buffer.
+ /* Decrypt the remaining number of bytes in the buffer. */
for (int i = len_div * sizeof(dword); i < len; i++)
{
buffer[i] ^= ((key[i % keylen] - 0x01) | 0x80);