summaryrefslogtreecommitdiffstats
path: root/src/usr/secureboot/trusted/test
diff options
context:
space:
mode:
authorJaymes Wilks <mjwilks@us.ibm.com>2018-04-24 10:01:59 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2018-05-10 21:49:40 -0400
commit98bee5bbab00b1fcb8c6b6255ac07e62e2800b60 (patch)
tree35359cf4fc59989468425e54a9c8b8a510ff87e6 /src/usr/secureboot/trusted/test
parent7145f5c28a5b4a8fe689d3250fa95acbdfc0c43f (diff)
downloadtalos-hostboot-98bee5bbab00b1fcb8c6b6255ac07e62e2800b60.tar.gz
talos-hostboot-98bee5bbab00b1fcb8c6b6255ac07e62e2800b60.zip
New API to Retrieve Random Number from the TPM
A new programming interface allows us to obtain random numbers from the TPM more easily (i.e. in a more high-level way). Change-Id: Ibd3d3b320411bea146d6eab4d1a59ca760bc726c RTC:191000 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/57802 Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/secureboot/trusted/test')
-rwxr-xr-xsrc/usr/secureboot/trusted/test/trustedbootTest.H50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/usr/secureboot/trusted/test/trustedbootTest.H b/src/usr/secureboot/trusted/test/trustedbootTest.H
index 0a8e181ca..0d293f41a 100755
--- a/src/usr/secureboot/trusted/test/trustedbootTest.H
+++ b/src/usr/secureboot/trusted/test/trustedbootTest.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2015,2017 */
+/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -45,6 +45,7 @@
#include "../trustedboot.H"
#include "../trustedbootCmds.H"
#include "../tpmLogMgr.H"
+#include <config.h>
using namespace TRUSTEDBOOT;
@@ -885,6 +886,53 @@ class TrustedBootTest: public CxxTest::TestSuite
EXIT_MRK "testReadPCR: %d/%d fails",
fails, num_ops );
}
+
+ /**
+ * @brief TPM GetRandom
+ */
+ void testGetRandom ( void )
+ {
+ TRACFCOMP( g_trac_trustedboot,
+ ENTER_MRK "testGetRandom" );
+
+ errlHndl_t err = nullptr;
+ size_t fails = 0;
+ size_t num_ops = 0;
+
+ // Just for fun generate random numbers for each of the TPMs
+ TARGETING::TargetHandleList tpmList;
+ TRUSTEDBOOT::getTPMs(tpmList, TRUSTEDBOOT::TPM_FILTER::ALL_FUNCTIONAL);
+ for (auto pTpm: tpmList)
+ {
+ uint64_t randNum = 0;
+ err = TRUSTEDBOOT::GetRandom(pTpm, randNum);
+ num_ops ++;
+ if(err)
+ {
+ fails++;
+ TS_FAIL( "testGetRandom: Error detected" );
+ errlCommit( err,
+ TRBOOT_COMP_ID );
+ delete err;
+ err = nullptr;
+ }
+ else if (randNum == 0) // if random number is zero still
+ {
+ fails++;
+ TS_FAIL( "testGetRandom: got zero for a random number");
+ }
+ else
+ {
+
+ TRACUCOMP(g_trac_trustedboot, "testGetRandom: GetRandom returned as expected. Random number 0x%.16llX",randNum);
+ }
+
+ }
+
+ TRACFCOMP( g_trac_trustedboot,
+ EXIT_MRK "testGetRandom: %d/%d fails",
+ fails, num_ops );
+ }
};
#endif
OpenPOWER on IntegriCloud