#include <Library/BaseMemoryLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PcdLib.h>\r
#include <Library/RngLib.h>\r
#include <Library/Tpm2CommandLib.h>\r
#include <Library/Tpm2DeviceLib.h>\r
// The authorization value may be no larger than the digest produced by the hash\r
// algorithm used for context integrity.\r
//\r
-#define MAX_NEW_AUTHORIZATION_SIZE SHA512_DIGEST_SIZE\r
\r
UINT16 mAuthSize;\r
\r
UINT8 *Ptr;\r
\r
Status = EFI_NOT_READY;\r
- BlockCount = Length / 64;\r
+ BlockCount = Length / sizeof(Seed);\r
Ptr = (UINT8 *)Entropy;\r
\r
//\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- CopyMem (Ptr, Seed, 64);\r
+ CopyMem (Ptr, Seed, sizeof(Seed));\r
\r
BlockCount--;\r
- Ptr = Ptr + 64;\r
+ Ptr = Ptr + sizeof(Seed);\r
}\r
\r
//\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- CopyMem (Ptr, Seed, (Length % 64));\r
+ CopyMem (Ptr, Seed, (Length % sizeof(Seed)));\r
\r
return Status;\r
}\r
{\r
EFI_STATUS Status;\r
UINT16 AuthSize;\r
- UINT8 *Rand;\r
- UINTN RandSize;\r
TPM2B_AUTH NewPlatformAuth;\r
\r
//\r
\r
GetAuthSize (&AuthSize);\r
\r
- ZeroMem (NewPlatformAuth.buffer, AuthSize);\r
NewPlatformAuth.size = AuthSize;\r
\r
//\r
- // Allocate one buffer to store random data.\r
+ // Create the random bytes in the destination buffer\r
//\r
- RandSize = MAX_NEW_AUTHORIZATION_SIZE;\r
- Rand = AllocatePool (RandSize);\r
-\r
- RdRandGenerateEntropy (RandSize, Rand);\r
- CopyMem (NewPlatformAuth.buffer, Rand, AuthSize);\r
\r
- FreePool (Rand);\r
+ RdRandGenerateEntropy (NewPlatformAuth.size, NewPlatformAuth.buffer);\r
\r
//\r
// Send Tpm2HierarchyChangeAuth command with the new Auth value\r
Status = Tpm2HierarchyChangeAuth (TPM_RH_PLATFORM, NULL, &NewPlatformAuth);\r
DEBUG ((DEBUG_INFO, "Tpm2HierarchyChangeAuth Result: - %r\n", Status));\r
ZeroMem (NewPlatformAuth.buffer, AuthSize);\r
- ZeroMem (Rand, RandSize);\r
}\r
\r
/**\r