mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-11 19:26:27 +00:00
Sync: Fix masking-out of unneeded bits in TpmMath_GetRandomBits
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
e91b1dd595
commit
e9b2c0513e
@ -105,9 +105,9 @@ LIB_EXPORT BOOL TpmMath_GetRandomBits(BYTE* pBuffer, size_t bits, RAND_STATE* ra
|
||||
// 2 0x03 6 = (8 - 2) % 8
|
||||
// ... etc ...
|
||||
// 7 0x7F 1 = (8 - 7) % 8
|
||||
int excessBits = bits % 8;
|
||||
static const BYTE mask[8] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f}; // libtpms changed: fix
|
||||
pBuffer[0] &= mask[excessBits]; // libtpms changed: fix
|
||||
static const BYTE mask[8] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f};
|
||||
int excessBits = bits % 8;
|
||||
pBuffer[0] = pBuffer[0] & mask[excessBits];
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user