mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-30 09:49:00 +00:00
This commit adds functionality to display tpm even log information to the support RIM display page. Outstanding issues to implement: 1) add link to base from support RIM, 2) make event table scrollable
This commit is contained in:
parent
39cfaa5fac
commit
3636782987
@ -9,6 +9,7 @@ import java.security.KeyStoreException;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
|
|
||||||
|
import hirs.data.persist.BaseReferenceManifest;
|
||||||
import hirs.data.persist.TPMMeasurementRecord;
|
import hirs.data.persist.TPMMeasurementRecord;
|
||||||
import hirs.data.persist.SwidResource;
|
import hirs.data.persist.SwidResource;
|
||||||
import hirs.data.persist.PCRPolicy;
|
import hirs.data.persist.PCRPolicy;
|
||||||
@ -335,13 +336,9 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
|||||||
|
|
||||||
fwStatus = new AppraisalStatus(PASS,
|
fwStatus = new AppraisalStatus(PASS,
|
||||||
SupplyChainCredentialValidator.FIRMWARE_VALID);
|
SupplyChainCredentialValidator.FIRMWARE_VALID);
|
||||||
if (rim == null) {
|
if (rim instanceof BaseReferenceManifest) {
|
||||||
fwStatus = new AppraisalStatus(FAIL,
|
BaseReferenceManifest bRim = (BaseReferenceManifest) rim;
|
||||||
String.format("Firmware validation failed: "
|
List<SwidResource> swids = bRim.parseResource();
|
||||||
+ "No associated RIM file could be found for %s",
|
|
||||||
manufacturer));
|
|
||||||
} else {
|
|
||||||
List<SwidResource> swids = rim.parseResource();
|
|
||||||
for (SwidResource swid : swids) {
|
for (SwidResource swid : swids) {
|
||||||
baseline = swid.getPcrValues()
|
baseline = swid.getPcrValues()
|
||||||
.toArray(new String[swid.getPcrValues().size()]);
|
.toArray(new String[swid.getPcrValues().size()]);
|
||||||
@ -413,6 +410,11 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
|||||||
fwStatus = new AppraisalStatus(FAIL, "Associated Issued Attestation"
|
fwStatus = new AppraisalStatus(FAIL, "Associated Issued Attestation"
|
||||||
+ " Certificate can not be found.");
|
+ " Certificate can not be found.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fwStatus = new AppraisalStatus(FAIL,
|
||||||
|
String.format("Firmware validation failed: "
|
||||||
|
+ "No associated RIM file could be found for %s",
|
||||||
|
manufacturer));
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildValidationRecord(SupplyChainValidation.ValidationType.FIRMWARE,
|
return buildValidationRecord(SupplyChainValidation.ValidationType.FIRMWARE,
|
||||||
|
@ -6,5 +6,4 @@
|
|||||||
|
|
||||||
<suppressions>
|
<suppressions>
|
||||||
<suppress checks="MagicNumber" files=".*[/\\]src[/\\]test[/\\]+" />
|
<suppress checks="MagicNumber" files=".*[/\\]src[/\\]test[/\\]+" />
|
||||||
<suppress checks="AvoidInlineConditionals" files=".*[/\\]src[/\\]test[/\\]+" />
|
|
||||||
</suppressions>
|
</suppressions>
|
||||||
|
@ -27,7 +27,7 @@ public final class DataTableResponse<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a data table response using a FilteredRecordList.
|
* Builds a data table response using a FilteredRecordList.
|
||||||
* @param recordList the filtered recordd list
|
* @param recordList the filtered record list
|
||||||
* @param inputQuery the data table input (used for draw)
|
* @param inputQuery the data table input (used for draw)
|
||||||
*/
|
*/
|
||||||
public DataTableResponse(final FilteredRecordsList<T> recordList,
|
public DataTableResponse(final FilteredRecordsList<T> recordList,
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package hirs.attestationca.portal.page.controllers;
|
package hirs.attestationca.portal.page.controllers;
|
||||||
|
|
||||||
|
import hirs.data.persist.BaseReferenceManifest;
|
||||||
import hirs.data.persist.ReferenceManifest;
|
import hirs.data.persist.ReferenceManifest;
|
||||||
|
import hirs.data.persist.SupportReferenceManifest;
|
||||||
import hirs.data.persist.SwidResource;
|
import hirs.data.persist.SwidResource;
|
||||||
|
import hirs.persist.DBManagerException;
|
||||||
import hirs.persist.ReferenceManifestManager;
|
import hirs.persist.ReferenceManifestManager;
|
||||||
import hirs.tpm.eventlog.TCGEventLog;
|
import hirs.tpm.eventlog.TCGEventLog;
|
||||||
import hirs.attestationca.portal.page.Page;
|
import hirs.attestationca.portal.page.Page;
|
||||||
@ -10,9 +13,6 @@ import hirs.attestationca.portal.page.PageMessages;
|
|||||||
import hirs.attestationca.portal.page.params.ReferenceManifestDetailsPageParams;
|
import hirs.attestationca.portal.page.params.ReferenceManifestDetailsPageParams;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.NoSuchFileException;
|
import java.nio.file.NoSuchFileException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -20,6 +20,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -53,6 +54,7 @@ public class ReferenceManifestDetailsPageController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the filePath for the view and the data model for the page.
|
||||||
*
|
*
|
||||||
* @param params The object to map url parameters into.
|
* @param params The object to map url parameters into.
|
||||||
* @param model The data model for the request. Can contain data from
|
* @param model The data model for the request. Can contain data from
|
||||||
@ -120,72 +122,75 @@ public class ReferenceManifestDetailsPageController
|
|||||||
.select(referenceManifestManager)
|
.select(referenceManifestManager)
|
||||||
.byEntityId(uuid).getRIM();
|
.byEntityId(uuid).getRIM();
|
||||||
|
|
||||||
if (rim != null) {
|
if (rim instanceof BaseReferenceManifest) {
|
||||||
|
BaseReferenceManifest bRim = (BaseReferenceManifest) rim;
|
||||||
// Software Identity
|
// Software Identity
|
||||||
data.put("swidName", rim.getSwidName());
|
data.put("swidName", bRim.getSwidName());
|
||||||
data.put("swidVersion", rim.getSwidVersion());
|
data.put("swidVersion", bRim.getSwidVersion());
|
||||||
if (rim.isSwidCorpus() == 1) {
|
if (bRim.isSwidCorpus() == 1) {
|
||||||
data.put("swidCorpus", "True");
|
data.put("swidCorpus", "True");
|
||||||
} else {
|
} else {
|
||||||
data.put("swidCorpus", "False");
|
data.put("swidCorpus", "False");
|
||||||
}
|
}
|
||||||
if (rim.isSwidPatch() == 1) {
|
if (bRim.isSwidPatch() == 1) {
|
||||||
data.put("swidPatch", "True");
|
data.put("swidPatch", "True");
|
||||||
} else {
|
} else {
|
||||||
data.put("swidPatch", "False");
|
data.put("swidPatch", "False");
|
||||||
}
|
}
|
||||||
if (rim.isSwidSupplemental() == 1) {
|
if (bRim.isSwidSupplemental() == 1) {
|
||||||
data.put("swidSupplemental", "True");
|
data.put("swidSupplemental", "True");
|
||||||
} else {
|
} else {
|
||||||
data.put("swidSupplemental", "False");
|
data.put("swidSupplemental", "False");
|
||||||
}
|
}
|
||||||
// data.put("swidCorpus", (rim.isSwidCorpus() == 1) ? "True" : "False");
|
|
||||||
// data.put("swidPatch", (rim.isSwidPatch() == 1) ? "True" : "False");
|
|
||||||
// data.put("swidSupplemental", (rim.isSwidSupplemental() == 1) ? "True" : "False");
|
|
||||||
data.put("swidTagId", rim.getTagId());
|
data.put("swidTagId", rim.getTagId());
|
||||||
// Entity
|
// Entity
|
||||||
data.put("entityName", rim.getEntityName());
|
data.put("entityName", bRim.getEntityName());
|
||||||
data.put("entityRegId", rim.getEntityRegId());
|
data.put("entityRegId", bRim.getEntityRegId());
|
||||||
data.put("entityRole", rim.getEntityRole());
|
data.put("entityRole", bRim.getEntityRole());
|
||||||
data.put("entityThumbprint", rim.getEntityThumbprint());
|
data.put("entityThumbprint", bRim.getEntityThumbprint());
|
||||||
// Link
|
// Link
|
||||||
data.put("linkHref", rim.getLinkHref());
|
data.put("linkHref", bRim.getLinkHref());
|
||||||
data.put("linkRel", rim.getLinkRel());
|
data.put("linkRel", bRim.getLinkRel());
|
||||||
data.put("supportBaseRimId", "");
|
data.put("supportBaseRimId", "");
|
||||||
data.put("supportBaseRimTagId", "");
|
data.put("supportBaseRimTagId", "");
|
||||||
data.put("platformManufacturer", rim.getPlatformManufacturer());
|
data.put("platformManufacturer", bRim.getPlatformManufacturer());
|
||||||
data.put("platformManufacturerId", rim.getPlatformManufacturerId());
|
data.put("platformManufacturerId", bRim.getPlatformManufacturerId());
|
||||||
data.put("platformModel", rim.getPlatformModel());
|
data.put("platformModel", bRim.getPlatformModel());
|
||||||
data.put("platformVersion", rim.getPlatformVersion());
|
data.put("platformVersion", bRim.getPlatformVersion());
|
||||||
data.put("firmwareVersion", rim.getFirmwareVersion());
|
data.put("firmwareVersion", bRim.getFirmwareVersion());
|
||||||
data.put("payloadType", rim.getPayloadType());
|
data.put("payloadType", bRim.getPayloadType());
|
||||||
data.put("colloquialVersion", rim.getColloquialVersion());
|
data.put("colloquialVersion", bRim.getColloquialVersion());
|
||||||
data.put("edition", rim.getEdition());
|
data.put("edition", bRim.getEdition());
|
||||||
data.put("product", rim.getProduct());
|
data.put("product", bRim.getProduct());
|
||||||
data.put("revision", rim.getRevision());
|
data.put("revision", bRim.getRevision());
|
||||||
data.put("bindingSpec", rim.getBindingSpec());
|
data.put("bindingSpec", bRim.getBindingSpec());
|
||||||
data.put("bindingSpecVersion", rim.getBindingSpecVersion());
|
data.put("bindingSpecVersion", bRim.getBindingSpecVersion());
|
||||||
data.put("pcUriGlobal", rim.getPcURIGlobal());
|
data.put("pcUriGlobal", bRim.getPcURIGlobal());
|
||||||
data.put("pcUriLocal", rim.getPcURILocal());
|
data.put("pcUriLocal", bRim.getPcURILocal());
|
||||||
data.put("rimLinkHash", rim.getRimLinkHash());
|
data.put("rimLinkHash", bRim.getRimLinkHash());
|
||||||
|
data.put("rimType", bRim.getRimType());
|
||||||
|
data.put("associatedRim", bRim.getAssociatedRim());
|
||||||
|
|
||||||
// checkout later
|
List<SwidResource> resources = bRim.parseResource();
|
||||||
data.put("rimType", rim.getRimType());
|
|
||||||
List<SwidResource> resources = rim.parseResource();
|
|
||||||
String resourceFilename = null;
|
String resourceFilename = null;
|
||||||
TCGEventLog logProcessor;
|
TCGEventLog logProcessor;
|
||||||
|
|
||||||
|
// going to have to pull the filename and grab that from the DB
|
||||||
|
// to get the id to make the link
|
||||||
try {
|
try {
|
||||||
for (SwidResource swidRes : resources) {
|
for (SwidResource swidRes : resources) {
|
||||||
resourceFilename = swidRes.getName();
|
resourceFilename = swidRes.getName();
|
||||||
Path logPath = Paths.get(String.format("%s/%s",
|
ReferenceManifest dbRim = ReferenceManifest.select(
|
||||||
SwidResource.RESOURCE_UPLOAD_FOLDER,
|
referenceManifestManager).byFileName(resourceFilename).getRIM();
|
||||||
resourceFilename));
|
|
||||||
if (Files.exists(logPath)) {
|
if (dbRim != null) {
|
||||||
logProcessor = new TCGEventLog(
|
logProcessor = new TCGEventLog(dbRim.getRimBytes());
|
||||||
Files.readAllBytes(logPath));
|
|
||||||
swidRes.setPcrValues(Arrays.asList(
|
swidRes.setPcrValues(Arrays.asList(
|
||||||
logProcessor.getExpectedPCRValues()));
|
logProcessor.getExpectedPCRValues()));
|
||||||
|
|
||||||
|
if (bRim.getAssociatedRim() == null) {
|
||||||
|
bRim.setAssociatedRim(dbRim.getId());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
swidRes.setPcrValues(new ArrayList<>());
|
swidRes.setPcrValues(new ArrayList<>());
|
||||||
}
|
}
|
||||||
@ -194,9 +199,20 @@ public class ReferenceManifestDetailsPageController
|
|||||||
LOGGER.error(String.format("File Not found!: %s",
|
LOGGER.error(String.format("File Not found!: %s",
|
||||||
resourceFilename));
|
resourceFilename));
|
||||||
LOGGER.error(nsfEx);
|
LOGGER.error(nsfEx);
|
||||||
|
} catch (DBManagerException dbmEx) {
|
||||||
|
LOGGER.error(dbmEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.put("associatedRim", bRim.getAssociatedRim());
|
||||||
data.put("swidFiles", resources);
|
data.put("swidFiles", resources);
|
||||||
|
} else if (rim instanceof SupportReferenceManifest) {
|
||||||
|
SupportReferenceManifest sRim = (SupportReferenceManifest) rim;
|
||||||
|
data.put("baseRim", sRim.getFileName());
|
||||||
|
data.put("associatedRim", sRim.getAssociatedRim());
|
||||||
|
data.put("rimType", sRim.getRimType());
|
||||||
|
|
||||||
|
TCGEventLog logProcessor = new TCGEventLog(sRim.getRimBytes());
|
||||||
|
data.put("events", logProcessor.getEventList());
|
||||||
} else {
|
} else {
|
||||||
LOGGER.error(String.format("Unable to find Reference Integrity "
|
LOGGER.error(String.format("Unable to find Reference Integrity "
|
||||||
+ "Manifest with ID: %s", uuid));
|
+ "Manifest with ID: %s", uuid));
|
||||||
|
@ -26,10 +26,9 @@ import java.text.ParseException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -202,27 +201,54 @@ public class ReferenceManifestPageController
|
|||||||
matcher = pattern.matcher(fileName);
|
matcher = pattern.matcher(fileName);
|
||||||
supportRIM = matcher.matches();
|
supportRIM = matcher.matches();
|
||||||
|
|
||||||
if (supportRIM) {
|
|
||||||
filePath = Paths.get(String.format("%s/%s",
|
|
||||||
SwidResource.RESOURCE_UPLOAD_FOLDER,
|
|
||||||
file.getOriginalFilename()));
|
|
||||||
if (Files.notExists(Paths.get(SwidResource.RESOURCE_UPLOAD_FOLDER))) {
|
|
||||||
Files.createDirectory(Paths.get(SwidResource.RESOURCE_UPLOAD_FOLDER));
|
|
||||||
}
|
|
||||||
if (Files.notExists(filePath)) {
|
|
||||||
Files.createFile(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
Files.write(filePath, file.getBytes());
|
|
||||||
|
|
||||||
String uploadCompletedMessage = String.format(
|
|
||||||
"%s successfully uploaded", file.getOriginalFilename());
|
|
||||||
messages.addSuccess(uploadCompletedMessage);
|
|
||||||
LOGGER.info(uploadCompletedMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Parse reference manifests
|
//Parse reference manifests
|
||||||
ReferenceManifest rim = parseRIM(file, supportRIM, messages);
|
ReferenceManifest rim = parseRIM(file, supportRIM, messages);
|
||||||
|
// look for associated base/support
|
||||||
|
Set<ReferenceManifest> rims = ReferenceManifest
|
||||||
|
.select(referenceManifestManager).getRIMs();
|
||||||
|
|
||||||
|
// update information for associated support rims
|
||||||
|
if (supportRIM) {
|
||||||
|
for (ReferenceManifest element : rims) {
|
||||||
|
if (element instanceof BaseReferenceManifest) {
|
||||||
|
BaseReferenceManifest bRim = (BaseReferenceManifest) element;
|
||||||
|
for (SwidResource swid : bRim.parseResource()) {
|
||||||
|
if (swid.getName().equals(rim.getFileName())) {
|
||||||
|
rim.setFirmwareVersion(swid.getSize());
|
||||||
|
rim.setPlatformManufacturer(element.getPlatformManufacturer());
|
||||||
|
rim.setPlatformModel(element.getPlatformModel());
|
||||||
|
rim.setTagId(element.getTagId());
|
||||||
|
rim.setAssociatedRim(element.getId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BaseReferenceManifest bRim = (BaseReferenceManifest) rim;
|
||||||
|
for (SwidResource swid : bRim.parseResource()) {
|
||||||
|
for (ReferenceManifest element : rims) {
|
||||||
|
if (element instanceof SupportReferenceManifest) {
|
||||||
|
SupportReferenceManifest sRim = (SupportReferenceManifest) element;
|
||||||
|
if (swid.getName().equals(sRim.getFileName())) {
|
||||||
|
sRim.setPlatformManufacturer(bRim.getPlatformManufacturer());
|
||||||
|
sRim.setPlatformModel(bRim.getPlatformModel());
|
||||||
|
sRim.setFirmwareVersion(swid.getSize());
|
||||||
|
sRim.setTagId(bRim.getTagId());
|
||||||
|
rim.setAssociatedRim(sRim.getId());
|
||||||
|
try {
|
||||||
|
referenceManifestManager.update(sRim);
|
||||||
|
} catch (DBManagerException dbmEx) {
|
||||||
|
LOGGER.error(String.format("Couldn't update Base RIM %s with "
|
||||||
|
+ "associated UUID %s", rim.getTagId(),
|
||||||
|
sRim.getId()), dbmEx);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Store only if it was parsed
|
//Store only if it was parsed
|
||||||
if (rim != null) {
|
if (rim != null) {
|
||||||
@ -320,6 +346,8 @@ public class ReferenceManifestPageController
|
|||||||
fileName.append(".swidTag\"");
|
fileName.append(".swidTag\"");
|
||||||
} else {
|
} else {
|
||||||
// this needs to be updated for support rims
|
// this needs to be updated for support rims
|
||||||
|
SupportReferenceManifest bRim = (SupportReferenceManifest) referenceManifest;
|
||||||
|
fileName.append(bRim.getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set filename for download.
|
// Set filename for download.
|
||||||
@ -382,9 +410,9 @@ public class ReferenceManifestPageController
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (supportRIM) {
|
if (supportRIM) {
|
||||||
return new SupportReferenceManifest(fileBytes);
|
return new SupportReferenceManifest(fileName, fileBytes);
|
||||||
} else {
|
} else {
|
||||||
return new BaseReferenceManifest(fileBytes);
|
return new BaseReferenceManifest(fileName, fileBytes);
|
||||||
}
|
}
|
||||||
// the this is a List<Object> is object is a JaxBElement that can
|
// the this is a List<Object> is object is a JaxBElement that can
|
||||||
// be matched up to the QName
|
// be matched up to the QName
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<my:page>
|
<my:page>
|
||||||
<jsp:attribute name="style">
|
<jsp:attribute name="style">
|
||||||
<link type="text/css" rel="stylesheet" href="${common}/certificate_details.css"/>
|
<link type="text/css" rel="stylesheet" href="${common}/certificate_details.css"/>
|
||||||
|
<link type="text/css" rel="stylesheet" href="${common}/rim_details.css"/>
|
||||||
</jsp:attribute>
|
</jsp:attribute>
|
||||||
<jsp:attribute name="pageHeaderTitle">
|
<jsp:attribute name="pageHeaderTitle">
|
||||||
${initialData.rimType} Reference Integrity Manifest
|
${initialData.rimType} Reference Integrity Manifest
|
||||||
@ -17,14 +18,15 @@
|
|||||||
</jsp:attribute>
|
</jsp:attribute>
|
||||||
<jsp:body>
|
<jsp:body>
|
||||||
<div id="certificate-details-page" class="container-fluid">
|
<div id="certificate-details-page" class="container-fluid">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${initialData.rimType=='Support'}">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<c:if test="${initialData.swidSupplemental=='True'}">
|
|
||||||
<div class="col-md-1 col-md-offset-1"><span class="colHeader">Base RIM</span></div>
|
<div class="col-md-1 col-md-offset-1"><span class="colHeader">Base RIM</span></div>
|
||||||
<div id="baseRim" class="col col-md-8">
|
<div id="baseRim" class="col col-md-8">
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${not empty initialData.supportBaseRimTagId}">
|
<c:when test="${not empty initialData.associatedRim}">
|
||||||
<a href="${portal}/rim-details?id=${initialData.supportBaseRimId}">
|
<a href="${portal}/rim-details?id=${initialData.associatedRim}">
|
||||||
${initialData.supportBaseRimTagId}
|
${initialData.associatedRim}
|
||||||
</a>
|
</a>
|
||||||
<!-- Event Number, Event Type, Digest (hex), Event Content -->
|
<!-- Event Number, Event Type, Digest (hex), Event Content -->
|
||||||
</c:when>
|
</c:when>
|
||||||
@ -33,8 +35,39 @@
|
|||||||
</c:otherwise>
|
</c:otherwise>
|
||||||
</c:choose>
|
</c:choose>
|
||||||
</div>
|
</div>
|
||||||
</c:if>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div id="tableDivTag">
|
||||||
|
<input type="text" id="eventInput" onkeyup="eventSearch()" placeholder="Search for text..." /><br />
|
||||||
|
<table id="eventLog">
|
||||||
|
<thead>
|
||||||
|
<tr class="header">
|
||||||
|
<th style="width: 5%">Event #</th>
|
||||||
|
<th style="width: 10%">PCR Index</th>
|
||||||
|
<th style="width: 20%">Event Type</th>
|
||||||
|
<th style="width: 20%">Digest</th>
|
||||||
|
<th style="width: 50%">Event Content</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:if test="${not empty initialData.events}">
|
||||||
|
<c:set var="count" value="1" scope="page"/>
|
||||||
|
<c:forEach items="${initialData.events}" var="event">
|
||||||
|
<tr>
|
||||||
|
<td>${count}</td>
|
||||||
|
<td>${event.getPcrIndex()}</td>
|
||||||
|
<td>${event.getEventTypeStr()}</td>
|
||||||
|
<td>${event.getEventDigestStr()}</td>
|
||||||
|
<td>${event.getEventContentStr()}</td>
|
||||||
|
</tr>
|
||||||
|
<c:set var="count" value="${count + 1}" scope="page"/>
|
||||||
|
<!-- not status.last ? ‘<hr/>’ : ‘<br/>’ -->
|
||||||
|
</c:forEach>
|
||||||
|
</c:if>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-1 col-md-offset-1"><span class="colHeader">Software Identity</span></div>
|
<div class="col-md-1 col-md-offset-1"><span class="colHeader">Software Identity</span></div>
|
||||||
<div id="softwareIdentity" class="col col-md-8">
|
<div id="softwareIdentity" class="col col-md-8">
|
||||||
@ -109,7 +142,6 @@
|
|||||||
<div>Rim Link Hash: <span>${initialData.rimLinkHash}</span></div>
|
<div>Rim Link Hash: <span>${initialData.rimLinkHash}</span></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-1 col-md-offset-1"><span class="colHeader">Payload/Support RIM(s)</span></div>
|
<div class="col-md-1 col-md-offset-1"><span class="colHeader">Payload/Support RIM(s)</span></div>
|
||||||
<div id="platformConfiguration" class="col col-md-8">
|
<div id="platformConfiguration" class="col col-md-8">
|
||||||
@ -140,7 +172,14 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<span data-toggle="tooltip" data-placement="top" title="Resource File">
|
<span data-toggle="tooltip" data-placement="top" title="Resource File">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${not empty initialData.associatedRim}">
|
||||||
|
<a href="${portal}/rim-details?id=${initialData.associatedRim}">${resource.getName()}</a>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
${resource.getName()}
|
${resource.getName()}
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<c:choose>
|
<c:choose>
|
||||||
@ -202,7 +241,44 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
function eventSearch() {
|
||||||
|
// Declare variables
|
||||||
|
var input, filter, table, tr, td, i, txtValue, txtFound;
|
||||||
|
input = document.getElementById("eventInput");
|
||||||
|
filter = input.value.toUpperCase();
|
||||||
|
table = document.getElementById("eventLog");
|
||||||
|
tr = table.getElementsByTagName("tr");
|
||||||
|
|
||||||
|
// Loop through all table rows, and hide those who don't match the search query
|
||||||
|
for (i = 0; i < tr.length; i++) {
|
||||||
|
txtFound = false;
|
||||||
|
tds = tr[i].getElementsByTagName("td");
|
||||||
|
for (j = 0; j < tds.length; j++) {
|
||||||
|
td = tds[j];
|
||||||
|
|
||||||
|
if (td) {
|
||||||
|
txtValue = td.textContent || td.innerText;
|
||||||
|
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
||||||
|
txtFound = true;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
txtFound = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (txtFound) {
|
||||||
|
tr[i].style.display = "";
|
||||||
|
} else {
|
||||||
|
tr[i].style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</jsp:body>
|
</jsp:body>
|
||||||
</my:page>
|
</my:page>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin: auto 0;
|
margin: auto 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#platformID {
|
#platformID {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package hirs.attestationca.portal.page.controllers;
|
package hirs.attestationca.portal.page.controllers;
|
||||||
|
|
||||||
|
import hirs.data.persist.BaseReferenceManifest;
|
||||||
import hirs.data.persist.ReferenceManifest;
|
import hirs.data.persist.ReferenceManifest;
|
||||||
import hirs.persist.DBReferenceManifestManager;
|
import hirs.persist.DBReferenceManifestManager;
|
||||||
import hirs.attestationca.portal.page.Page;
|
import hirs.attestationca.portal.page.Page;
|
||||||
@ -52,7 +53,7 @@ public class ReferenceManifestDetailsPageControllerTest extends PageControllerTe
|
|||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw new IOException("Could not resolve path URI", e);
|
throw new IOException("Could not resolve path URI", e);
|
||||||
}
|
}
|
||||||
referenceManifest = new ReferenceManifest(Files.readAllBytes(fPath));
|
referenceManifest = new BaseReferenceManifest(Files.readAllBytes(fPath));
|
||||||
referenceManifestManager.save(referenceManifest);
|
referenceManifestManager.save(referenceManifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
@ -26,6 +27,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
public class BaseReferenceManifest extends ReferenceManifest {
|
public class BaseReferenceManifest extends ReferenceManifest {
|
||||||
private static final Logger LOGGER = LogManager.getLogger(BaseReferenceManifest.class);
|
private static final Logger LOGGER = LogManager.getLogger(BaseReferenceManifest.class);
|
||||||
|
|
||||||
@ -35,14 +40,12 @@ public class BaseReferenceManifest extends ReferenceManifest {
|
|||||||
private String swidName = null;
|
private String swidName = null;
|
||||||
@Column
|
@Column
|
||||||
private String swidVersion = null;
|
private String swidVersion = null;
|
||||||
@Column(nullable = false)
|
|
||||||
private int swidCorpus = 0;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private int swidPatch = 0;
|
|
||||||
@Column(nullable = false)
|
|
||||||
private int swidSupplemental = 0;
|
|
||||||
@Column
|
@Column
|
||||||
private String firmwareVersion = null;
|
private int swidCorpus = 0;
|
||||||
|
@Column
|
||||||
|
private int swidPatch = 0;
|
||||||
|
@Column
|
||||||
|
private int swidSupplemental = 0;
|
||||||
@Column
|
@Column
|
||||||
private String colloquialVersion = null;
|
private String colloquialVersion = null;
|
||||||
@Column
|
@Column
|
||||||
@ -74,10 +77,11 @@ public class BaseReferenceManifest extends ReferenceManifest {
|
|||||||
private String linkRel = null;
|
private String linkRel = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Support constructor for the RIM object.
|
||||||
*
|
*
|
||||||
* @param fileName
|
* @param fileName - string representation of the uploaded file.
|
||||||
* @param rimBytes
|
* @param rimBytes - the file content of the uploaded file.
|
||||||
* @throws IOException
|
* @throws IOException - thrown if the file is invalid.
|
||||||
*/
|
*/
|
||||||
public BaseReferenceManifest(final String fileName, final byte[] rimBytes) throws IOException {
|
public BaseReferenceManifest(final String fileName, final byte[] rimBytes) throws IOException {
|
||||||
this(rimBytes);
|
this(rimBytes);
|
||||||
@ -440,24 +444,6 @@ public class BaseReferenceManifest extends ReferenceManifest {
|
|||||||
this.swidSupplemental = swidSupplemental;
|
this.swidSupplemental = swidSupplemental;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for the firmware version info.
|
|
||||||
*
|
|
||||||
* @return string for the firmware version
|
|
||||||
*/
|
|
||||||
public String getFirmwareVersion() {
|
|
||||||
return firmwareVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for the firmware version info.
|
|
||||||
*
|
|
||||||
* @param firmwareVersion passed in firmware version
|
|
||||||
*/
|
|
||||||
public void setFirmwareVersion(final String firmwareVersion) {
|
|
||||||
this.firmwareVersion = firmwareVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the Entity Name.
|
* Getter for the Entity Name.
|
||||||
*
|
*
|
||||||
@ -769,8 +755,8 @@ public class BaseReferenceManifest extends ReferenceManifest {
|
|||||||
return String.format("ReferenceManifest{swidName=%s,"
|
return String.format("ReferenceManifest{swidName=%s,"
|
||||||
+ "platformManufacturer=%s,"
|
+ "platformManufacturer=%s,"
|
||||||
+ " platformModel=%s,"
|
+ " platformModel=%s,"
|
||||||
+ "firmwareVersion=%s, firmwareVersion=%s, rimHash=%d}",
|
+ "tagId=%s, rimHash=%d}",
|
||||||
swidName, this.getPlatformManufacturer(),
|
swidName, this.getPlatformManufacturer(),
|
||||||
this.getPlatformModel(), firmwareVersion, getTagId(), this.getRimHash());
|
this.getPlatformModel(), getTagId(), this.getRimHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package hirs.data.persist;
|
package hirs.data.persist;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
import javax.persistence.Access;
|
import javax.persistence.Access;
|
||||||
import javax.persistence.AccessType;
|
import javax.persistence.AccessType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@ -12,6 +13,8 @@ import hirs.persist.ReferenceManifestManager;
|
|||||||
import hirs.persist.ReferenceManifestSelector;
|
import hirs.persist.ReferenceManifestSelector;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.xml.XMLConstants;
|
import javax.xml.XMLConstants;
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
@ -28,7 +31,13 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@Access(AccessType.FIELD)
|
@Access(AccessType.FIELD)
|
||||||
public abstract class ReferenceManifest extends ArchivableEntity {
|
public abstract class ReferenceManifest extends ArchivableEntity {
|
||||||
|
/**
|
||||||
|
* String for display of a Base RIM.
|
||||||
|
*/
|
||||||
public static final String BASE_RIM = "Base";
|
public static final String BASE_RIM = "Base";
|
||||||
|
/**
|
||||||
|
* String for display of a Support RIM.
|
||||||
|
*/
|
||||||
public static final String SUPPORT_RIM = "Support";
|
public static final String SUPPORT_RIM = "Support";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,12 +78,6 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
|||||||
public Selector(final ReferenceManifestManager referenceManifestManager) {
|
public Selector(final ReferenceManifestManager referenceManifestManager) {
|
||||||
super(referenceManifestManager);
|
super(referenceManifestManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify a manufacturer that certificates must have to be considered as matching.
|
|
||||||
* @param rimType the manufacturer to query, not empty or null
|
|
||||||
* @return this instance (for chaining further calls)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,9 +99,14 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
|||||||
@Column
|
@Column
|
||||||
private String platformManufacturerId = null;
|
private String platformManufacturerId = null;
|
||||||
@Column
|
@Column
|
||||||
|
private String firmwareVersion = null;
|
||||||
|
@Column
|
||||||
private String platformModel = null;
|
private String platformModel = null;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String fileName = null;
|
private String fileName = null;
|
||||||
|
@Type(type = "uuid-char")
|
||||||
|
@Column
|
||||||
|
private UUID associatedRim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Selector for use in retrieving ReferenceManifest.
|
* Get a Selector for use in retrieving ReferenceManifest.
|
||||||
@ -119,8 +127,18 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
|||||||
this.rimBytes = null;
|
this.rimBytes = null;
|
||||||
this.rimHash = 0;
|
this.rimHash = 0;
|
||||||
this.rimType = null;
|
this.rimType = null;
|
||||||
|
this.platformManufacturer = null;
|
||||||
|
this.platformManufacturerId = null;
|
||||||
|
this.platformModel = null;
|
||||||
|
this.fileName = BASE_RIM;
|
||||||
|
this.tagId = null;
|
||||||
|
this.associatedRim = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor for ingesting the bytes of the file content.
|
||||||
|
* @param rimBytes - file contents.
|
||||||
|
*/
|
||||||
public ReferenceManifest(final byte[] rimBytes) {
|
public ReferenceManifest(final byte[] rimBytes) {
|
||||||
Preconditions.checkArgument(rimBytes != null,
|
Preconditions.checkArgument(rimBytes != null,
|
||||||
"Cannot construct a RIM from a null byte array");
|
"Cannot construct a RIM from a null byte array");
|
||||||
@ -238,6 +256,40 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
|||||||
this.tagId = tagId;
|
this.tagId = tagId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the firmware version info.
|
||||||
|
*
|
||||||
|
* @return string for the firmware version
|
||||||
|
*/
|
||||||
|
public String getFirmwareVersion() {
|
||||||
|
return firmwareVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for the firmware version info.
|
||||||
|
*
|
||||||
|
* @param firmwareVersion passed in firmware version
|
||||||
|
*/
|
||||||
|
public void setFirmwareVersion(final String firmwareVersion) {
|
||||||
|
this.firmwareVersion = firmwareVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the associated RIM DB ID.
|
||||||
|
* @return UUID for the rim
|
||||||
|
*/
|
||||||
|
public UUID getAssociatedRim() {
|
||||||
|
return associatedRim;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for the associated RIM DB ID.
|
||||||
|
* @param associatedRim UUID for the rim
|
||||||
|
*/
|
||||||
|
public void setAssociatedRim(final UUID associatedRim) {
|
||||||
|
this.associatedRim = associatedRim;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the Reference Integrity Manifest as a byte array.
|
* Getter for the Reference Integrity Manifest as a byte array.
|
||||||
*
|
*
|
||||||
@ -264,4 +316,26 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getRimHash();
|
return getRimHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object object) {
|
||||||
|
if (this == object) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (object == null || getClass() != object.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!super.equals(object)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ReferenceManifest that = (ReferenceManifest) object;
|
||||||
|
return rimHash == that.rimHash
|
||||||
|
&& Arrays.equals(rimBytes, that.rimBytes)
|
||||||
|
&& rimType.equals(that.rimType)
|
||||||
|
&& tagId.equals(that.tagId)
|
||||||
|
&& platformManufacturer.equals(that.platformManufacturer)
|
||||||
|
&& platformManufacturerId.equals(that.platformManufacturerId)
|
||||||
|
&& platformModel.equals(that.platformModel)
|
||||||
|
&& fileName.equals(that.fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,45 @@
|
|||||||
package hirs.data.persist;
|
package hirs.data.persist;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import hirs.tpm.eventlog.TCGEventLog;
|
||||||
|
import hirs.tpm.eventlog.TpmPcrEvent;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub class that will just focus on PCR Values and Events
|
* Sub class that will just focus on PCR Values and Events.
|
||||||
*/
|
*/
|
||||||
|
@Entity
|
||||||
public class SupportReferenceManifest extends ReferenceManifest {
|
public class SupportReferenceManifest extends ReferenceManifest {
|
||||||
private static final Logger LOGGER = LogManager.getLogger(SupportReferenceManifest.class);
|
private static final Logger LOGGER = LogManager.getLogger(SupportReferenceManifest.class);
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private int pcrHash;
|
private int pcrHash = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support constructor for the RIM object.
|
||||||
|
*
|
||||||
|
* @param fileName - string representation of the uploaded file.
|
||||||
|
* @param rimBytes byte array representation of the RIM
|
||||||
|
* @throws IOException if unable to unmarshal the string
|
||||||
|
*/
|
||||||
|
public SupportReferenceManifest(final String fileName,
|
||||||
|
final byte[] rimBytes) throws IOException {
|
||||||
|
this(rimBytes);
|
||||||
|
this.setRimType(SUPPORT_RIM);
|
||||||
|
this.setFileName(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main constructor for the RIM object. This takes in a byte array of a
|
* Main constructor for the RIM object. This takes in a byte array of a
|
||||||
@ -27,19 +51,71 @@ public class SupportReferenceManifest extends ReferenceManifest {
|
|||||||
public SupportReferenceManifest(final byte[] rimBytes) throws IOException {
|
public SupportReferenceManifest(final byte[] rimBytes) throws IOException {
|
||||||
super(rimBytes);
|
super(rimBytes);
|
||||||
this.setRimType(SUPPORT_RIM);
|
this.setRimType(SUPPORT_RIM);
|
||||||
|
this.pcrHash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor necessary for Hibernate.
|
* Default constructor necessary for Hibernate.
|
||||||
*/
|
*/
|
||||||
protected SupportReferenceManifest() {
|
protected SupportReferenceManifest() {
|
||||||
|
super();
|
||||||
|
this.pcrHash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter method for the expected PCR values contained within the support
|
||||||
|
* RIM.
|
||||||
|
* @return a string array of the pcr values.
|
||||||
|
*/
|
||||||
|
public String[] getExpectedPCRList() {
|
||||||
|
try {
|
||||||
|
TCGEventLog logProcessor = new TCGEventLog(this.getRimBytes());
|
||||||
|
this.pcrHash = Arrays.hashCode(logProcessor.getExpectedPCRValues());
|
||||||
|
return logProcessor.getExpectedPCRValues();
|
||||||
|
} catch (CertificateException cEx) {
|
||||||
|
LOGGER.error(cEx);
|
||||||
|
} catch (NoSuchAlgorithmException noSaEx) {
|
||||||
|
LOGGER.error(noSaEx);
|
||||||
|
} catch (IOException ioEx) {
|
||||||
|
LOGGER.error(ioEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter method for the event log that should be present in the support RIM.
|
||||||
|
*
|
||||||
|
* @return list of TPM PCR Events for display
|
||||||
|
*/
|
||||||
|
public List<TpmPcrEvent> getEventLog() {
|
||||||
|
TCGEventLog logProcessor = null;
|
||||||
|
try {
|
||||||
|
logProcessor = new TCGEventLog(this.getRimBytes());
|
||||||
|
return Collections.unmodifiableList(logProcessor.getEventList());
|
||||||
|
} catch (CertificateException cEx) {
|
||||||
|
LOGGER.error(cEx);
|
||||||
|
} catch (NoSuchAlgorithmException noSaEx) {
|
||||||
|
LOGGER.error(noSaEx);
|
||||||
|
} catch (IOException ioEx) {
|
||||||
|
LOGGER.error(ioEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the PCR Hash contained in the support RIM.
|
||||||
|
* @return hash in int form
|
||||||
|
*/
|
||||||
public int getPcrHash() {
|
public int getPcrHash() {
|
||||||
return pcrHash;
|
return pcrHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for the PCR Hash.
|
||||||
|
* @param pcrHash hash in int form
|
||||||
|
*/
|
||||||
public void setPcrHash(final int pcrHash) {
|
public void setPcrHash(final int pcrHash) {
|
||||||
this.pcrHash = pcrHash;
|
this.pcrHash = pcrHash;
|
||||||
}
|
}
|
||||||
|
@ -118,11 +118,11 @@ public abstract class ReferenceManifestSelector<ReferenceManifest> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specif the file name of the object to grab.
|
* Specify the file name of the object to grab.
|
||||||
* @param fileName the name of the file associated with the rim
|
* @param fileName the name of the file associated with the rim
|
||||||
* @return
|
* @return instance of the manifest in relation to the filename.
|
||||||
*/
|
*/
|
||||||
public ReferenceManifestSelector byFileName(final int fileName) {
|
public ReferenceManifestSelector byFileName(final String fileName) {
|
||||||
setFieldValue(RIM_FILENAME_FIELD, fileName);
|
setFieldValue(RIM_FILENAME_FIELD, fileName);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ public final class TCGEventLog {
|
|||||||
public String[] getExpectedPCRValues() {
|
public String[] getExpectedPCRValues() {
|
||||||
String[] pcrs = new String[PCR_COUNT];
|
String[] pcrs = new String[PCR_COUNT];
|
||||||
for (int i = 0; i < PCR_COUNT; i++) {
|
for (int i = 0; i < PCR_COUNT; i++) {
|
||||||
pcrs[i] = HexUtils.byteArrayToHexString(pcrList[i]);
|
pcrs[i] = Hex.encodeHexString(pcrList[i]);
|
||||||
}
|
}
|
||||||
return pcrs;
|
return pcrs;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package hirs.tpm.eventlog;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
@ -25,6 +26,9 @@ import hirs.tpm.eventlog.uefi.UefiConstants;
|
|||||||
import hirs.tpm.eventlog.uefi.UefiFirmware;
|
import hirs.tpm.eventlog.uefi.UefiFirmware;
|
||||||
import hirs.tpm.eventlog.uefi.UefiVariable;
|
import hirs.tpm.eventlog.uefi.UefiVariable;
|
||||||
import hirs.utils.HexUtils;
|
import hirs.utils.HexUtils;
|
||||||
|
import org.apache.commons.codec.binary.Hex;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to process a TCG_PCR_EVENT.
|
* Class to process a TCG_PCR_EVENT.
|
||||||
@ -44,32 +48,60 @@ import hirs.utils.HexUtils;
|
|||||||
* } TCG_PCR_EVENT;
|
* } TCG_PCR_EVENT;
|
||||||
*/
|
*/
|
||||||
public class TpmPcrEvent {
|
public class TpmPcrEvent {
|
||||||
/** Log format. SHA1=1, Crytpo agile=2. */
|
private static final Logger LOGGER = LogManager.getLogger(TpmPcrEvent.class);
|
||||||
private int logFormat = -1;
|
/**
|
||||||
/** PCR index. */
|
* Indent Offset.
|
||||||
private int pcrIndex = -1;
|
*/
|
||||||
/** Event Type (long). */
|
|
||||||
private long eventType = 0;
|
|
||||||
/** Event digest. */
|
|
||||||
private byte[] digest = null;
|
|
||||||
/** Even data (no content). */
|
|
||||||
private byte[] event;
|
|
||||||
/** Even content data. */
|
|
||||||
private byte[] eventContent;
|
|
||||||
/** TCG Event Log spec version. */
|
|
||||||
private String version = "Unknown";
|
|
||||||
/** TCG Event Log errata version. */
|
|
||||||
private String errata = "Unknown";
|
|
||||||
/** Description for toString support. */
|
|
||||||
private String description = "";
|
|
||||||
/** Length (in bytes) of a pcr. */
|
|
||||||
private int digestLength = 0;
|
|
||||||
/** Event hash for SHA1 event logs. */
|
|
||||||
private byte[] eventDataSha1hash;
|
|
||||||
/** Event hash for Crypto Agile events. */
|
|
||||||
private byte[] eventDataSha256hash;
|
|
||||||
/** Indent Offset. */
|
|
||||||
private static final int INDENT_3 = 3;
|
private static final int INDENT_3 = 3;
|
||||||
|
/**
|
||||||
|
* Log format. SHA1=1, Crytpo agile=2.
|
||||||
|
*/
|
||||||
|
private int logFormat = -1;
|
||||||
|
/**
|
||||||
|
* PCR index.
|
||||||
|
*/
|
||||||
|
private int pcrIndex = -1;
|
||||||
|
/**
|
||||||
|
* Event Type (long).
|
||||||
|
*/
|
||||||
|
private long eventType = 0;
|
||||||
|
/**
|
||||||
|
* Event digest.
|
||||||
|
*/
|
||||||
|
private byte[] digest = null;
|
||||||
|
/**
|
||||||
|
* Event data (no content).
|
||||||
|
*/
|
||||||
|
private byte[] event;
|
||||||
|
/**
|
||||||
|
* Event content data.
|
||||||
|
*/
|
||||||
|
private byte[] eventContent;
|
||||||
|
/**
|
||||||
|
* TCG Event Log spec version.
|
||||||
|
*/
|
||||||
|
private String version = "Unknown";
|
||||||
|
/**
|
||||||
|
* TCG Event Log errata version.
|
||||||
|
*/
|
||||||
|
private String errata = "Unknown";
|
||||||
|
/**
|
||||||
|
* Description for toString support.
|
||||||
|
*/
|
||||||
|
private String description = "";
|
||||||
|
/**
|
||||||
|
* Length (in bytes) of a pcr.
|
||||||
|
*/
|
||||||
|
private int digestLength = 0;
|
||||||
|
/**
|
||||||
|
* Event hash for SHA1 event logs.
|
||||||
|
*/
|
||||||
|
private byte[] eventDataSha1hash;
|
||||||
|
/**
|
||||||
|
* Event hash for Crypto Agile events.
|
||||||
|
*/
|
||||||
|
private byte[] eventDataSha256hash;
|
||||||
|
private EvPostCode evPostCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -104,6 +136,14 @@ public class TpmPcrEvent {
|
|||||||
return digestCopy;
|
return digestCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a hex representation of the event digest.
|
||||||
|
* @return hex string
|
||||||
|
*/
|
||||||
|
public String getEventDigestStr() {
|
||||||
|
return Hex.encodeHexString(this.digest);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the event PCR index value from a TCG Event.
|
* Sets the event PCR index value from a TCG Event.
|
||||||
*
|
*
|
||||||
@ -122,8 +162,10 @@ public class TpmPcrEvent {
|
|||||||
return pcrIndex;
|
return pcrIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the Log Format for this TCG Event.
|
/**
|
||||||
|
* Sets the Log Format for this TCG Event.
|
||||||
* 1 = SHA1 Format, 2 = Crypto Agile format.
|
* 1 = SHA1 Format, 2 = Crypto Agile format.
|
||||||
|
*
|
||||||
* @param format indicates log format.
|
* @param format indicates log format.
|
||||||
*/
|
*/
|
||||||
protected void setLogFormat(final int format) {
|
protected void setLogFormat(final int format) {
|
||||||
@ -133,6 +175,7 @@ public class TpmPcrEvent {
|
|||||||
/**
|
/**
|
||||||
* Gets the Log Format for this TCG Event.
|
* Gets the Log Format for this TCG Event.
|
||||||
* 1 = SHA1 Format, 2 = Crypto Agile format.
|
* 1 = SHA1 Format, 2 = Crypto Agile format.
|
||||||
|
*
|
||||||
* @return number representing the format.
|
* @return number representing the format.
|
||||||
*/
|
*/
|
||||||
public int getLogFormat() {
|
public int getLogFormat() {
|
||||||
@ -157,6 +200,14 @@ public class TpmPcrEvent {
|
|||||||
return eventType;
|
return eventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a formatted string of the type for the event.
|
||||||
|
* @return a string formatted to be human readable
|
||||||
|
*/
|
||||||
|
public String getEventTypeStr() {
|
||||||
|
return String.format("0x%s %s", Long.toHexString(eventType), eventString((int) eventType));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the version of the TCG Log Event specification pertaining to the log.
|
* Returns the version of the TCG Log Event specification pertaining to the log.
|
||||||
* only updated if the event is a TCG_EfiSpecIdEvent.
|
* only updated if the event is a TCG_EfiSpecIdEvent.
|
||||||
@ -190,11 +241,13 @@ public class TpmPcrEvent {
|
|||||||
/**
|
/**
|
||||||
* Gets the Event Data (no event content) for the event.
|
* Gets the Event Data (no event content) for the event.
|
||||||
* event log format.
|
* event log format.
|
||||||
|
*
|
||||||
* @return byte array holding the event structure.
|
* @return byte array holding the event structure.
|
||||||
*/
|
*/
|
||||||
public byte[] getEvent() {
|
public byte[] getEvent() {
|
||||||
return java.util.Arrays.copyOf(event, event.length);
|
return java.util.Arrays.copyOf(event, event.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the event content after processing.
|
* Sets the event content after processing.
|
||||||
*
|
*
|
||||||
@ -202,17 +255,168 @@ public class TpmPcrEvent {
|
|||||||
*/
|
*/
|
||||||
protected void setEventContent(final byte[] eventData) {
|
protected void setEventContent(final byte[] eventData) {
|
||||||
eventContent = new byte[eventData.length];
|
eventContent = new byte[eventData.length];
|
||||||
|
evPostCode = new EvPostCode(eventContent);
|
||||||
System.arraycopy(eventData, 0, eventContent, 0, eventData.length);
|
System.arraycopy(eventData, 0, eventContent, 0, eventData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the event Content Data (not the entire event structure).
|
* Gets the event Content Data (not the entire event structure).
|
||||||
|
*
|
||||||
* @return byte array holding the events content field
|
* @return byte array holding the events content field
|
||||||
*/
|
*/
|
||||||
public byte[] getEventContent() {
|
public byte[] getEventContent() {
|
||||||
return java.util.Arrays.copyOf(eventContent, eventContent.length);
|
return java.util.Arrays.copyOf(eventContent, eventContent.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A getter that parses the content based on the type and returns the proper string
|
||||||
|
* value for the content.
|
||||||
|
* @return an appended string of human readable data
|
||||||
|
*/
|
||||||
|
public String getEventContentStr() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
switch ((int) this.eventType) {
|
||||||
|
case EvConstants.EV_PREBOOT_CERT:
|
||||||
|
sb.append(" EV_PREBOOT_CERT");
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_POST_CODE:
|
||||||
|
sb.append(new EvPostCode(eventContent).toString());
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_UNUSED:
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_NO_ACTION:
|
||||||
|
EvNoAction noAction = null;
|
||||||
|
try {
|
||||||
|
noAction = new EvNoAction(eventContent);
|
||||||
|
sb.append(noAction.toString());
|
||||||
|
if (noAction.isSpecIDEvent()) {
|
||||||
|
// this should be in the constructor
|
||||||
|
EvEfiSpecIdEvent specID = noAction.getEvEfiSpecIdEvent();
|
||||||
|
version = String.format("%s.%s",
|
||||||
|
specID.getVersionMajor(),
|
||||||
|
specID.getVersionMinor());
|
||||||
|
errata = specID.getErrata();
|
||||||
|
}
|
||||||
|
} catch (UnsupportedEncodingException ueEx) {
|
||||||
|
LOGGER.error(ueEx);
|
||||||
|
sb.append(ueEx.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_SEPARATOR:
|
||||||
|
if (EvPostCode.isAscii(eventContent)
|
||||||
|
&& !this.isBlank(eventContent)) {
|
||||||
|
sb.append(String.format("Separator event content = %s",
|
||||||
|
new String(eventContent, StandardCharsets.UTF_8)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EVENT_TAG:
|
||||||
|
sb.append(new EvEventTag(eventContent).toString());
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_S_CRTM_CONTENTS:
|
||||||
|
sb.append(new EvSCrtmContents(eventContent).toString());
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_S_CRTM_VERSION:
|
||||||
|
try {
|
||||||
|
sb.append(new EvSCrtmVersion(eventContent).toString());
|
||||||
|
} catch (UnsupportedEncodingException ueEx) {
|
||||||
|
LOGGER.error(ueEx);
|
||||||
|
sb.append(ueEx.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_CPU_MICROCODE:
|
||||||
|
case EvConstants.EV_PLATFORM_CONFIG_FLAGS:
|
||||||
|
case EvConstants.EV_TABLE_OF_DEVICES:
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_COMPACT_HASH:
|
||||||
|
try {
|
||||||
|
sb.append(new EvCompactHash(eventContent).toString());
|
||||||
|
} catch (UnsupportedEncodingException ueEx) {
|
||||||
|
LOGGER.error(ueEx);
|
||||||
|
sb.append(ueEx.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_IPL:
|
||||||
|
sb.append(new EvIPL(eventContent).toString());
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_IPL_PARTITION_DATA:
|
||||||
|
case EvConstants.EV_NONHOST_CODE:
|
||||||
|
case EvConstants.EV_NONHOST_CONFIG:
|
||||||
|
case EvConstants.EV_NONHOST_INFO:
|
||||||
|
case EvConstants.EV_EV_OMIT_BOOT_DEVICES_EVENTS:
|
||||||
|
case EvConstants.EV_EFI_EVENT_BASE:
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_VARIABLE_DRIVER_CONFIG:
|
||||||
|
UefiVariable efiVar = null;
|
||||||
|
try {
|
||||||
|
efiVar = new UefiVariable(eventContent);
|
||||||
|
String efiVarDescription = efiVar.toString().replace("\n", "\n ");
|
||||||
|
sb.append(efiVarDescription.substring(0,
|
||||||
|
efiVarDescription.length() - INDENT_3));
|
||||||
|
} catch (CertificateException cEx) {
|
||||||
|
LOGGER.error(cEx);
|
||||||
|
sb.append(cEx.toString());
|
||||||
|
} catch (NoSuchAlgorithmException noSaEx) {
|
||||||
|
LOGGER.error(noSaEx);
|
||||||
|
sb.append(noSaEx.toString());
|
||||||
|
} catch (IOException ioEx) {
|
||||||
|
LOGGER.error(ioEx);
|
||||||
|
sb.append(ioEx.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_VARIABLE_BOOT:
|
||||||
|
case EvConstants.EV_EFI_VARIABLE_AUTHORITY:
|
||||||
|
try {
|
||||||
|
sb.append(new UefiVariable(eventContent).toString());
|
||||||
|
} catch (CertificateException cEx) {
|
||||||
|
LOGGER.error(cEx);
|
||||||
|
sb.append(cEx.toString());
|
||||||
|
} catch (NoSuchAlgorithmException noSaEx) {
|
||||||
|
LOGGER.error(noSaEx);
|
||||||
|
sb.append(noSaEx.toString());
|
||||||
|
} catch (IOException ioEx) {
|
||||||
|
LOGGER.error(ioEx);
|
||||||
|
sb.append(ioEx.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_BOOT_SERVICES_APPLICATION:
|
||||||
|
case EvConstants.EV_EFI_BOOT_SERVICES_DRIVER: // same as EV_EFI_BOOT_SERVICES_APP
|
||||||
|
try {
|
||||||
|
sb.append(new EvEfiBootServicesApp(eventContent).toString());
|
||||||
|
} catch (UnsupportedEncodingException ueEx) {
|
||||||
|
LOGGER.error(ueEx);
|
||||||
|
sb.append(ueEx.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_RUNTIME_SERVICES_DRIVER:
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_GPT_EVENT:
|
||||||
|
try {
|
||||||
|
sb.append(new EvEfiGptPartition(eventContent).toString());
|
||||||
|
} catch (UnsupportedEncodingException ueEx) {
|
||||||
|
LOGGER.error(ueEx);
|
||||||
|
sb.append(ueEx.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_ACTION:
|
||||||
|
case EvConstants.EV_ACTION:
|
||||||
|
sb.append(new String(eventContent, StandardCharsets.UTF_8));
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_PLATFORM_FIRMWARE_BLOB:
|
||||||
|
sb.append(new UefiFirmware(eventContent).toString());
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_HANDOFF_TABLES:
|
||||||
|
sb.append(new EvEfiHandoffTable(eventContent).toString());
|
||||||
|
break;
|
||||||
|
case EvConstants.EV_EFI_HCRTM_EVENT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sb.append("Unknown Event found\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Digest Length.
|
* Sets the Digest Length.
|
||||||
* Also the number of bytes expected within each PCR.
|
* Also the number of bytes expected within each PCR.
|
||||||
@ -234,6 +438,7 @@ public class TpmPcrEvent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the event content and creates a human readable description of each event.
|
* Parses the event content and creates a human readable description of each event.
|
||||||
|
*
|
||||||
* @param event the byte array holding the event data.
|
* @param event the byte array holding the event data.
|
||||||
* @param eventContent the byte array holding the event content.
|
* @param eventContent the byte array holding the event content.
|
||||||
* @param eventNumber event position within the event log.
|
* @param eventNumber event position within the event log.
|
||||||
@ -250,9 +455,9 @@ public class TpmPcrEvent {
|
|||||||
description += "Event Type: 0x" + Long.toHexString(eventType) + " " + eventString(eventID);
|
description += "Event Type: 0x" + Long.toHexString(eventType) + " " + eventString(eventID);
|
||||||
description += "\n";
|
description += "\n";
|
||||||
if (logFormat == 1) { // Digest
|
if (logFormat == 1) { // Digest
|
||||||
description += "digest (SHA-1): " + HexUtils.byteArrayToHexString(this.digest);
|
description += "digest (SHA-1): " + Hex.encodeHexString(this.digest);
|
||||||
} else {
|
} else {
|
||||||
description += "digest (SHA256): " + HexUtils.byteArrayToHexString(this.digest);
|
description += "digest (SHA256): " + Hex.encodeHexString(this.digest);
|
||||||
}
|
}
|
||||||
if (eventID != UefiConstants.SIZE_4) {
|
if (eventID != UefiConstants.SIZE_4) {
|
||||||
description += "\n";
|
description += "\n";
|
||||||
@ -287,9 +492,9 @@ public class TpmPcrEvent {
|
|||||||
break;
|
break;
|
||||||
case EvConstants.EV_SEPARATOR:
|
case EvConstants.EV_SEPARATOR:
|
||||||
if (EvPostCode.isAscii(eventContent)) {
|
if (EvPostCode.isAscii(eventContent)) {
|
||||||
String seperatorEventData = new String(eventContent, StandardCharsets.UTF_8);
|
String separatorEventData = new String(eventContent, StandardCharsets.UTF_8);
|
||||||
if (!this.isEmpty(eventContent)) {
|
if (!this.isBlank(eventContent)) {
|
||||||
description += "Seperator event content = " + seperatorEventData;
|
description += "Separator event content = " + separatorEventData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -373,7 +578,8 @@ public class TpmPcrEvent {
|
|||||||
case EvConstants.EV_EFI_VARIABLE_AUTHORITY:
|
case EvConstants.EV_EFI_VARIABLE_AUTHORITY:
|
||||||
description += "Event Content:\n" + new UefiVariable(eventContent).toString();
|
description += "Event Content:\n" + new UefiVariable(eventContent).toString();
|
||||||
break;
|
break;
|
||||||
default: description += " Unknown Event found" + "\n";
|
default:
|
||||||
|
description += " Unknown Event found" + "\n";
|
||||||
}
|
}
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
@ -381,6 +587,7 @@ public class TpmPcrEvent {
|
|||||||
/**
|
/**
|
||||||
* Converts the Event ID into a String As defined in the TCG PC Client FW Profile.
|
* Converts the Event ID into a String As defined in the TCG PC Client FW Profile.
|
||||||
* Event IDs have values larger than an integer,so a Long is used hold the value.
|
* Event IDs have values larger than an integer,so a Long is used hold the value.
|
||||||
|
*
|
||||||
* @param event the event id.
|
* @param event the event id.
|
||||||
* @return TCG defined String that represents the event id
|
* @return TCG defined String that represents the event id
|
||||||
*/
|
*/
|
||||||
@ -455,23 +662,25 @@ public class TpmPcrEvent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Human readable output of a check of input against the current event hash.
|
* Human readable output of a check of input against the current event hash.
|
||||||
|
*
|
||||||
* @return human readable string.
|
* @return human readable string.
|
||||||
*/
|
*/
|
||||||
private String eventHashCheck() {
|
private String eventHashCheck() {
|
||||||
String result = "";
|
String result = "";
|
||||||
if (logFormat == 1) {
|
if (logFormat == 1) {
|
||||||
if (Arrays.equals(this.digest, eventDataSha1hash)) { result
|
if (Arrays.equals(this.digest, eventDataSha1hash)) {
|
||||||
|
result
|
||||||
+= "Event digest matched hash of the event data " + "\n";
|
+= "Event digest matched hash of the event data " + "\n";
|
||||||
} else {
|
} else {
|
||||||
result += "Event digest DID NOT match the hash of the event data :"
|
result += "Event digest DID NOT match the hash of the event data :"
|
||||||
+ HexUtils.byteArrayToHexString(getEventDigest()) + "\n";
|
+ Hex.encodeHexString(getEventDigest()) + "\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Arrays.equals(this.digest, eventDataSha256hash)) {
|
if (Arrays.equals(this.digest, eventDataSha256hash)) {
|
||||||
result += "Event digest matched hash of the event data " + "\n";
|
result += "Event digest matched hash of the event data " + "\n";
|
||||||
} else {
|
} else {
|
||||||
result += "Event digest DID NOT match the hash of the event data :"
|
result += "Event digest DID NOT match the hash of the event data :"
|
||||||
+ HexUtils.byteArrayToHexString(getEventDigest()) + "\n";
|
+ Hex.encodeHexString(getEventDigest()) + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -479,10 +688,11 @@ public class TpmPcrEvent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks a byte array for all zeros.
|
* Checks a byte array for all zeros.
|
||||||
|
*
|
||||||
* @param array holds data to check.
|
* @param array holds data to check.
|
||||||
* @return true of all zeros are found.
|
* @return true of all zeros are found.
|
||||||
*/
|
*/
|
||||||
public boolean isEmpty(final byte[] array) {
|
public boolean isBlank(final byte[] array) {
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
if (array[i] != 0) {
|
if (array[i] != 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -493,6 +703,7 @@ public class TpmPcrEvent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Human readable string representing the contents of the Event Log.
|
* Human readable string representing the contents of the Event Log.
|
||||||
|
*
|
||||||
* @return Description of the log.
|
* @return Description of the log.
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@ -501,6 +712,7 @@ public class TpmPcrEvent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Human readable string representing the contents of the Event Log.
|
* Human readable string representing the contents of the Event Log.
|
||||||
|
*
|
||||||
* @param bEvent event Flag.
|
* @param bEvent event Flag.
|
||||||
* @param bContent content flag.
|
* @param bContent content flag.
|
||||||
* @param bHexEvent hex event flag.
|
* @param bHexEvent hex event flag.
|
||||||
@ -517,7 +729,7 @@ public class TpmPcrEvent {
|
|||||||
}
|
}
|
||||||
byte[] eventData = getEvent();
|
byte[] eventData = getEvent();
|
||||||
sb.append("Event (Hex no Content) (" + eventData.length + " bytes): "
|
sb.append("Event (Hex no Content) (" + eventData.length + " bytes): "
|
||||||
+ HexUtils.byteArrayToHexString(eventData));
|
+ Hex.encodeHexString(eventData));
|
||||||
}
|
}
|
||||||
if (bContent) {
|
if (bContent) {
|
||||||
byte[] evContent = getEventContent();
|
byte[] evContent = getEventContent();
|
||||||
@ -525,7 +737,7 @@ public class TpmPcrEvent {
|
|||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
}
|
}
|
||||||
sb.append("Event content (Hex) (" + evContent.length + " bytes): "
|
sb.append("Event content (Hex) (" + evContent.length + " bytes): "
|
||||||
+ HexUtils.byteArrayToHexString(evContent));
|
+ Hex.encodeHexString(evContent));
|
||||||
}
|
}
|
||||||
return sb.toString() + "\n";
|
return sb.toString() + "\n";
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,7 @@ public class EvPostCode {
|
|||||||
public EvPostCode(final byte[] postCode) {
|
public EvPostCode(final byte[] postCode) {
|
||||||
// 2 ways post code has been implemented, check for the ascii string first
|
// 2 ways post code has been implemented, check for the ascii string first
|
||||||
if (isAscii(postCode)) {
|
if (isAscii(postCode)) {
|
||||||
String info = new String(postCode, StandardCharsets.UTF_8);
|
codeInfo = new String(postCode, StandardCharsets.UTF_8);
|
||||||
codeInfo = info;
|
|
||||||
bisString = true;
|
bisString = true;
|
||||||
} else {
|
} else {
|
||||||
blob = new UefiFirmware(postCode);
|
blob = new UefiFirmware(postCode);
|
||||||
@ -46,7 +45,7 @@ public class EvPostCode {
|
|||||||
* Returns the UEFI Defined Firmware Blob information.
|
* Returns the UEFI Defined Firmware Blob information.
|
||||||
* @return UEFI Defined Firmware Blob information.
|
* @return UEFI Defined Firmware Blob information.
|
||||||
*/
|
*/
|
||||||
public UefiFirmware getfirmwareBlob() {
|
public UefiFirmware getFirmwareBlob() {
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,12 +74,11 @@ public class EvPostCode {
|
|||||||
* @return true if byte array is a string.
|
* @return true if byte array is a string.
|
||||||
*/
|
*/
|
||||||
public static boolean isAscii(final byte[] postCode) {
|
public static boolean isAscii(final byte[] postCode) {
|
||||||
boolean bisAscii = true;
|
|
||||||
for (byte b : postCode) {
|
for (byte b : postCode) {
|
||||||
if (!Character.isDefined(b)) {
|
if (!Character.isDefined(b)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bisAscii;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,44 @@
|
|||||||
package hirs.tpm.eventlog.uefi;
|
package hirs.tpm.eventlog.uefi;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
import hirs.utils.HexUtils;
|
import hirs.utils.HexUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to process the PFP defined UEFI_PLATFORM_FIRMWARE_BLOB structure.
|
* Class to process the PFP defined UEFI_PLATFORM_FIRMWARE_BLOB structure.
|
||||||
*
|
* <p>
|
||||||
* typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB {
|
* typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB {
|
||||||
* UEFI_PHYSICAL_ADDRESS BlobBase;
|
* UEFI_PHYSICAL_ADDRESS BlobBase;
|
||||||
* UINT64 BlobLength;
|
* UINT64 BlobLength;
|
||||||
* } UEFI_PLATFORM_FIRMWARE_BLOB;
|
* } UEFI_PLATFORM_FIRMWARE_BLOB;
|
||||||
*/
|
*/
|
||||||
public class UefiFirmware {
|
public class UefiFirmware {
|
||||||
private boolean berror = false;
|
private boolean bError = false;
|
||||||
/** byte array holding the firmwares physical address. */
|
/**
|
||||||
|
* byte array holding the firmwares physical address.
|
||||||
|
*/
|
||||||
private byte[] physicalAddress = null;
|
private byte[] physicalAddress = null;
|
||||||
/** byte array holding the uefi address length. */
|
/**
|
||||||
|
* byte array holding the uefi address length.
|
||||||
|
*/
|
||||||
private byte[] addressLength = null;
|
private byte[] addressLength = null;
|
||||||
/** uefi physical address. */
|
/**
|
||||||
|
* uefi physical address.
|
||||||
|
*/
|
||||||
private int blobAddress = 0;
|
private int blobAddress = 0;
|
||||||
/** uefi address length. */
|
/**
|
||||||
|
* uefi address length.
|
||||||
|
*/
|
||||||
private int blobLength = 0;
|
private int blobLength = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UefiFirmware constructor.
|
* UefiFirmware constructor.
|
||||||
|
*
|
||||||
* @param blob byte array holding a Firmware Blob.
|
* @param blob byte array holding a Firmware Blob.
|
||||||
*/
|
*/
|
||||||
public UefiFirmware(final byte[] blob) {
|
public UefiFirmware(final byte[] blob) {
|
||||||
if (blob.length != UefiConstants.SIZE_16) {
|
if (blob.length != UefiConstants.SIZE_16) {
|
||||||
berror = true;
|
bError = true;
|
||||||
} else {
|
} else {
|
||||||
physicalAddress = new byte[UefiConstants.SIZE_8];
|
physicalAddress = new byte[UefiConstants.SIZE_8];
|
||||||
addressLength = new byte[UefiConstants.SIZE_8];
|
addressLength = new byte[UefiConstants.SIZE_8];
|
||||||
@ -37,37 +47,44 @@ public class UefiFirmware {
|
|||||||
byte[] lelength = HexUtils.leReverseByte(addressLength);
|
byte[] lelength = HexUtils.leReverseByte(addressLength);
|
||||||
BigInteger bigIntLength = new BigInteger(lelength);
|
BigInteger bigIntLength = new BigInteger(lelength);
|
||||||
blobLength = bigIntLength.intValue();
|
blobLength = bigIntLength.intValue();
|
||||||
byte[]leAddress = HexUtils.leReverseByte(physicalAddress);
|
byte[] leAddress = HexUtils.leReverseByte(physicalAddress);
|
||||||
BigInteger bigIntAddress = new BigInteger(leAddress);
|
BigInteger bigIntAddress = new BigInteger(leAddress);
|
||||||
blobAddress = bigIntAddress.intValue();
|
blobAddress = bigIntAddress.intValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Returns the uefi firmware blobs physical address.
|
* Returns the uefi firmware blobs physical address.
|
||||||
|
*
|
||||||
* @return uefi firmware address.
|
* @return uefi firmware address.
|
||||||
*/
|
*/
|
||||||
public int getPhysicalAddress() {
|
public int getPhysicalAddress() {
|
||||||
return blobAddress;
|
return blobAddress;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Returns the length of the blobs physical address.
|
* Returns the length of the blobs physical address.
|
||||||
|
*
|
||||||
* @return length of the address.
|
* @return length of the address.
|
||||||
*/
|
*/
|
||||||
public int getBlobLength() {
|
public int getBlobLength() {
|
||||||
return blobLength;
|
return blobLength;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Returns a description of the firmware blobs location.
|
* Returns a description of the firmware blobs location.
|
||||||
|
*
|
||||||
* @return a description of the the firmware blobs location.
|
* @return a description of the the firmware blobs location.
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String blobInfo = "";
|
StringBuilder blobInfo = new StringBuilder();
|
||||||
if (!berror) {
|
if (!bError) {
|
||||||
blobInfo += " Platform Firwmare Blob Address = " + Integer.toHexString(blobAddress);
|
blobInfo.append(String.format(" Platform Firmware Blob Address = %s",
|
||||||
blobInfo += " length = " + blobLength;
|
Integer.toHexString(blobAddress)));
|
||||||
|
blobInfo.append(String.format(" length = %d", blobLength));
|
||||||
} else {
|
} else {
|
||||||
blobInfo += " Invalid Firmware Blob event encountered";
|
blobInfo.append(" Invalid Firmware Blob event encountered");
|
||||||
}
|
}
|
||||||
return blobInfo;
|
return blobInfo.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,13 @@ final class Main {
|
|||||||
private static byte[] eventLog = null;
|
private static byte[] eventLog = null;
|
||||||
private static boolean bContentFlag, bEventFlag, bHexEvent, bHexFlag, bPcrFlag = false;
|
private static boolean bContentFlag, bEventFlag, bHexEvent, bHexFlag, bPcrFlag = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Constructor.
|
* Main Constructor.
|
||||||
|
*
|
||||||
* @param args command line parameters.
|
* @param args command line parameters.
|
||||||
*/
|
*/
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
commander = new Commander(args);
|
commander = new Commander(args);
|
||||||
if (!commander.getValidityFlag()) {
|
if (!commander.getValidityFlag()) {
|
||||||
System.out.print("Program exiting without processs due to issues with"
|
System.out.print("Program exiting without processs due to issues with"
|
||||||
+ " parameters provided.");
|
+ " parameters provided.");
|
||||||
@ -83,10 +84,10 @@ commander = new Commander(args);
|
|||||||
if (commander.getHexFlag()) {
|
if (commander.getHexFlag()) {
|
||||||
bHexFlag = true;
|
bHexFlag = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.print("Nothing to do: No Parameters provided.");
|
System.out.print("Nothing to do: No Parameters provided.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
} // End commander processing
|
} // End commander processing
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (eventLog == null) {
|
if (eventLog == null) {
|
||||||
@ -101,7 +102,7 @@ commander = new Commander(args);
|
|||||||
writeOut("Expected Platform Configuration Register (PCR) values"
|
writeOut("Expected Platform Configuration Register (PCR) values"
|
||||||
+ " derived from the Event Log: \n\n");
|
+ " derived from the Event Log: \n\n");
|
||||||
}
|
}
|
||||||
for (String pcr: pcrs) {
|
for (String pcr : pcrs) {
|
||||||
if (count++ == commander.getPcrNumber() || (commander.getPcrNumber() == -1)) {
|
if (count++ == commander.getPcrNumber() || (commander.getPcrNumber() == -1)) {
|
||||||
if (bHexFlag) {
|
if (bHexFlag) {
|
||||||
writeOut(pcr.toString() + "\n");
|
writeOut(pcr.toString() + "\n");
|
||||||
@ -127,7 +128,7 @@ commander = new Commander(args);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int eventCount = 0;
|
int eventCount = 0;
|
||||||
for (TpmPcrEvent event: evLog.getEventList()) {
|
for (TpmPcrEvent event : evLog.getEventList()) {
|
||||||
if ((commander.getEventNumber() == eventCount++)
|
if ((commander.getEventNumber() == eventCount++)
|
||||||
|| commander.getEventNumber() == -1) {
|
|| commander.getEventNumber() == -1) {
|
||||||
if ((commander.getPcrNumber() == event.getPcrIndex())
|
if ((commander.getPcrNumber() == event.getPcrIndex())
|
||||||
@ -160,10 +161,11 @@ commander = new Commander(args);
|
|||||||
+ "\nError was " + a.toString());
|
+ "\nError was " + a.toString());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a TCG Event log file.
|
* Opens a TCG Event log file.
|
||||||
|
*
|
||||||
* @param fileName Name of the log file. Will use a OS specific default.
|
* @param fileName Name of the log file. Will use a OS specific default.
|
||||||
* @return a byte array holding the entire log
|
* @return a byte array holding the entire log
|
||||||
*/
|
*/
|
||||||
@ -201,6 +203,7 @@ commander = new Commander(args);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write data out to the system and/or a file.
|
* Write data out to the system and/or a file.
|
||||||
|
*
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
private static void writeOut(final String data) {
|
private static void writeOut(final String data) {
|
||||||
@ -219,6 +222,7 @@ commander = new Commander(args);
|
|||||||
/**
|
/**
|
||||||
* Compares 2 Event Logs and returns a string based upon the results.
|
* Compares 2 Event Logs and returns a string based upon the results.
|
||||||
* Uses the Events digest field for comparisons.
|
* Uses the Events digest field for comparisons.
|
||||||
|
*
|
||||||
* @param logFileName1 Log file to use as a reference.
|
* @param logFileName1 Log file to use as a reference.
|
||||||
* @param logFileName2 Log file to compare to the reference.
|
* @param logFileName2 Log file to compare to the reference.
|
||||||
* @return A sting containing human readable results.
|
* @return A sting containing human readable results.
|
||||||
@ -276,10 +280,12 @@ commander = new Commander(args);
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare this event log against a second event log.
|
* Compare this event log against a second event log.
|
||||||
* Returns a String Array of event descriptions in which the digests from the first
|
* Returns a String Array of event descriptions in which the digests from the first
|
||||||
* did no match the second. Return value is null if all events matched.
|
* did no match the second. Return value is null if all events matched.
|
||||||
|
*
|
||||||
* @param eventList initial events.
|
* @param eventList initial events.
|
||||||
* @param eventList2 events to compare against.
|
* @param eventList2 events to compare against.
|
||||||
* @param pcr used as a filter. Use -1 to check all pcrs.
|
* @param pcr used as a filter. Use -1 to check all pcrs.
|
||||||
@ -306,6 +312,7 @@ commander = new Commander(args);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks a digest from a single event against all digests with the same index in an Event Log.
|
* Checks a digest from a single event against all digests with the same index in an Event Log.
|
||||||
|
*
|
||||||
* @param eventLog The Reference Event log.
|
* @param eventLog The Reference Event log.
|
||||||
* @param event single event to match.
|
* @param event single event to match.
|
||||||
* @return
|
* @return
|
||||||
|
Loading…
Reference in New Issue
Block a user