diff options
| author | Chris Engel <cjengel@us.ibm.com> | 2015-11-19 11:37:23 -0600 |
|---|---|---|
| committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2016-03-27 23:15:23 -0400 |
| commit | e3d766322fb0715c0def3ca6dd850deccbd9fbbc (patch) | |
| tree | f7fe4125bb2e2a2e2b00b7d745b0c7968a14c47d /src/usr/secureboot/trusted/test | |
| parent | 6c5ba7c0b4d3d1694a2cdf2d6c5365027534ef5a (diff) | |
| download | talos-hostboot-e3d766322fb0715c0def3ca6dd850deccbd9fbbc.tar.gz talos-hostboot-e3d766322fb0715c0def3ca6dd850deccbd9fbbc.zip | |
Trustedboot support for PCR Read
cherry picked from commit 93cd77a2455e60f01b003f747368e69cfef1b844
RTC: 125287
ForwardPort: yes
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/701
Reviewed-by: Timothy R. Block <block@us.ibm.com>
Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Change-Id: I37103173d417ce1f378ee3ce76646f1028339ee0
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22496
Tested-by: Jenkins Server
Tested-by: FSP CI Jenkins
Reviewed-by: Christopher J. Engel <cjengel@us.ibm.com>
Diffstat (limited to 'src/usr/secureboot/trusted/test')
| -rwxr-xr-x | src/usr/secureboot/trusted/test/trustedbootTest.H | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/src/usr/secureboot/trusted/test/trustedbootTest.H b/src/usr/secureboot/trusted/test/trustedbootTest.H index 476b7e4c0..5fad75145 100755 --- a/src/usr/secureboot/trusted/test/trustedbootTest.H +++ b/src/usr/secureboot/trusted/test/trustedbootTest.H @@ -475,6 +475,67 @@ class TrustedBootTest: public CxxTest::TestSuite } + // Test PcrReadIn + { + TRACUCOMP( g_trac_trustedboot, + "testCommandMarshal - PcrReadIn" ); + memset(dataBufIn, 0, sizeof(dataBufIn)); + memset(dataBufOut, 0, sizeof(dataBufOut)); + TRUSTEDBOOT::TPM2_PcrReadIn* cmdPtr = + reinterpret_cast<TRUSTEDBOOT::TPM2_PcrReadIn*> + (dataBufIn); + cmdPtr->base.commandCode = TRUSTEDBOOT::TPM_CC_PCR_Read; + cmdPtr->pcrSelectionIn.count = 1; + cmdPtr->pcrSelectionIn.pcrSelections[0].algorithmId = + TPM_ALG_SHA256; + cmdPtr->pcrSelectionIn.pcrSelections[0].sizeOfSelect = + PCR_SELECT_MAX; + + runTpmMarshalTest(baseCmd, + dataBufOut, + sizeof(dataBufOut), + cmdSize, + "PcrReadIn", + num_ops, + fails, + sizeof(TPM2_PcrReadIn)); + + // Invalid number of algorithms + memset(dataBufIn, 0, sizeof(dataBufIn)); + memset(dataBufOut, 0, sizeof(dataBufOut)); + cmdPtr->base.commandCode = TRUSTEDBOOT::TPM_CC_PCR_Read; + cmdPtr->pcrSelectionIn.count = HASH_COUNT+1; + cmdPtr->pcrSelectionIn.pcrSelections[0].algorithmId = + TPM_ALG_SHA256; + cmdPtr->pcrSelectionIn.pcrSelections[0].sizeOfSelect = 1; + runTpmMarshalFailTest(baseCmd, + dataBufOut, + sizeof(dataBufOut), + cmdSize, + "PcrReadIn - invalid #algorithms", + num_ops, + fails); + + // Invalid select size + memset(dataBufIn, 0, sizeof(dataBufIn)); + memset(dataBufOut, 0, sizeof(dataBufOut)); + cmdPtr->base.commandCode = TRUSTEDBOOT::TPM_CC_PCR_Read; + cmdPtr->pcrSelectionIn.count = HASH_COUNT+1; + cmdPtr->pcrSelectionIn.pcrSelections[0].algorithmId = + TPM_ALG_SHA256; + cmdPtr->pcrSelectionIn.pcrSelections[0].sizeOfSelect = + PCR_SELECT_MAX+1; + runTpmMarshalFailTest(baseCmd, + dataBufOut, + sizeof(dataBufOut), + cmdSize, + "PcrReadIn - invalid select size", + num_ops, + fails); + + } + + } while( 0 ); TRACFCOMP( g_trac_trustedboot, @@ -567,6 +628,44 @@ class TrustedBootTest: public CxxTest::TestSuite fails); } + // Test PcrReadOut + { + TRACUCOMP( g_trac_trustedboot, + "testCommandUnmarshal - PcrReadOut" ); + memset(dataBufIn, 0, sizeof(dataBufIn)); + memset(dataBufOut, 0, sizeof(dataBufOut)); + + TRUSTEDBOOT::TPM2_PcrReadOut* respPtr = + reinterpret_cast<TRUSTEDBOOT::TPM2_PcrReadOut*> + (dataBufIn); + respPtr->pcrUpdateCounter = 0xAABBCCDD; + respPtr->pcrSelectionOut.count = 1; + respPtr->pcrSelectionOut.pcrSelections[0].sizeOfSelect = + PCR_SELECT_MAX; + respPtr->pcrValues.count = 1; + respPtr->pcrValues.digests[0].size = TPM_ALG_SHA256_SIZE; + + runTpmUnmarshalTest(TRUSTEDBOOT::TPM_CC_PCR_Read, + dataBufIn, + sizeof(dataBufIn), + baseCmd, + sizeof(TPM2_PcrReadOut), + "PcrReadOut", + num_ops, + fails); + + memset(dataBufIn, 0xFF, sizeof(dataBufIn)); + respPtr->base.responseCode = TPM_SUCCESS; + runTpmUnmarshalFailTest(TRUSTEDBOOT::TPM_CC_PCR_Read, + dataBufIn, + sizeof(dataBufIn), + baseCmd, + sizeof(TPM2_PcrReadOut), + "PcrReadOut - xFF buffer", + num_ops, + fails); + + } @@ -689,6 +788,67 @@ class TrustedBootTest: public CxxTest::TestSuite } } + /** + * @brief TPM Read PCR + */ + void testReadPCR ( void ) + { + int64_t fails = 0, num_ops = 0; + uint8_t digest[TPM_ALG_SHA256_SIZE]; + errlHndl_t err = NULL; + + TRACFCOMP( g_trac_trustedboot, + "testReadPCR - Start" ); + TpmTarget target = getTestTarget(); + + do + { + + if (target.failed) + { + TS_FAIL( "testReadPCR - Master TPM not functional" ); + break; + } + + memset(digest, 0, sizeof(digest)); + + num_ops++; + err = tpmCmdPcrRead(&target, + PCR_DEBUG, + TPM_ALG_SHA256, + digest, + sizeof(digest)); + if( NULL != err ) + { + fails++; + TS_FAIL( "testReadPCR - Error detected" ); + errlCommit( err, + SECURE_COMP_ID ); + delete err; + err = NULL; + break; + } + else + { + TRACUCOMP(g_trac_trustedboot, "testReadPCR - " + "Read returned as expected."); + TRACUBIN(g_trac_trustedboot, "PCR Contents", + digest, sizeof(digest)); + } + + + + } while( 0 ); + TRACFCOMP( g_trac_trustedboot, + "testReadPCR - End: %d/%d fails", + fails, num_ops ); + + if (NULL != target.logMgr) + { + delete target.logMgr; + } + } + }; |

