Header improvements, refactor continues

This commit is contained in:
Andrew 2023-06-05 12:29:54 +03:00
parent 150f7433dc
commit 1603dbd6e2
2 changed files with 11 additions and 7 deletions

View File

@ -43,11 +43,14 @@
#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 NEXTSNBITS(field, n, offset) (((QWORD)(field) >> (offset)) & ((1ULL << (n)) - 1))
#define FIRSTNBITS(field, n) NEXTSNBITS((field), (n), 0)
#define BYDWORD(n) (*(n + 0) | *(n + 1) << 8 | *(n + 2) << 16 | *(n + 3) << 24)
#define BITMASK(n) ((1ULL << n) - 1)
#define HIBYTES(field, bytes) NEXTSNBITS((QWORD)(field), ((bytes) * 8), ((bytes) * 8))
#define LOBYTES(field, bytes) FIRSTNBITS((QWORD)(field), ((bytes) * 8))
#define BYDWORD(n) (*((n) + 0) | *((n) + 1) << 8 | *((n) + 2) << 16 | *((n) + 3) << 24)
#define BITMASK(n) ((1ULL << (n)) - 1)
// Confirmation ID generator constants
#define SUCCESS 0

View File

@ -299,8 +299,7 @@ void generateServerKey(
BN_rshift1(s, s);
// Convert s from BigNum back to bytecode and reverse the endianness.
BN_bn2bin(s, (BYTE *)&pSignature);
endian((BYTE *)&pSignature, BN_num_bytes(s));
BN_bn2lebinpad(s, (BYTE *)&pSignature, BN_num_bytes(s));
// Pack product key.
packServer(bKey, pChannelID, hash, pSignature, pAuthInfo);
@ -310,10 +309,12 @@ void generateServerKey(
BN_free(x);
BN_free(y);
BN_free(b);
} while ((pSignature >> 32) >= 0x40000000);
} while (HIBYTES(pSignature, sizeof(DWORD)) >= 0x40000000);
base24(pKey, (BYTE *)bKey);
std::cout << "attempt pass" << std::endl;
BN_CTX_free(ctx);
EC_POINT_free(r);
}