Refactor/Overhaul (#40)

* major refactor/overhaul
move generation implementation to libumskt/*
decouple CLI/Options (and JSON) from generation implementation
set groundwork for future shared library
use standardized PIDGEN2/PIDGEN3 naming convention
create a Windows Docker file for quick compilation
add Windows resouce file/header so we have an application icon on windows
use icon from @Endermanch (used with permission)
add support for fully-static linux/muslc-based compilation
add support for a dos/windows (i486+) binary using djgpp
add Dockerfile to compile gcc/djgpp/watt32/openssl to provide DOS (DPMI) binaries
add @Endermanch 's Vista+ documentation
update Readme for recent credits

* begin work on C linkage and emscripten buildpath

* Update CMake to include and build Crypto++

* move dllmain.cpp to the correct directory

* add rust port info to README.md

* re-add dropped changes from rebase

* update build config, specify windows XP version number for crypto++

* update dos-djgpp action to use new cmake builder and options

* update dos-djgpp to use UMSKT hosted forks

* update other workflows to include standard header

* remove crypto++ from build config for now

* use the new `shell` parameter in `threeal/cmake-action`
TODO: move to a stable version (v1.3.0) when ready

* use full commit hash because a shortened hash is unsupported

* add the required {0} parameter?

* add openssl 3.1.1 to windows github runners

* ensure linux matrix build compiles on the correct arch

---------

Co-authored-by: Neo <321592+Neo-Desktop@users.noreply.github.com>
This commit is contained in:
CONIGUERO
2023-07-09 00:08:43 -03:00
committed by GitHub
parent de04746c5e
commit 15cbe19006
35 changed files with 1520 additions and 242 deletions

View File

@@ -23,18 +23,8 @@
#ifndef UMSKT_HEADER_H
#define UMSKT_HEADER_H
#ifdef DEBUG
#include <cassert>
#else
#define assert(x) /* nothing */
#endif
#include "typedefs.h"
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <random>
#include <iostream>
#include <fstream>
#include <filesystem>
@@ -45,95 +35,7 @@
#include <fmt/core.h>
#include <nlohmann/json.hpp>
#include <openssl/bn.h>
#include <openssl/ec.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
// Algorithm macros
#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
#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)
using json = nlohmann::json;
namespace fs = std::filesystem;
enum MODE {
MODE_BINK1998_GENERATE = 0,
MODE_BINK2002_GENERATE = 1,
MODE_CONFIRMATION_ID = 2,
MODE_BINK1998_VALIDATE = 3,
MODE_BINK2002_VALIDATE = 4,
};
struct Options {
std::string binkid;
std::string keysFilename;
std::string instid;
std::string keyToCheck;
int channelID;
bool serialSet;
int serial;
int numKeys;
bool verbose;
bool help;
bool error;
bool list;
MODE applicationMode;
};
// Type definitions
typedef bool BOOL;
typedef uint8_t BYTE;
typedef uint16_t WORD;
typedef uint32_t DWORD;
typedef uint64_t QWORD;
#ifdef __SIZEOF_INT128__
typedef unsigned __int128 OWORD;
#endif
// Global variables
extern Options options;
// util.cpp
int BN_bn2lebin(const BIGNUM *a, unsigned char *to, int tolen); // Hello OpenSSL developers, please tell me, where is this function at?
void endian(BYTE *data, int length);
EC_GROUP *initializeEllipticCurve(
std::string pSel,
std::string aSel,
std::string bSel,
std::string generatorXSel,
std::string generatorYSel,
std::string publicKeyXSel,
std::string publicKeyYSel,
EC_POINT *&genPoint,
EC_POINT *&pubPoint
);
// key.cpp
extern char pKeyCharset[];
void unbase24(BYTE *byteSeq, const char *cdKey);
void base24(char *cdKey, BYTE *byteSeq);
#endif //UMSKT_HEADER_H