This commit is contained in:
Martin Michelsen
2022-12-02 23:35:02 -08:00
parent 85fbd1b389
commit 9f4b53178a
2 changed files with 45 additions and 0 deletions
+29
View File
@@ -837,6 +837,35 @@ shared_ptr<PSOBBEncryption> PSOBBMultiKeyImitatorEncryption::ensure_crypt() {
JSD0Encryption::JSD0Encryption(const void* seed, size_t seed_size) : key(0) {
const uint8_t* bytes = reinterpret_cast<const uint8_t*>(seed);
for (size_t z = 0; z < seed_size; z++) {
this->key ^= bytes[z];
}
}
void JSD0Encryption::decrypt(void* data, size_t size, bool) {
uint8_t* bytes = reinterpret_cast<uint8_t*>(data);
for (size_t z = 0; z < size; z++) {
bytes[z] ^= this->key;
bytes[z] -= this->key;
}
}
void JSD0Encryption::encrypt(void* data, size_t size, bool) {
uint8_t* bytes = reinterpret_cast<uint8_t*>(data);
for (size_t z = 0; z < size; z++) {
bytes[z] += this->key;
bytes[z] ^= this->key;
}
}
PSOEncryption::Type JSD0Encryption::type() const {
return Type::JSD0;
}
void decrypt_trivial_gci_data(void* data, size_t size, uint8_t basis) {
uint8_t* bytes = reinterpret_cast<uint8_t*>(data);
uint8_t key = basis + 0x80;
+16
View File
@@ -18,6 +18,7 @@ public:
V2 = 0,
V3,
BB,
JSD0,
};
virtual ~PSOEncryption() = default;
@@ -229,4 +230,19 @@ protected:
class JSD0Encryption : public PSOEncryption {
public:
JSD0Encryption(const void* seed, size_t seed_size);
virtual void encrypt(void* data, size_t size, bool advance = true);
virtual void decrypt(void* data, size_t size, bool advance = true);
virtual Type type() const = 0;
private:
uint8_t key;
};
void decrypt_trivial_gci_data(void* data, size_t size, uint8_t basis);