aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-02-08 13:55:26 +0100
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2016-03-09 16:50:44 +0700
commit33ecc5fa53322662c8ab7c0e9a534c9307cbeac9 (patch)
tree3882bfe7642e8c00f01c72ea448b4ecfb50cd352
parent56516776eddc5ccaf19cb1431e016531c2bda870 (diff)
Platforms/ARM: implement a pseudo-random version of RngLib for Juno
For lack of suitable hardware upon which a proper implementation of RngLib can be based, this implements a pseudo-random version of RngLib based on the generic timer, the cycle counter and a couple of rounds of AES. NOTE: while the values produced by this library may look like random values to the human eye, they most certainly are not, and use of this library in production is UNSAFE. For this reason, the library is provided as a binary only, and will print a warning to the console the first time it is invoked. Since Juno is a development platform with no entropy source in hardware, wire up this library for it into RngDxe Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
-rw-r--r--Platforms/ARM/Binary/Library/PseudoRngLib/License.txt19
-rw-r--r--Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.inf38
-rw-r--r--Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.libbin0 -> 29610 bytes
-rw-r--r--Platforms/ARM/Binary/Library/PseudoRngLib/README8
-rw-r--r--Platforms/ARM/Juno/ArmJuno.dsc5
-rw-r--r--Platforms/ARM/Juno/ArmJuno.fdf1
6 files changed, 71 insertions, 0 deletions
diff --git a/Platforms/ARM/Binary/Library/PseudoRngLib/License.txt b/Platforms/ARM/Binary/Library/PseudoRngLib/License.txt
new file mode 100644
index 0000000..fe5821e
--- /dev/null
+++ b/Platforms/ARM/Binary/Library/PseudoRngLib/License.txt
@@ -0,0 +1,19 @@
+Copyright (c) 2016, Linaro Ltd. All rights reserved.
+
+Redistribution and use in binary form without modification is permitted
+provided that this copyright notice and the following disclaimer are
+reproduced in the documentation and/or other materials provided with the
+distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.inf b/Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.inf
new file mode 100644
index 0000000..96afe88
--- /dev/null
+++ b/Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.inf
@@ -0,0 +1,38 @@
+## @file
+# Instance of RNG (Random Number Generator) Library.
+#
+# Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PseudoRngLib
+ FILE_GUID = 0b9d239e-e958-4071-882a-102835914533
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = RngLib|DXE_DRIVER
+
+#
+# VALID_ARCHITECTURES = AARCH64
+#
+
+[Binaries.AARCH64]
+ LIB|PseudoRngLib.lib|*
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ArmPkg/ArmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ ArmGenericTimerCounterLib
+ UefiBootServicesTableLib
diff --git a/Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.lib b/Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.lib
new file mode 100644
index 0000000..90bf9dd
--- /dev/null
+++ b/Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.lib
Binary files differ
diff --git a/Platforms/ARM/Binary/Library/PseudoRngLib/README b/Platforms/ARM/Binary/Library/PseudoRngLib/README
new file mode 100644
index 0000000..b338682
--- /dev/null
+++ b/Platforms/ARM/Binary/Library/PseudoRngLib/README
@@ -0,0 +1,8 @@
+This pseudo-random implementation of RngLib is unsafe, and is not intended for
+use in production. It is provided for development purposes only, and only to be
+used on development platforms that lack any hardware peripherals to implement
+RngLib properly.
+
+Note that this code blindly assumes the availability of the AES instructions,
+and the accessibility of the cycle counter. If either is not available, this
+code will crash.
diff --git a/Platforms/ARM/Juno/ArmJuno.dsc b/Platforms/ARM/Juno/ArmJuno.dsc
index 02472ce..3910389 100644
--- a/Platforms/ARM/Juno/ArmJuno.dsc
+++ b/Platforms/ARM/Juno/ArmJuno.dsc
@@ -294,6 +294,11 @@
# Juno platform driver
#
ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf
+ SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf {
+ <LibraryClasses>
+ # DO NOT USE THIS LIBRARY FOR PRODUCTION DEVICES
+ RngLib|OpenPlatformPkg/Platforms/ARM/Binary/Library/PseudoRngLib/PseudoRngLib.inf
+ }
#
# Bds
diff --git a/Platforms/ARM/Juno/ArmJuno.fdf b/Platforms/ARM/Juno/ArmJuno.fdf
index e686a6d..a051510 100644
--- a/Platforms/ARM/Juno/ArmJuno.fdf
+++ b/Platforms/ARM/Juno/ArmJuno.fdf
@@ -198,6 +198,7 @@ FvNameGuid = B73FE497-B92E-416e-8326-45AD0D270092
# Juno platform driver
#
INF ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf
+ INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
#
# Bds