This commit is contained in:
Andrew 2023-06-09 21:07:29 +03:00
parent eed869981b
commit f11552509a
6 changed files with 71 additions and 24 deletions

View File

@ -45,7 +45,7 @@ bool BINK1998::Verify(
EC_GROUP *eCurve,
EC_POINT *basePoint,
EC_POINT *publicKey,
char (&pKey)[25]
char (&pKey)[25]
) {
BN_CTX *numContext = BN_CTX_new();
@ -136,10 +136,10 @@ bool BINK1998::Verify(
void BINK1998::Generate(
EC_GROUP *eCurve,
EC_POINT *basePoint,
BIGNUM *genOrder,
BIGNUM *privateKey,
DWORD pSerial,
char (&pKey)[25]
BIGNUM *genOrder,
BIGNUM *privateKey,
DWORD pSerial,
char (&pKey)[25]
) {
BN_CTX *numContext = BN_CTX_new();

View File

@ -8,12 +8,34 @@
#include "header.h"
class BINK1998 {
static void Unpack (QWORD (&pRaw)[2], DWORD &pSerial, DWORD &pHash, QWORD &pSignature);
static void Pack (QWORD (&pRaw)[2], DWORD pSerial, DWORD pHash, QWORD pSignature);
static void Unpack(
QWORD (&pRaw)[2],
DWORD &pSerial,
DWORD &pHash,
QWORD &pSignature
);
static void Pack(
QWORD (&pRaw)[2],
DWORD pSerial,
DWORD pHash,
QWORD pSignature
);
public:
static bool Verify (EC_GROUP *eCurve, EC_POINT *basePoint, EC_POINT *publicKey, char (&pKey)[25]);
static void Generate (EC_GROUP *eCurve, EC_POINT *basePoint, BIGNUM *genOrder, BIGNUM *privateKey, DWORD pSerial, char (&pKey)[25]);
static bool Verify(
EC_GROUP *eCurve,
EC_POINT *basePoint,
EC_POINT *publicKey,
char (&pKey)[25]
);
static void Generate(
EC_GROUP *eCurve,
EC_POINT *basePoint,
BIGNUM *genOrder,
BIGNUM *privateKey,
DWORD pSerial,
char (&pKey)[25]
);
};
#endif //WINDOWSXPKG_BINK1998_H

View File

@ -35,7 +35,7 @@ void BINK2002::Pack(
QWORD (&pRaw)[2],
DWORD pChannelID,
DWORD pHash,
QWORD &pSignature,
QWORD pSignature,
DWORD pAuthInfo
) {
// AuthInfo [113..104] <- Signature [103..42] <- Hash [41..11] <- Channel ID [10..1] <- Upgrade [0]
@ -48,7 +48,7 @@ bool BINK2002::Verify(
EC_GROUP *eCurve,
EC_POINT *basePoint,
EC_POINT *publicKey,
char (&cdKey)[25]
char (&cdKey)[25]
) {
BN_CTX *context = BN_CTX_new();
@ -174,11 +174,11 @@ bool BINK2002::Verify(
void BINK2002::Generate(
EC_GROUP *eCurve,
EC_POINT *basePoint,
BIGNUM *genOrder,
BIGNUM *privateKey,
DWORD pChannelID,
DWORD pAuthInfo,
char (&pKey)[25]
BIGNUM *genOrder,
BIGNUM *privateKey,
DWORD pChannelID,
DWORD pAuthInfo,
char (&pKey)[25]
) {
BN_CTX *numContext = BN_CTX_new();

View File

@ -8,12 +8,37 @@
#include "header.h"
class BINK2002 {
static void Unpack (QWORD (&pRaw)[2], DWORD &pChannelID, DWORD &pHash, QWORD &pSignature, DWORD &pAuthInfo);
static void Pack (QWORD (&pRaw)[2], DWORD pChannelID, DWORD pHash, QWORD &pSignature, DWORD pAuthInfo);
static void Unpack(
QWORD (&pRaw)[2],
DWORD &pChannelID,
DWORD &pHash,
QWORD &pSignature,
DWORD &pAuthInfo
);
static void Pack(
QWORD (&pRaw)[2],
DWORD pChannelID,
DWORD pHash,
QWORD pSignature,
DWORD pAuthInfo
);
public:
static bool Verify (EC_GROUP *eCurve, EC_POINT *basePoint, EC_POINT *publicKey, char (&cdKey)[25]);
static void Generate (EC_GROUP *eCurve, EC_POINT *basePoint, BIGNUM *genOrder, BIGNUM *privateKey, DWORD pChannelID, DWORD pAuthInfo, char (&pKey)[25]);
static bool Verify(
EC_GROUP *eCurve,
EC_POINT *basePoint,
EC_POINT *publicKey,
char (&cdKey)[25]
);
static void Generate(
EC_GROUP *eCurve,
EC_POINT *basePoint,
BIGNUM *genOrder,
BIGNUM *privateKey,
DWORD pChannelID,
DWORD pAuthInfo,
char (&pKey)[25]
);
};
#endif //WINDOWSXPKG_BINK2002_H

View File

@ -30,7 +30,7 @@ QWORD ConfirmationID::residue_sub(QWORD x, QWORD y)
#ifdef __GNUC__
inline QWORD ConfirmationID::__umul128(QWORD a, QWORD b, QWORD* hi)
{
DQWORD r = (DQWORD)a * (DQWORD)b;
OWORD r = (OWORD)a * (OWORD)b;
*hi = r >> 64;
return (QWORD) r;
}

View File

@ -87,7 +87,7 @@ typedef uint32_t DWORD;
typedef uint64_t QWORD;
#ifdef __SIZEOF_INT128__
typedef unsigned __int128 DQWORD;
typedef unsigned __int128 OWORD;
#endif
// Global variables
@ -104,8 +104,8 @@ EC_GROUP *initializeEllipticCurve(
std::string generatorYSel,
std::string publicKeyXSel,
std::string publicKeyYSel,
EC_POINT *&genPoint,
EC_POINT *&pubPoint
EC_POINT *&genPoint,
EC_POINT *&pubPoint
);
// key.cpp