// // Created by Andrew on 09/04/2023. // #ifndef KEYGEN_HEADER_H #define KEYGEN_HEADER_H #include #include #include #include #include #include #include #include #define PK_LENGTH 25 #define NULL_TERMINATOR 1 #define FIELD_BITS 384 #define FIELD_BYTES (FIELD_BITS / 8) #define FIELD_BITS_2003 512 #define FIELD_BYTES_2003 (FIELD_BITS_2003 / 8) #define SHA_MSG_LENGTH_XP (4 + 2 * FIELD_BYTES) #define SHA_MSG_LENGTH_2003 (3 + 2 * FIELD_BYTES_2003) #define NEXTSNBITS(field, n, offset) (((QWORD)(field) >> (offset)) & ((1ULL << (n)) - 1)) #define FIRSTNBITS(field, n) NEXTSNBITS((field), (n), 0) #define HIBYTES(field, bytes) NEXTSNBITS((QWORD)(field), ((bytes) * 8), ((bytes) * 8)) #define LOBYTES(field, bytes) FIRSTNBITS((QWORD)(field), ((bytes) * 8)) #define BYDWORD(n) (DWORD)(*((n) + 0) | *((n) + 1) << 8 | *((n) + 2) << 16 | *((n) + 3) << 24) #define BITMASK(n) ((1ULL << (n)) - 1) #define IDC_BUTTON1 1000 #define IDC_BUTTON2 1001 #define IDC_BUTTON3 1002 #define IDC_BUTTON4 1003 #define IDC_COMBO1 1020 #define IDC_RADIO1 1030 #define IDC_RADIO2 1031 #define IDC_CHECK1 1036 #define IDC_EDIT1 1040 #define IDC_INPUT1 1060 #define IDC_INPUT2 1061 #define IDC_INPUT3 1062 #define IDC_IMAGE1 1080 #define IDC_IMAGE2 1081 #define IDC_LABEL1 1105 #define IDC_LABEL2 1106 #define IDC_LABEL3 1107 #define IDC_LABEL4 1108 #define IDC_LABEL5 1109 #define IDC_LABEL6 1110 typedef uint64_t QWORD; extern char pCharset[]; extern const char pXP[]; extern const long aXP; extern const long bXP; // xp.cpp VOID unpackXP( QWORD(&pRaw)[2], BOOL &pUpgrade, DWORD &pChannelID, DWORD &pSequence, DWORD &pHash, QWORD &pSignature ); VOID packXP( QWORD (&pRaw)[2], BOOL pUpgrade, DWORD pChannelID, DWORD pSequence, DWORD pHash, QWORD pSignature ); VOID generateXPKey( EC_GROUP *eCurve, EC_POINT *basePoint, BIGNUM *genOrder, BIGNUM *privateKey, DWORD pChannelID, DWORD pSequence, BOOL pUpgrade, CHAR (&pKey)[PK_LENGTH + NULL_TERMINATOR] ); BOOL keyXP( CHAR(&pKey)[PK_LENGTH + NULL_TERMINATOR], DWORD nChannelID, DWORD nSequence, BOOL bUpgrade ); // server.cpp VOID unpackServer( QWORD (&pRaw)[2], BOOL &pUpgrade, DWORD &pChannelID, DWORD &pHash, QWORD &pSignature, DWORD &pAuthInfo ); VOID packServer( QWORD (&pRaw)[2], BOOL pUpgrade, DWORD pChannelID, DWORD pHash, QWORD pSignature, DWORD pAuthInfo ); BOOL verifyServerKey( EC_GROUP *eCurve, EC_POINT *basePoint, EC_POINT *publicKey, CHAR (&cdKey)[PK_LENGTH + NULL_TERMINATOR] ); VOID generateServerKey( EC_GROUP *eCurve, EC_POINT *basePoint, BIGNUM *genOrder, BIGNUM *privateKey, DWORD pChannelID, DWORD pAuthInfo, BOOL pUpgrade, CHAR (&pKey)[PK_LENGTH + NULL_TERMINATOR] ); BOOL keyServer( CHAR (&pKey)[PK_LENGTH + NULL_TERMINATOR], DWORD nChannelID, DWORD nAuthInfo, BOOL bUpgrade ); // utilities.cpp void endian(byte *data, int length); DWORD randomRange(DWORD dwLow, DWORD dwHigh); void stopAudio(); bool playAudio(HINSTANCE hInstance, WCHAR *lpName, UINT bFlags); EC_GROUP *initializeEllipticCurve( const char *pSel, long aSel, long bSel, const char *generatorXSel, const char *generatorYSel, const char *publicKeyXSel, const char *publicKeyYSel, BIGNUM *genOrderSel, BIGNUM *privateKeySel, EC_POINT **genPoint, EC_POINT **pubPoint ); int BN_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen); // key.cpp bool unbase24(BYTE *byteSeq, CHAR (&pKey)[PK_LENGTH + NULL_TERMINATOR]); void base24(BYTE *byteSeq, CHAR(&pKey)[PK_LENGTH + NULL_TERMINATOR]); VOID formatXP(BOOL bUpgrade, WCHAR *pBSection, WCHAR *pCSection, WCHAR *pText); VOID formatServer(BOOL bUpgrade, WCHAR *pBSection, WCHAR *pAuthSection, WCHAR *pText); // windows.cpp bool InitializeWindow(HINSTANCE hInstance); // bink.cpp void base(WCHAR *pPath); #endif //KEYGEN_HEADER_H