diff --git a/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.c b/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.c index 8f7da092..5fc2f3e3 100644 --- a/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.c +++ b/src/tpm2/TPMCmd/tpm/src/crypt/math/TpmMath_Util.c @@ -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;