2023-06-01 16:09:22 +03:00
|
|
|
//
|
|
|
|
// Created by neo on 5/26/2023.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef WINDOWSXPKG_HEADER_H
|
|
|
|
#define WINDOWSXPKG_HEADER_H
|
|
|
|
|
2023-06-04 10:50:41 +03:00
|
|
|
#ifdef DEBUG
|
2023-06-01 16:09:22 +03:00
|
|
|
#include <cassert>
|
2023-06-04 10:50:41 +03:00
|
|
|
#else
|
|
|
|
#define assert(x) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2023-06-01 16:09:22 +03:00
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <ctime>
|
2023-06-04 10:50:41 +03:00
|
|
|
|
2023-06-01 23:09:44 +03:00
|
|
|
#include <random>
|
2023-06-02 07:25:43 +03:00
|
|
|
#include <iostream>
|
2023-06-01 20:55:36 +03:00
|
|
|
#include <fstream>
|
2023-06-01 16:09:22 +03:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
2023-06-01 20:55:36 +03:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
2023-06-01 16:09:22 +03:00
|
|
|
#include <openssl/bn.h>
|
|
|
|
#include <openssl/ec.h>
|
|
|
|
#include <openssl/sha.h>
|
|
|
|
#include <openssl/rand.h>
|
|
|
|
|
2023-06-02 17:13:57 +03:00
|
|
|
// Algorithm macros
|
2023-06-01 16:09:22 +03:00
|
|
|
#define PK_LENGTH 25
|
|
|
|
#define NULL_TERMINATOR 1
|
|
|
|
|
|
|
|
#define FIELD_BITS 384
|
|
|
|
#define FIELD_BYTES 48
|
|
|
|
#define FIELD_BITS_2003 512
|
|
|
|
#define FIELD_BYTES_2003 64
|
|
|
|
|
2023-06-04 15:06:51 +03:00
|
|
|
#define FIRSTNBITS(field, n) ((field) & ((1ULL << (n)) - 1))
|
|
|
|
|
2023-06-03 17:14:11 +03:00
|
|
|
// Confirmation ID generator constants
|
|
|
|
#define SUCCESS 0
|
|
|
|
#define ERR_TOO_SHORT 1
|
|
|
|
#define ERR_TOO_LARGE 2
|
|
|
|
#define ERR_INVALID_CHARACTER 3
|
|
|
|
#define ERR_INVALID_CHECK_DIGIT 4
|
|
|
|
#define ERR_UNKNOWN_VERSION 5
|
|
|
|
#define ERR_UNLUCKY 6
|
|
|
|
|
2023-06-02 17:13:57 +03:00
|
|
|
// Type definitions
|
|
|
|
typedef uint8_t BYTE;
|
|
|
|
typedef uint16_t WORD;
|
|
|
|
typedef uint32_t DWORD;
|
|
|
|
typedef uint64_t QWORD;
|
2023-06-01 16:09:22 +03:00
|
|
|
|
2023-06-02 17:13:57 +03:00
|
|
|
// Global variables
|
2023-06-04 15:40:08 +03:00
|
|
|
extern char pCharset[];
|
2023-06-01 16:09:22 +03:00
|
|
|
|
|
|
|
// util.cpp
|
2023-06-04 13:31:24 +03:00
|
|
|
void endian(BYTE *data, int length);
|
2023-06-01 22:19:35 +03:00
|
|
|
EC_GROUP *initializeEllipticCurve(
|
2023-06-02 17:13:57 +03:00
|
|
|
std::string pSel,
|
|
|
|
std::string aSel,
|
|
|
|
std::string bSel,
|
|
|
|
std::string generatorXSel,
|
|
|
|
std::string generatorYSel,
|
|
|
|
std::string publicKeyXSel,
|
|
|
|
std::string publicKeyYSel,
|
2023-06-04 14:54:22 +03:00
|
|
|
EC_POINT *&genPoint,
|
|
|
|
EC_POINT *&pubPoint
|
2023-06-01 22:19:35 +03:00
|
|
|
);
|
2023-06-01 16:09:22 +03:00
|
|
|
|
|
|
|
// key.cpp
|
2023-06-04 15:40:08 +03:00
|
|
|
void unbase24(BYTE *byteSeq, const char *cdKey);
|
|
|
|
void base24(char *cdKey, BYTE *byteSeq);
|
2023-06-01 16:09:22 +03:00
|
|
|
|
|
|
|
// cli.cpp
|
|
|
|
void print_product_key(char *pk);
|
2023-06-04 13:31:24 +03:00
|
|
|
void print_product_id(DWORD *pid);
|
2023-06-02 07:25:43 +03:00
|
|
|
|
|
|
|
struct Options {
|
|
|
|
std::string binkid;
|
|
|
|
int channelID;
|
|
|
|
bool verbose;
|
|
|
|
bool help;
|
|
|
|
bool list;
|
|
|
|
bool error;
|
|
|
|
};
|
|
|
|
|
|
|
|
Options parseCommandLine(int argc, char* argv[]);
|
|
|
|
void showHelp(char *argv[]);
|
2023-06-01 16:09:22 +03:00
|
|
|
|
|
|
|
// xp.cpp
|
2023-06-04 14:54:22 +03:00
|
|
|
bool verifyXPKey(EC_GROUP *eCurve, EC_POINT *generator, EC_POINT *publicKey, char (&cdKey)[25]);
|
|
|
|
void generateXPKey(EC_GROUP *eCurve, EC_POINT *generator, BIGNUM *order, BIGNUM *privateKey, DWORD pRaw, char (&cdKey)[25]);
|
2023-06-01 16:09:22 +03:00
|
|
|
|
|
|
|
// server.cpp
|
|
|
|
|
|
|
|
#endif //WINDOWSXPKG_HEADER_H
|