Fix BYDWORD (implementation mistake)

This commit is contained in:
Andrew 2023-06-05 15:07:31 +03:00
parent 04e6362d7e
commit da7e88b970
3 changed files with 4 additions and 8 deletions

View File

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

View File

@ -86,15 +86,12 @@ bool verifyServerKey(
SHA1(msgBuffer, 11, msgDigest); SHA1(msgBuffer, 11, msgDigest);
DWORD newHash[2]{}; QWORD newHash2 = (QWORD)(BYDWORD(&msgDigest[4]) >> 2 & BITMASK(30)) << 32 | BYDWORD(msgDigest);
newHash[0] = BYDWORD(msgDigest);
newHash[1] = BYDWORD(&msgDigest[4]) >> 2 & BITMASK(30);
BIGNUM *x = BN_new(); BIGNUM *x = BN_new();
BIGNUM *y = BN_new(); BIGNUM *y = BN_new();
BIGNUM *s = BN_lebin2bn((BYTE *)&pSignature, sizeof(pSignature), nullptr); BIGNUM *s = BN_lebin2bn((BYTE *)&pSignature, sizeof(pSignature), nullptr);
BIGNUM *e = BN_lebin2bn((BYTE *)&newHash, sizeof(newHash), nullptr); BIGNUM *e = BN_lebin2bn((BYTE *)&newHash2, 8, nullptr);
EC_POINT *u = EC_POINT_new(eCurve); EC_POINT *u = EC_POINT_new(eCurve);
EC_POINT *v = EC_POINT_new(eCurve); EC_POINT *v = EC_POINT_new(eCurve);

View File

@ -186,8 +186,7 @@ void generateXPKey(
// Translate the byte digest into a 32-bit integer - this is our computed pHash. // Translate the byte digest into a 32-bit integer - this is our computed pHash.
// Truncate the pHash to 28 bits. // Truncate the pHash to 28 bits.
pHash = BYDWORD(msgDigest) >> 4; pHash = BYDWORD(msgDigest) >> 4 & BITMASK(28);
pHash &= BITMASK(28);
/* /*
* *