26 lines
728 B
C
26 lines
728 B
C
#include "decrypt.h"
|
|
#include "utils/decryptUtilities.h"
|
|
|
|
struct DECRYPTION_DATA {
|
|
uint32_t key0;
|
|
uint32_t key1;
|
|
uint32_t key2;
|
|
};
|
|
|
|
struct DECRYPTION_DATA decryptor;
|
|
|
|
void initDecryptor(uint32_t key0, uint32_t key1, uint32_t key2) {
|
|
decryptor.key0 = key0;
|
|
decryptor.key1 = key1;
|
|
decryptor.key2 = key2;
|
|
}
|
|
|
|
/** Decrypts the given input in-place. The input buffer will be modified. */
|
|
void decrypt(unsigned char chunk[], unsigned long length) {
|
|
for (unsigned long i = 0; i < length; i += 1) {
|
|
unsigned char testChar = chunk[i];
|
|
testChar = testChar ^ decryptByte((uint16_t)(decryptor.key2 | 2));
|
|
updateKeys(&(decryptor.key0), &(decryptor.key1), &(decryptor.key2), testChar);
|
|
chunk[i] = testChar;
|
|
}
|
|
}
|