fix pidgen3, finally plumb in pid 2.0

This commit is contained in:
Neo-Desktop
2024-02-17 08:07:37 -08:00
parent 2ac7f9bc1e
commit 015fd00d3f
29 changed files with 1651 additions and 1211 deletions

View File

@@ -23,19 +23,20 @@
#ifndef UMSKT_PIDGEN3_H
#define UMSKT_PIDGEN3_H
#include "../libumskt.h"
#include "../pidgen.h"
class BINK1998;
class BINK2002;
class EXPORT PIDGEN3
class EXPORT PIDGEN3 : public PIDGEN
{
friend class BINK1998;
friend class BINK2002;
protected:
Integer BINKID;
Integer privateKey, genOrder;
ECP::Point genPoint, pubPoint;
ECP::Point pubPoint, genPoint;
ECP eCurve;
public:
@@ -45,8 +46,8 @@ class EXPORT PIDGEN3
{
privateKey = p3.privateKey;
genOrder = p3.genOrder;
genPoint = p3.genPoint;
pubPoint = p3.pubPoint;
genPoint = p3.genPoint;
eCurve = p3.eCurve;
}
@@ -56,43 +57,50 @@ class EXPORT PIDGEN3
struct KeyInfo
{
Integer Serial = 0, AuthInfo = 0, ChannelID = 0, Hash = 0, Signature = 0;
BOOL isUpgrade = false;
Integer Serial = 0, AuthInfo = 0, ChannelID = 0, Hash = 0, Signature = 0, Rand = 0;
BOOL isUpgrade = false, isOEM = false;
void setSerial(DWORD32 serialIn)
void setSerial(DWORD32 SerialIn)
{
Serial.Decode((BYTE *)&serialIn, sizeof(serialIn));
Serial = IntegerN(SerialIn);
}
void setAuthInfo(DWORD32 AuthInfoIn)
{
AuthInfo.Decode((BYTE *)&AuthInfoIn, sizeof(AuthInfoIn));
AuthInfo = IntegerN(AuthInfoIn);
}
void setChannelID(DWORD32 ChannelIDIn)
{
ChannelID.Decode((BYTE *)&ChannelIDIn, sizeof(ChannelIDIn));
ChannelID = IntegerN(ChannelIDIn);
}
} info;
static constexpr char pKeyCharset[] = "BCDFGHJKMPQRTVWXY2346789";
static const Integer MaxSizeBINK1998;
static const std::string pKeyCharset;
static const DWORD32 MaxSizeBINK1998;
BOOL LoadEllipticCurve(std::string pSel, std::string aSel, std::string bSel, std::string generatorXSel,
std::string generatorYSel, std::string publicKeyXSel, std::string publicKeyYSel,
std::string genOrderSel, std::string privateKeySel);
BOOL LoadEllipticCurve(const std::string &BinkIDSel, const std::string &pSel, const std::string &aSel,
const std::string &bSel, const std::string &generatorXSel, const std::string &generatorYSel,
const std::string &publicKeyXSel, const std::string &publicKeyYSel,
const std::string &genOrderSel, const std::string &privateKeySel);
virtual BOOL Pack(Q_OWORD *pRaw) = 0;
virtual BOOL Unpack(Q_OWORD *pRaw) = 0;
virtual BOOL Generate(std::string &pKey);
virtual BOOL Validate(std::string &pKey);
BOOL Generate(std::string &pKey) override;
BOOL Validate(const std::string &pKey) override;
std::string StringifyKey(const std::string &pKey) override;
std::string StringifyProductID() override;
virtual Integer Pack(const KeyInfo &ki) = 0;
virtual KeyInfo Unpack(const Integer &raw) = 0;
// PIDGEN3.cpp
void base24(std::string &cdKey, BYTE *byteSeq);
void unbase24(BYTE *byteSeq, std::string cdKey);
BOOL checkFieldIsBink1998();
static BOOL checkFieldStrIsBink1998(std::string keyin);
static PIDGEN3 *Factory(const std::string &field);
static BOOL checkFieldStrIsBink1998(std::string keyin);
static std::string ValidateStringKeyInputCharset(std::string &accumulator, char currentChar);
static BOOL ValidateKeyString(const std::string &in_key, std::string &out_key);
static std::string base24(Integer &seq);
static Integer unbase24(const std::string &cdKey);
BOOL checkFieldIsBink1998();
};
#endif // UMSKT_PIDGEN3_H