diff --git a/src/header.h b/src/header.h index 6017459..978a2ef 100644 --- a/src/header.h +++ b/src/header.h @@ -57,7 +57,7 @@ typedef uint32_t DWORD; typedef uint64_t QWORD; // Global variables -extern char charset[]; +extern char pCharset[]; // util.cpp void endian(BYTE *data, int length); @@ -74,8 +74,8 @@ EC_GROUP *initializeEllipticCurve( ); // key.cpp -void unbase24(DWORD *byteSeq, const char *cdKey); -void base24(char *cdKey, DWORD *byteSeq); +void unbase24(BYTE *byteSeq, const char *cdKey); +void base24(char *cdKey, BYTE *byteSeq); // cli.cpp void print_product_key(char *pk); diff --git a/src/key.cpp b/src/key.cpp index bce76f6..5dc4e66 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -5,7 +5,7 @@ #include "header.h" /* Converts from CD-key to a byte sequence. */ -void unbase24(DWORD *byteSeq, const char *cdKey) { +void unbase24(BYTE *byteSeq, const char *cdKey) { BYTE pDecodedKey[PK_LENGTH + NULL_TERMINATOR]{}; BIGNUM *y = BN_new(); @@ -14,7 +14,7 @@ void unbase24(DWORD *byteSeq, const char *cdKey) { // Remove dashes from the CD-key and put it into a Base24 byte array. for (int i = 0, k = 0; i < strlen(cdKey) && k < PK_LENGTH; i++) { for (int j = 0; j < 24; j++) { - if (cdKey[i] != '-' && cdKey[i] == charset[j]) { + if (cdKey[i] != '-' && cdKey[i] == pCharset[j]) { pDecodedKey[k++] = j; break; } @@ -34,15 +34,15 @@ void unbase24(DWORD *byteSeq, const char *cdKey) { int n = BN_num_bytes(y); // Place the generated code into the byte sequence. - BN_bn2bin(y, (BYTE *)byteSeq); + BN_bn2bin(y, byteSeq); BN_free(y); // Reverse the byte sequence. - endian((BYTE *)byteSeq, n); + endian(byteSeq, n); } /* Converts from byte sequence to the CD-key. */ -void base24(char *cdKey, DWORD *byteSeq) { +void base24(char *cdKey, BYTE *byteSeq) { BYTE rbyteSeq[16]; BIGNUM *z; @@ -62,7 +62,7 @@ void base24(char *cdKey, DWORD *byteSeq) { cdKey[25] = 0; for (int i = 24; i >= 0; i--) - cdKey[i] = charset[BN_div_word(z, 24)]; + cdKey[i] = pCharset[BN_div_word(z, 24)]; BN_free(z); } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index c734ba1..dc2f804 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,7 @@ #include "header.h" -char charset[] = "BCDFGHJKMPQRTVWXY2346789"; +char pCharset[] = "BCDFGHJKMPQRTVWXY2346789"; const std::string filename = "keys.json"; using json = nlohmann::json; diff --git a/src/server.cpp b/src/server.cpp index a9cf878..780f35a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1,6 +1,6 @@ #include "header.h" -char charset[] = "BCDFGHJKMPQRTVWXY2346789"; +char pCharset[] = "BCDFGHJKMPQRTVWXY2346789"; void unpackServer(DWORD *osFamily, DWORD *hash, DWORD *sig, DWORD *prefix, DWORD *raw) { diff --git a/src/xp.cpp b/src/xp.cpp index 4f042eb..14779f7 100644 --- a/src/xp.cpp +++ b/src/xp.cpp @@ -51,7 +51,7 @@ bool verifyXPKey(EC_GROUP *eCurve, EC_POINT *generator, EC_POINT *publicKey, cha QWORD sig = 0; - unbase24(bKey, cdKey); + unbase24((BYTE *)bKey, cdKey); // Extract data, hash and signature from the bytecode. unpackXP(bKey, pID, checkHash, sig); @@ -241,7 +241,7 @@ void generateXPKey(EC_GROUP *eCurve, EC_POINT *generator, BIGNUM *order, BIGNUM // the CD-key longer than 25 characters. // Convert the key to Base24. - base24(pKey, bKey); + base24(pKey, (BYTE *)bKey); BN_free(c); BN_free(s);