RngProtocol = NULL;\r
\r
if (Buffer == NULL) {\r
- DEBUG((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));\r
- return EFI_INVALID_PARAMETER;\r
+ DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));\r
+ return EFI_INVALID_PARAMETER;\r
}\r
\r
Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);\r
- if (EFI_ERROR (Status) || RngProtocol == NULL) {\r
- DEBUG((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));\r
- return Status;\r
+ if (EFI_ERROR (Status) || (RngProtocol == NULL)) {\r
+ DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));\r
+ return Status;\r
}\r
\r
Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);\r
- DEBUG((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));\r
+ DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));\r
if (!EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);\r
- DEBUG((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));\r
+ DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));\r
if (!EFI_ERROR (Status)) {\r
return Status;\r
}\r
\r
Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);\r
- DEBUG((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));\r
+ DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));\r
if (!EFI_ERROR (Status)) {\r
return Status;\r
}\r
+\r
// If all the other methods have failed, use the default method from the RngProtocol\r
Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);\r
- DEBUG((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));\r
+ DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));\r
if (!EFI_ERROR (Status)) {\r
return Status;\r
}\r
+\r
// If we get to this point, we have failed\r
- DEBUG((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));\r
+ DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));\r
\r
return Status;\r
}// GenerateRandomNumberViaNist800Algorithm()\r
\r
-\r
/**\r
Generates a 16-bit random number.\r
\r
OUT UINT16 *Rand\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
- if (Rand == NULL)\r
- {\r
+ if (Rand == NULL) {\r
return FALSE;\r
}\r
\r
- Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, sizeof(UINT16));\r
+ Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, sizeof (UINT16));\r
if (EFI_ERROR (Status)) {\r
return FALSE;\r
}\r
+\r
return TRUE;\r
}\r
\r
BOOLEAN\r
EFIAPI\r
GetRandomNumber32 (\r
- OUT UINT32 *Rand\r
+ OUT UINT32 *Rand\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
if (Rand == NULL) {\r
return FALSE;\r
}\r
\r
- Status = GenerateRandomNumberViaNist800Algorithm ((UINT8*)Rand, sizeof(UINT32));\r
+ Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, sizeof (UINT32));\r
if (EFI_ERROR (Status)) {\r
return FALSE;\r
}\r
+\r
return TRUE;\r
}\r
\r
BOOLEAN\r
EFIAPI\r
GetRandomNumber64 (\r
- OUT UINT64 *Rand\r
+ OUT UINT64 *Rand\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
if (Rand == NULL) {\r
return FALSE;\r
}\r
\r
- Status = GenerateRandomNumberViaNist800Algorithm ((UINT8*)Rand, sizeof(UINT64));\r
+ Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, sizeof (UINT64));\r
if (EFI_ERROR (Status)) {\r
return FALSE;\r
}\r
+\r
return TRUE;\r
}\r
\r
BOOLEAN\r
EFIAPI\r
GetRandomNumber128 (\r
- OUT UINT64 *Rand\r
+ OUT UINT64 *Rand\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
if (Rand == NULL) {\r
return FALSE;\r
}\r
\r
- Status = GenerateRandomNumberViaNist800Algorithm ((UINT8*)Rand, 2 * sizeof(UINT64));\r
+ Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, 2 * sizeof (UINT64));\r
if (EFI_ERROR (Status)) {\r
return FALSE;\r
}\r
+\r
return TRUE;\r
}\r