Re: [edk2-devel] [PATCH v3 2/2] SecurityPkg: Add support for RngDxe on AARCH64

2021-05-11 Thread Sami Mujawar

This patch looks good to me.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar


On 10/05/2021 10:53 PM, Rebecca Cran wrote:

AARCH64 support has been added to BaseRngLib via the optional
ARMv8.5 FEAT_RNG.

Refactor RngDxe to support AARCH64, note support for it in the
VALID_ARCHITECTURES line of RngDxe.inf and enable it in SecurityPkg.dsc.

Signed-off-by: Rebecca Cran 
---
  SecurityPkg/SecurityPkg.dec   |   2 +
  SecurityPkg/SecurityPkg.dsc   |  11 +-
  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf   |  24 ++-
  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.h |   0
  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.h  |  17 --
  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h| 117 
++
  SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 127 
+++
  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.c |   0
  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.c  |  45 +-
  SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c| 146 
+
  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 170 

  11 files changed, 483 insertions(+), 176 deletions(-)

diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index dfbbb0365a2b..4001650fa28e 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -297,6 +297,8 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]

gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationPass|0x0303100A|UINT32|0x00010030

gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationFail|0x0303100B|UINT32|0x00010031

+  
gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x00010032
+
  [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## Image verification policy for OptionRom. Only following values are 
valid:
#  NOTE: Do NOT use 0x5 and 0x2 since it violates the UEFI specification and has 
been removed.
diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 12ccd1634941..bd4b810bce61 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -259,6 +259,12 @@ [Components]
  [Components.IA32, Components.X64, Components.ARM, Components.AARCH64]
SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf

+[Components.IA32, Components.X64, Components.AARCH64]
+  #
+  # Random Number Generator
+  #
+  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
+
  [Components.IA32, Components.X64]

SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf

@@ -334,11 +340,6 @@ [Components.IA32, Components.X64]

SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.inf

SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.inf

-  #
-  # Random Number Generator
-  #
-  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
-
#
# Opal Password solution
#
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf 
b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
index 99d6f6b35fc2..f3300971993f 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
@@ -26,15 +26,22 @@ [Defines]
  #
  # The following information is for reference only and not required by the 
build tools.
  #
-#  VALID_ARCHITECTURES   = IA32 X64
+#  VALID_ARCHITECTURES   = IA32 X64 AARCH64
  #

  [Sources.common]
RngDxe.c
-  RdRand.c
-  RdRand.h
-  AesCore.c
-  AesCore.h
+  RngDxeInternals.h
+
+[Sources.IA32, Sources.X64]
+  Rand/RngDxe.c
+  Rand/RdRand.c
+  Rand/RdRand.h
+  Rand/AesCore.c
+  Rand/AesCore.h
+
+[Sources.AARCH64]
+  AArch64/RngDxe.c

  [Packages]
MdePkg/MdePkg.dec
@@ -50,12 +57,19 @@ [LibraryClasses]
RngLib

  [Guids]
+  gEfiRngAlgorithmSp80090Hash256Guid  ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
+  gEfiRngAlgorithmSp80090Hmac256Guid  ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
gEfiRngAlgorithmSp80090Ctr256Guid   ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
+  gEfiRngAlgorithmX9313DesGuid## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
+  gEfiRngAlgorithmX931AesGuid ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
gEfiRngAlgorithmRaw ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG

  [Protocols]
gEfiRngProtocolGuid## PRODUCES

+[Pcd]
+  gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm  ## CONSUMES
+
  [Depex]
TRUE

diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AesCore.h 

Re: [edk2-devel] [PATCH v3 2/2] SecurityPkg: Add support for RngDxe on AARCH64

2021-05-11 Thread Yao, Jiewen
Acked-by: Jiewen Yao 

Need ARM expert to double confirm.

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ard
> Biesheuvel
> Sent: Tuesday, May 11, 2021 10:44 PM
> To: Rebecca Cran ; Yao, Jiewen
> ; Wang, Jian J 
> Cc: edk2-devel-groups-io ; Kinney, Michael D
> ; Liming Gao ; Liu,
> Zhiguang ; Ard Biesheuvel
> ; Sami Mujawar 
> Subject: Re: [edk2-devel] [PATCH v3 2/2] SecurityPkg: Add support for RngDxe
> on AARCH64
> 
> On Mon, 10 May 2021 at 23:53, Rebecca Cran  wrote:
> >
> > AARCH64 support has been added to BaseRngLib via the optional
> > ARMv8.5 FEAT_RNG.
> >
> > Refactor RngDxe to support AARCH64, note support for it in the
> > VALID_ARCHITECTURES line of RngDxe.inf and enable it in SecurityPkg.dsc.
> >
> > Signed-off-by: Rebecca Cran 
> 
> I'm happy to take these and merge them if I can get an ack from a
> SecurityPkg maintainer.
> 
> 
> > ---
> >  SecurityPkg/SecurityPkg.dec   |   2 +
> >  SecurityPkg/SecurityPkg.dsc   |  11 +-
> >  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf   |  24 ++-
> >  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.h |   0
> >  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.h  |  17 --
> >  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h| 117
> ++
> >  SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 127
> +++
> >  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.c |   0
> >  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.c  |  45 +-
> 
> >  SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c| 146
> +
> >  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 170
> 
> >  11 files changed, 483 insertions(+), 176 deletions(-)
> >
> > diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
> > index dfbbb0365a2b..4001650fa28e 100644
> > --- a/SecurityPkg/SecurityPkg.dec
> > +++ b/SecurityPkg/SecurityPkg.dec
> > @@ -297,6 +297,8 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
> >
> gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationPass|0x0303100A|
> UINT32|0x00010030
> >
> gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationFail|0x0303100B|
> UINT32|0x00010031
> >
> > +
> gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x0
> 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID
> *|0x00010032
> > +
> >  [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
> >## Image verification policy for OptionRom. Only following values are
> valid:
> >#  NOTE: Do NOT use 0x5 and 0x2 since it violates the UEFI specification 
> > and
> has been removed.
> > diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
> > index 12ccd1634941..bd4b810bce61 100644
> > --- a/SecurityPkg/SecurityPkg.dsc
> > +++ b/SecurityPkg/SecurityPkg.dsc
> > @@ -259,6 +259,12 @@ [Components]
> >  [Components.IA32, Components.X64, Components.ARM,
> Components.AARCH64]
> >SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> >
> > +[Components.IA32, Components.X64, Components.AARCH64]
> > +  #
> > +  # Random Number Generator
> > +  #
> > +  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> > +
> >  [Components.IA32, Components.X64]
> >
> SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDx
> e.inf
> >
> > @@ -334,11 +340,6 @@ [Components.IA32, Components.X64]
> >
> SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib
> .inf
> >
> SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalP
> resenceLib.inf
> >
> > -  #
> > -  # Random Number Generator
> > -  #
> > -  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> > -
> >#
> ># Opal Password solution
> >#
> > diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> > index 99d6f6b35fc2..f3300971993f 100644
> > --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> > +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> > @@ -26,15 +26,22 @@ [Defines]
> >  #
> >  # The following information is for reference only and not required by the 
> > build
> tools.
> >  #
> > -#  VALID_ARCHITECTURES   = IA32 X64
> > +#  VALID_ARCHITECTURES   = 

Re: [edk2-devel] [PATCH v3 2/2] SecurityPkg: Add support for RngDxe on AARCH64

2021-05-11 Thread Ard Biesheuvel
On Mon, 10 May 2021 at 23:53, Rebecca Cran  wrote:
>
> AARCH64 support has been added to BaseRngLib via the optional
> ARMv8.5 FEAT_RNG.
>
> Refactor RngDxe to support AARCH64, note support for it in the
> VALID_ARCHITECTURES line of RngDxe.inf and enable it in SecurityPkg.dsc.
>
> Signed-off-by: Rebecca Cran 

I'm happy to take these and merge them if I can get an ack from a
SecurityPkg maintainer.


> ---
>  SecurityPkg/SecurityPkg.dec   |   2 +
>  SecurityPkg/SecurityPkg.dsc   |  11 +-
>  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf   |  24 ++-
>  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.h |   0
>  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.h  |  17 --
>  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h| 117 
> ++
>  SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 127 
> +++
>  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.c |   0
>  SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.c  |  45 +-
>  SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c| 146 
> +
>  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 170 
> 
>  11 files changed, 483 insertions(+), 176 deletions(-)
>
> diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
> index dfbbb0365a2b..4001650fa28e 100644
> --- a/SecurityPkg/SecurityPkg.dec
> +++ b/SecurityPkg/SecurityPkg.dec
> @@ -297,6 +297,8 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
>
> gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationPass|0x0303100A|UINT32|0x00010030
>
> gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationFail|0x0303100B|UINT32|0x00010031
>
> +  
> gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x00010032
> +
>  [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>## Image verification policy for OptionRom. Only following values are 
> valid:
>#  NOTE: Do NOT use 0x5 and 0x2 since it violates the UEFI specification 
> and has been removed.
> diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
> index 12ccd1634941..bd4b810bce61 100644
> --- a/SecurityPkg/SecurityPkg.dsc
> +++ b/SecurityPkg/SecurityPkg.dsc
> @@ -259,6 +259,12 @@ [Components]
>  [Components.IA32, Components.X64, Components.ARM, Components.AARCH64]
>SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
>
> +[Components.IA32, Components.X64, Components.AARCH64]
> +  #
> +  # Random Number Generator
> +  #
> +  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> +
>  [Components.IA32, Components.X64]
>
> SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
>
> @@ -334,11 +340,6 @@ [Components.IA32, Components.X64]
>
> SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.inf
>
> SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.inf
>
> -  #
> -  # Random Number Generator
> -  #
> -  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> -
>#
># Opal Password solution
>#
> diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf 
> b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> index 99d6f6b35fc2..f3300971993f 100644
> --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
> @@ -26,15 +26,22 @@ [Defines]
>  #
>  # The following information is for reference only and not required by the 
> build tools.
>  #
> -#  VALID_ARCHITECTURES   = IA32 X64
> +#  VALID_ARCHITECTURES   = IA32 X64 AARCH64
>  #
>
>  [Sources.common]
>RngDxe.c
> -  RdRand.c
> -  RdRand.h
> -  AesCore.c
> -  AesCore.h
> +  RngDxeInternals.h
> +
> +[Sources.IA32, Sources.X64]
> +  Rand/RngDxe.c
> +  Rand/RdRand.c
> +  Rand/RdRand.h
> +  Rand/AesCore.c
> +  Rand/AesCore.h
> +
> +[Sources.AARCH64]
> +  AArch64/RngDxe.c
>
>  [Packages]
>MdePkg/MdePkg.dec
> @@ -50,12 +57,19 @@ [LibraryClasses]
>RngLib
>
>  [Guids]
> +  gEfiRngAlgorithmSp80090Hash256Guid  ## SOMETIMES_PRODUCES## GUID   
>  # Unique ID of the algorithm for RNG
> +  gEfiRngAlgorithmSp80090Hmac256Guid  ## SOMETIMES_PRODUCES## GUID   
>  # Unique ID of the algorithm for RNG
>gEfiRngAlgorithmSp80090Ctr256Guid   ## SOMETIMES_PRODUCES## GUID   
>  # Unique ID of the algorithm for RNG
> +  gEfiRngAlgorithmX9313DesGuid## SOMETIMES_PRODUCES## GUID   
>  # Unique ID of the algorithm for RNG
> +  gEfiRngAlgorithmX931AesGuid ## SOMETIMES_PRODUCES## GUID   
>  # Unique ID of the algorithm for RNG
>gEfiRngAlgorithmRaw ## SOMETIMES_PRODUCES## GUID   
>  # Unique ID of the algorithm for RNG
>
>  [Protocols]
>gEfiRngProtocolGuid## PRODUCES
>
> 

[edk2-devel] [PATCH v3 2/2] SecurityPkg: Add support for RngDxe on AARCH64

2021-05-10 Thread Rebecca Cran
AARCH64 support has been added to BaseRngLib via the optional
ARMv8.5 FEAT_RNG.

Refactor RngDxe to support AARCH64, note support for it in the
VALID_ARCHITECTURES line of RngDxe.inf and enable it in SecurityPkg.dsc.

Signed-off-by: Rebecca Cran 
---
 SecurityPkg/SecurityPkg.dec   |   2 +
 SecurityPkg/SecurityPkg.dsc   |  11 +-
 SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf   |  24 ++-
 SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.h |   0
 SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.h  |  17 --
 SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h| 117 
++
 SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 127 
+++
 SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/AesCore.c |   0
 SecurityPkg/RandomNumberGenerator/RngDxe/{ => Rand}/RdRand.c  |  45 +-
 SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c| 146 
+
 SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 170 

 11 files changed, 483 insertions(+), 176 deletions(-)

diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index dfbbb0365a2b..4001650fa28e 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -297,6 +297,8 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   
gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationPass|0x0303100A|UINT32|0x00010030
   
gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeFvVerificationFail|0x0303100B|UINT32|0x00010031
 
+  
gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x00010032
+
 [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   ## Image verification policy for OptionRom. Only following values are 
valid:
   #  NOTE: Do NOT use 0x5 and 0x2 since it violates the UEFI specification and 
has been removed.
diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 12ccd1634941..bd4b810bce61 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -259,6 +259,12 @@ [Components]
 [Components.IA32, Components.X64, Components.ARM, Components.AARCH64]
   SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
 
+[Components.IA32, Components.X64, Components.AARCH64]
+  #
+  # Random Number Generator
+  #
+  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
+
 [Components.IA32, Components.X64]
   SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
 
@@ -334,11 +340,6 @@ [Components.IA32, Components.X64]
   SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.inf
   
SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/StandaloneMmTcg2PhysicalPresenceLib.inf
 
-  #
-  # Random Number Generator
-  #
-  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
-
   #
   # Opal Password solution
   #
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf 
b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
index 99d6f6b35fc2..f3300971993f 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
@@ -26,15 +26,22 @@ [Defines]
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64
+#  VALID_ARCHITECTURES   = IA32 X64 AARCH64
 #
 
 [Sources.common]
   RngDxe.c
-  RdRand.c
-  RdRand.h
-  AesCore.c
-  AesCore.h
+  RngDxeInternals.h
+
+[Sources.IA32, Sources.X64]
+  Rand/RngDxe.c
+  Rand/RdRand.c
+  Rand/RdRand.h
+  Rand/AesCore.c
+  Rand/AesCore.h
+
+[Sources.AARCH64]
+  AArch64/RngDxe.c
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -50,12 +57,19 @@ [LibraryClasses]
   RngLib
 
 [Guids]
+  gEfiRngAlgorithmSp80090Hash256Guid  ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
+  gEfiRngAlgorithmSp80090Hmac256Guid  ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
   gEfiRngAlgorithmSp80090Ctr256Guid   ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
+  gEfiRngAlgorithmX9313DesGuid## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
+  gEfiRngAlgorithmX931AesGuid ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
   gEfiRngAlgorithmRaw ## SOMETIMES_PRODUCES## GUID
# Unique ID of the algorithm for RNG
 
 [Protocols]
   gEfiRngProtocolGuid## PRODUCES
 
+[Pcd]
+  gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm  ## CONSUMES
+
 [Depex]
   TRUE
 
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AesCore.h 
b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/AesCore.h
similarity index 100%
rename from SecurityPkg/RandomNumberGenerator/RngDxe/AesCore.h
rename to SecurityPkg/RandomNumberGenerator/RngDxe/Rand/AesCore.h
diff