mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-19 04:58:00 +00:00
These changes may be removed because the issue is becoming more involved and I may need to rethink how this will work.
This commit is contained in:
parent
c523dda558
commit
cd206f870c
@ -909,11 +909,10 @@ public abstract class AbstractAttestationCertificateAuthority
|
||||
try {
|
||||
// find previous version. If it exists, delete it
|
||||
measurements = EventLogMeasurements.select(referenceManifestManager)
|
||||
.byDeviceName(dv.getNw().getHostname())
|
||||
.includeArchived().getRIM();
|
||||
.byDeviceName(dv.getNw().getHostname()).getRIM();
|
||||
if (measurements != null) {
|
||||
LOG.info("Previous bios measurement log found and being replaced...");
|
||||
this.referenceManifestManager.delete(measurements);
|
||||
LOG.info("Previous bios measurement log found and being archived...");
|
||||
this.referenceManifestManager.update(measurements);
|
||||
}
|
||||
measurements = new EventLogMeasurements(fileName,
|
||||
dv.getLivelog().toByteArray());
|
||||
|
@ -380,7 +380,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
||||
.byDeviceName(device.getDeviceInfo().getNetworkInfo().getHostname()).getRIMs();
|
||||
|
||||
measurement = EventLogMeasurements.select(referenceManifestManager)
|
||||
.byManufacturer(manufacturer).includeArchived().getRIM();
|
||||
.byManufacturer(manufacturer).getRIM();
|
||||
|
||||
for (BaseReferenceManifest bRim : baseReferenceManifests) {
|
||||
if (!bRim.isSwidSupplemental() && !bRim.isSwidPatch()) {
|
||||
@ -444,7 +444,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
||||
if (passed) {
|
||||
TCGEventLog logProcessor;
|
||||
try {
|
||||
logProcessor = new TCGEventLog(measurement.getRimBytes());
|
||||
logProcessor = new TCGEventLog(supportReferenceManifest.getRimBytes());
|
||||
baseline = logProcessor.getExpectedPCRValues();
|
||||
} catch (CertificateException cEx) {
|
||||
LOGGER.error(cEx);
|
||||
@ -644,10 +644,6 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
||||
validations.add(buildValidationRecord(scv.getValidationType(),
|
||||
scv.getResult(), scv.getMessage(),
|
||||
scv.getCertificatesUsed().get(0), Level.INFO));
|
||||
} else {
|
||||
validations.add(buildValidationRecord(scv.getValidationType(),
|
||||
scv.getResult(), scv.getMessage(),
|
||||
quoteScv.getCertificatesUsed().get(0), Level.INFO));
|
||||
}
|
||||
}
|
||||
validations.add(quoteScv);
|
||||
|
@ -95,7 +95,6 @@ public class EventLogMeasurements extends ReferenceManifest {
|
||||
super(rimBytes);
|
||||
this.setFileName(fileName);
|
||||
this.setRimType(MEASUREMENT_RIM);
|
||||
this.archive("Measurement event log");
|
||||
this.pcrHash = 0;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package hirs.data.persist;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.hibernate.annotations.Type;
|
||||
@ -15,6 +16,8 @@ import javax.xml.XMLConstants;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -28,6 +31,10 @@ import java.util.UUID;
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@Access(AccessType.FIELD)
|
||||
public abstract class ReferenceManifest extends ArchivableEntity {
|
||||
/**
|
||||
* Holds the name of the 'hexDecHash' field.
|
||||
*/
|
||||
public static final String HEX_DEC_HASH_FIELD = "hexDecHash";
|
||||
/**
|
||||
* String for display of a Base RIM.
|
||||
*/
|
||||
@ -90,6 +97,9 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
||||
@Column
|
||||
@JsonIgnore
|
||||
private String deviceName;
|
||||
@Column
|
||||
@JsonIgnore
|
||||
private String hexDecHash = "";
|
||||
|
||||
/**
|
||||
* Default constructor necessary for Hibernate.
|
||||
@ -118,6 +128,15 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
||||
"Cannot construct a RIM from an empty byte array");
|
||||
|
||||
this.rimBytes = rimBytes.clone();
|
||||
MessageDigest digest = null;
|
||||
this.hexDecHash = "";
|
||||
try {
|
||||
digest = MessageDigest.getInstance("SHA-256");
|
||||
this.hexDecHash = Hex.encodeHexString(
|
||||
digest.digest(rimBytes));
|
||||
} catch (NoSuchAlgorithmException noSaEx) {
|
||||
LOGGER.error(noSaEx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,6 +349,15 @@ public abstract class ReferenceManifest extends ArchivableEntity {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the Reference Integrity Manifest hash value.
|
||||
*
|
||||
* @return int representation of the hash value
|
||||
*/
|
||||
public String getHexDecHash() {
|
||||
return hexDecHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the Reference Integrity Manifest as a byte array.
|
||||
*
|
||||
|
@ -5,14 +5,12 @@ import hirs.persist.ReferenceManifestManager;
|
||||
import hirs.persist.ReferenceManifestSelector;
|
||||
import hirs.tpm.eventlog.TCGEventLog;
|
||||
import hirs.tpm.eventlog.TpmPcrEvent;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.ArrayList;
|
||||
@ -25,14 +23,6 @@ import java.util.Collection;
|
||||
@Entity
|
||||
public class SupportReferenceManifest extends ReferenceManifest {
|
||||
private static final Logger LOGGER = LogManager.getLogger(SupportReferenceManifest.class);
|
||||
/**
|
||||
* Holds the name of the 'hexDecHash' field.
|
||||
*/
|
||||
public static final String HEX_DEC_HASH_FIELD = "hexDecHash";
|
||||
|
||||
@Column
|
||||
@JsonIgnore
|
||||
private String hexDecHash = "";
|
||||
@Column
|
||||
@JsonIgnore
|
||||
private int pcrHash = 0;
|
||||
@ -114,15 +104,6 @@ public class SupportReferenceManifest extends ReferenceManifest {
|
||||
this.setFileName(fileName);
|
||||
this.setRimType(SUPPORT_RIM);
|
||||
this.pcrHash = 0;
|
||||
MessageDigest digest = null;
|
||||
this.hexDecHash = "";
|
||||
try {
|
||||
digest = MessageDigest.getInstance("SHA-256");
|
||||
this.hexDecHash = Hex.encodeHexString(
|
||||
digest.digest(rimBytes));
|
||||
} catch (NoSuchAlgorithmException noSaEx) {
|
||||
LOGGER.error(noSaEx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,13 +234,4 @@ public class SupportReferenceManifest extends ReferenceManifest {
|
||||
public boolean isBaseSupport() {
|
||||
return !this.isSwidSupplemental() && !this.isSwidPatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the Reference Integrity Manifest hash value.
|
||||
*
|
||||
* @return int representation of the hash value
|
||||
*/
|
||||
public String getHexDecHash() {
|
||||
return hexDecHash;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user