clean up v2 encryption code
This commit is contained in:
+12
-34
@@ -118,21 +118,14 @@ void PSOLFGEncryption::encrypt_both_endian(
|
|||||||
|
|
||||||
PSOV2Encryption::PSOV2Encryption(uint32_t seed)
|
PSOV2Encryption::PSOV2Encryption(uint32_t seed)
|
||||||
: PSOLFGEncryption(seed, this->STREAM_LENGTH + 1, this->STREAM_LENGTH) {
|
: PSOLFGEncryption(seed, this->STREAM_LENGTH + 1, this->STREAM_LENGTH) {
|
||||||
uint32_t esi, ebx, edi, eax, edx, var1;
|
uint32_t a = 1, b = this->initial_seed;
|
||||||
esi = 1;
|
this->stream[0x37] = b;
|
||||||
ebx = this->initial_seed;
|
for (uint16_t virtual_index = 0x15; virtual_index <= 0x36 * 0x15; virtual_index += 0x15) {
|
||||||
edi = 0x15;
|
b -= a;
|
||||||
this->stream[56] = ebx;
|
this->stream[virtual_index % 0x37] = a;
|
||||||
this->stream[55] = ebx;
|
uint32_t c = a;
|
||||||
while (edi <= 0x46E) {
|
a = b;
|
||||||
eax = edi;
|
b = c;
|
||||||
var1 = eax / 55;
|
|
||||||
edx = eax - (var1 * 55);
|
|
||||||
ebx = ebx - esi;
|
|
||||||
edi = edi + 0x15;
|
|
||||||
this->stream[edx] = esi;
|
|
||||||
esi = ebx;
|
|
||||||
ebx = this->stream[edx];
|
|
||||||
}
|
}
|
||||||
for (size_t x = 0; x < 5; x++) {
|
for (size_t x = 0; x < 5; x++) {
|
||||||
this->update_stream();
|
this->update_stream();
|
||||||
@@ -141,26 +134,11 @@ PSOV2Encryption::PSOV2Encryption(uint32_t seed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PSOV2Encryption::update_stream() {
|
void PSOV2Encryption::update_stream() {
|
||||||
uint32_t esi, edi, eax, ebp, edx;
|
for (size_t z = 1; z < 0x19; z++) {
|
||||||
edi = 1;
|
this->stream[z] -= this->stream[z + 0x1F];
|
||||||
edx = 0x18;
|
|
||||||
eax = edi;
|
|
||||||
while (edx > 0) {
|
|
||||||
esi = this->stream[eax + 0x1F];
|
|
||||||
ebp = this->stream[eax] - esi;
|
|
||||||
this->stream[eax] = ebp;
|
|
||||||
eax++;
|
|
||||||
edx--;
|
|
||||||
}
|
}
|
||||||
edi = 0x19;
|
for (size_t z = 0x19; z < 0x38; z++) {
|
||||||
edx = 0x1F;
|
this->stream[z] -= this->stream[z - 0x18];
|
||||||
eax = edi;
|
|
||||||
while (edx > 0) {
|
|
||||||
esi = this->stream[eax - 0x18];
|
|
||||||
ebp = this->stream[eax] - esi;
|
|
||||||
this->stream[eax] = ebp;
|
|
||||||
eax++;
|
|
||||||
edx--;
|
|
||||||
}
|
}
|
||||||
this->offset = 1;
|
this->offset = 1;
|
||||||
this->cycles++;
|
this->cycles++;
|
||||||
|
|||||||
Reference in New Issue
Block a user