diff options
Diffstat (limited to 'utils/zenutils/source/shared/updater.cpp')
-rw-r--r-- | utils/zenutils/source/shared/updater.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/utils/zenutils/source/shared/updater.cpp b/utils/zenutils/source/shared/updater.cpp index 7efac3d373..6f200e3da4 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) | |||
115 | 115 | ||
116 | return true; | 116 | return true; |
117 | #else | 117 | #else |
118 | // Determine if the key length is dword aligned. | 118 | /* Determine if the key length is dword aligned. */ |
119 | int keylen = strlen(key); | 119 | int keylen = strlen(key); |
120 | int keylen_rem = keylen % sizeof(dword); | 120 | int keylen_rem = keylen % sizeof(dword); |
121 | 121 | ||
122 | // Determine how many times the key must be repeated to be dword aligned. | 122 | /* Determine how many times the key must be repeated to be dword aligned. */ |
123 | int keycycle = keylen_rem ? (sizeof(dword) / keylen_rem) : 1; | 123 | int keycycle = keylen_rem ? (sizeof(dword) / keylen_rem) : 1; |
124 | int keyscount = (keylen * keycycle) / sizeof(dword); | 124 | int keyscount = (keylen * keycycle) / sizeof(dword); |
125 | 125 | ||
126 | // Allocate a buffer to hold the key as an array of dwords. | 126 | /* Allocate a buffer to hold the key as an array of dwords. */ |
127 | dword* keys = new dword[keyscount]; | 127 | dword* keys = new dword[keyscount]; |
128 | 128 | ||
129 | // Copy the key into the key array, whilst mutating it. | 129 | /* Copy the key into the key array, whilst mutating it. */ |
130 | for (int i = 0; i < keyscount; i++) | 130 | for (int i = 0; i < keyscount; i++) |
131 | { | 131 | { |
132 | dword val; | 132 | dword val; |
@@ -145,19 +145,19 @@ bool zen::crypt_firmware(const char* key, byte* buffer, size_t len) | |||
145 | keys[i] = (val - 0x01010101) | 0x80808080; | 145 | keys[i] = (val - 0x01010101) | 0x80808080; |
146 | } | 146 | } |
147 | 147 | ||
148 | // Determine the number of dwords in the buffer. | 148 | /* Determine the number of dwords in the buffer. */ |
149 | int len_div = len / sizeof(dword); | 149 | int len_div = len / sizeof(dword); |
150 | 150 | ||
151 | // Decrypt all dwords of the buffer. | 151 | /* Decrypt all dwords of the buffer. */ |
152 | for (int i = 0; i < len_div; i++) | 152 | for (int i = 0; i < len_div; i++) |
153 | { | 153 | { |
154 | ((dword*)buffer)[i] ^= keys[i % keyscount]; | 154 | ((dword*)buffer)[i] ^= keys[i % keyscount]; |
155 | } | 155 | } |
156 | 156 | ||
157 | // Determine the remaining number of bytes in the buffer. | 157 | /* Determine the remaining number of bytes in the buffer. */ |
158 | int len_rem = len % sizeof(dword); | 158 | int len_rem = len % sizeof(dword); |
159 | 159 | ||
160 | // Decrypt the remaining number of bytes in the buffer. | 160 | /* Decrypt the remaining number of bytes in the buffer. */ |
161 | for (int i = len_div * sizeof(dword); i < len; i++) | 161 | for (int i = len_div * sizeof(dword); i < len; i++) |
162 | { | 162 | { |
163 | buffer[i] ^= ((key[i % keylen] - 0x01) | 0x80); | 163 | buffer[i] ^= ((key[i % keylen] - 0x01) | 0x80); |