encrypt: Simplify initialization code
This avoids destructors being even needed.
This commit is contained in:
parent
7de7d6c1c5
commit
87cb2f648f
|
@ -55,7 +55,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//TODO - do we need these here?
|
//TODO - do we need these here?
|
||||||
_KEY2 key2;
|
static _KEY2 key2;
|
||||||
|
|
||||||
//http://home.utah.edu/~nahaj/factoring/isqrt.c.html
|
//http://home.utah.edu/~nahaj/factoring/isqrt.c.html
|
||||||
static u64 isqrt (u64 x) {
|
static u64 isqrt (u64 x) {
|
||||||
|
|
|
@ -20,28 +20,12 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
struct _KEY1
|
struct _KEY1 final
|
||||||
{
|
{
|
||||||
_KEY1(const u8 *inKeyBufPtr)
|
_KEY1(const u8 *inKeyBufPtr) : keyBufPtr(inKeyBufPtr) {}
|
||||||
{
|
|
||||||
if (keyBuf) delete[] keyBuf;
|
|
||||||
keyBuf = new u32 [0x412];
|
|
||||||
memset(keyBuf, 0x00, 0x412 * sizeof(u32));
|
|
||||||
memset(&keyCode[0], 0, sizeof(keyCode));
|
|
||||||
this->keyBufPtr = inKeyBufPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
~_KEY1()
|
u32 keyBuf[0x412] = {};
|
||||||
{
|
u32 keyCode[3] = {};
|
||||||
if (keyBuf)
|
|
||||||
{
|
|
||||||
delete[] keyBuf;
|
|
||||||
keyBuf = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 *keyBuf;
|
|
||||||
u32 keyCode[3];
|
|
||||||
const u8 *keyBufPtr;
|
const u8 *keyBufPtr;
|
||||||
|
|
||||||
void init(u32 idcode, u8 level, u8 modulo);
|
void init(u32 idcode, u8 level, u8 modulo);
|
||||||
|
@ -50,23 +34,19 @@ struct _KEY1
|
||||||
void encrypt(u32 *ptr);
|
void encrypt(u32 *ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _KEY2
|
struct _KEY2 final
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
u64 seed0;
|
u64 seed0 = 0x58C56DE0E8ULL;
|
||||||
u64 seed1;
|
u64 seed1 = 0x5C879B9B05ULL;
|
||||||
u64 x;
|
u64 x;
|
||||||
u64 y;
|
u64 y;
|
||||||
|
|
||||||
u64 bitsReverse39(u64 key);
|
u64 bitsReverse39(u64 key);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_KEY2() : seed0(0x58C56DE0E8ULL),
|
|
||||||
seed1(0x5C879B9B05ULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void applySeed(u8 PROCNUM);
|
void applySeed(u8 PROCNUM);
|
||||||
u8 apply(u8 data);
|
u8 apply(u8 data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue