diff options
Diffstat (limited to 'MdeModulePkg/Library/DxeNetLib/DxeNetLib.c')
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index ce26b322bc..57e8f9f27b 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -853,11 +853,11 @@ Ip6Swap128 ( }
/**
- Initialize a random seed using current time.
+ Initialize a random seed using current time and monotonic count.
- Get current time first. Then initialize a random seed based on some basic
- mathematics operation on the hour, day, minute, second, nanosecond and year
- of the current time.
+ Get current time and monotonic count first. Then initialize a random seed
+ based on some basic mathematics operation on the hour, day, minute, second,
+ nanosecond and year of the current time and the monotonic count value.
@return The random seed initialized with current time.
@@ -870,12 +870,16 @@ NetRandomInitSeed ( {
EFI_TIME Time;
UINT32 Seed;
+ UINT64 MonotonicCount;
gRT->GetTime (&Time, NULL);
Seed = (~Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second);
Seed ^= Time.Nanosecond;
Seed ^= Time.Year << 7;
+ gBS->GetNextMonotonicCount (&MonotonicCount);
+ Seed += (UINT32) MonotonicCount;
+
return Seed;
}
|