mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-18 20:47:58 +00:00
Finished issue. Ready for PR
This commit is contained in:
parent
337a626335
commit
0a5de5316e
@ -19,7 +19,7 @@ import java.util.Map;
|
||||
public class SwidResource {
|
||||
|
||||
@Getter
|
||||
private final boolean validFileSize = false;
|
||||
private static final boolean VALID_FILE_SIZE = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -8,7 +8,7 @@ import javax.xml.namespace.QName;
|
||||
* class. It is expected that member properties of this class will expand as
|
||||
* more functionality is added to SwidTagGateway.
|
||||
*/
|
||||
public class SwidTagConstants {
|
||||
public final class SwidTagConstants {
|
||||
|
||||
public static final String DEFAULT_KEYSTORE_FILE = "keystore.jks"; //"/opt/hirs/rimtool/keystore.jks";
|
||||
public static final String DEFAULT_KEYSTORE_PASSWORD = "password";
|
||||
|
@ -13,7 +13,7 @@ import java.io.IOException;
|
||||
* Class to process the DEVICE_SECURITY_EVENT_DATA_HEADER.
|
||||
* DEVICE_SECURITY_EVENT_DATA_HEADER contains the measurement(s) and hash algorithm identifier
|
||||
* returned by the SPDM "GET_MEASUREMENTS" function.
|
||||
*
|
||||
* <p>
|
||||
* HEADERS defined by PFP v1.06 Rev 52:
|
||||
* <p>
|
||||
* typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER {
|
||||
@ -62,8 +62,9 @@ public class DeviceSecurityEventDataHeader extends DeviceSecurityEventHeader {
|
||||
|
||||
super(dsedBytes);
|
||||
|
||||
final int dsedBytesSrcIndex1 = 18;
|
||||
byte[] lengthBytes = new byte[UefiConstants.SIZE_2];
|
||||
System.arraycopy(dsedBytes, 18, lengthBytes, 0,
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex1, lengthBytes, 0,
|
||||
UefiConstants.SIZE_2);
|
||||
length = HexUtils.leReverseInt(lengthBytes);
|
||||
|
||||
@ -72,18 +73,22 @@ public class DeviceSecurityEventDataHeader extends DeviceSecurityEventHeader {
|
||||
UefiConstants.SIZE_4);
|
||||
spdmHashAlgo = HexUtils.leReverseInt(spdmHashAlgoBytes);
|
||||
|
||||
extractDeviceType(dsedBytes, 24);
|
||||
final int dsedBytesStartByte = 24;
|
||||
extractDeviceType(dsedBytes, dsedBytesStartByte);
|
||||
|
||||
// get the size of the SPDM Measurement Block
|
||||
final int dsedBytesSrcIndex2 = 30;
|
||||
byte[] sizeOfSpdmMeasBlockBytes = new byte[UefiConstants.SIZE_2];
|
||||
System.arraycopy(dsedBytes, 30, sizeOfSpdmMeasBlockBytes, 0,
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex2, sizeOfSpdmMeasBlockBytes, 0,
|
||||
UefiConstants.SIZE_2);
|
||||
int sizeOfSpdmMeas = HexUtils.leReverseInt(sizeOfSpdmMeasBlockBytes);
|
||||
int sizeOfSpdmMeasBlock = sizeOfSpdmMeas + 4; // header is 4 bytes
|
||||
final int sizeOfSpdmMeas = HexUtils.leReverseInt(sizeOfSpdmMeasBlockBytes);
|
||||
final int offSetBytesForSpdm = 4;
|
||||
final int sizeOfSpdmMeasBlock = sizeOfSpdmMeas + offSetBytesForSpdm; // header is 4 bytes
|
||||
|
||||
// extract the bytes that comprise the SPDM Measurement Block
|
||||
final int dsedBytesSrcIndex3 = 28;
|
||||
byte[] spdmMeasBlockBytes = new byte[sizeOfSpdmMeasBlock];
|
||||
System.arraycopy(dsedBytes, 28, spdmMeasBlockBytes, 0,
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex3, spdmMeasBlockBytes, 0,
|
||||
sizeOfSpdmMeasBlock);
|
||||
|
||||
ByteArrayInputStream spdmMeasurementBlockData =
|
||||
@ -96,7 +101,8 @@ public class DeviceSecurityEventDataHeader extends DeviceSecurityEventHeader {
|
||||
spdmMeasurementBlockInfo = " Error reading SPDM Measurement Block";
|
||||
}
|
||||
|
||||
int devPathLenStartByte = 28 + sizeOfSpdmMeasBlock;
|
||||
final int offSetBytesForDevPath = 28;
|
||||
final int devPathLenStartByte = offSetBytesForDevPath + sizeOfSpdmMeasBlock;
|
||||
extractDevicePathAndFinalSize(dsedBytes, devPathLenStartByte);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import lombok.Getter;
|
||||
* Class to process the DEVICE_SECURITY_EVENT_DATA_HEADER2.
|
||||
* DEVICE_SECURITY_EVENT_DATA_HEADER2 contains the measurement(s) and hash algorithm identifier
|
||||
* returned by the SPDM "GET_MEASUREMENTS" function.
|
||||
*
|
||||
* <p>
|
||||
* HEADERS defined by PFP v1.06 Rev 52:
|
||||
* <p>
|
||||
* typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER2 {
|
||||
@ -27,6 +27,32 @@ import lombok.Getter;
|
||||
*/
|
||||
public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader {
|
||||
|
||||
/**
|
||||
* Auth state - success.
|
||||
*/
|
||||
public static final int AUTH_SUCCESS = 0;
|
||||
/**
|
||||
* Auth state - digital signature of the data is valid, but the public key certificate chain is not
|
||||
* validated with the entry in the UEFI device signature variable.
|
||||
*/
|
||||
public static final int AUTH_NO_AUTHORITY = 1;
|
||||
/**
|
||||
* Auth state - digital signature of the measurement data is valid, but the reported device capabilities,
|
||||
* negotiated parameters or certificate chains were not validated by a transcript.
|
||||
*/
|
||||
public static final int AUTH_NO_BINDING = 2;
|
||||
/**
|
||||
* Auth state - data has no digital signature.
|
||||
*/
|
||||
public static final int AUTH_FAIL_NO_SIG = 3;
|
||||
/**
|
||||
* Auth state - data is invalid.
|
||||
*/
|
||||
public static final int AUTH_FAIL_INVALID = 4;
|
||||
/**
|
||||
* Auth state - device is not an SPDM-capable device.
|
||||
*/
|
||||
public static final int AUTH_NO_SPDM = 0xFF;
|
||||
/**
|
||||
* Event auth state.
|
||||
*/
|
||||
@ -55,33 +81,6 @@ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader {
|
||||
@Getter
|
||||
private String subHeaderUid = "";
|
||||
|
||||
/**
|
||||
* Auth state - success.
|
||||
*/
|
||||
public static final int AUTH_SUCCESS = 0;
|
||||
/**
|
||||
* Auth state - digital signature of the data is valid, but the public key certificate chain is not
|
||||
* validated with the entry in the UEFI device signature variable.
|
||||
*/
|
||||
public static final int AUTH_NO_AUTHORITY = 1;
|
||||
/**
|
||||
* Auth state - digital signature of the measurement data is valid, but the reported device capabilities,
|
||||
* negotiated parameters or certificate chains were not validated by a transcript.
|
||||
*/
|
||||
public static final int AUTH_NO_BINDING = 2;
|
||||
/**
|
||||
* Auth state - data has no digital signature.
|
||||
*/
|
||||
public static final int AUTH_FAIL_NO_SIG = 3;
|
||||
/**
|
||||
* Auth state - data is invalid.
|
||||
*/
|
||||
public static final int AUTH_FAIL_INVALID = 4;
|
||||
/**
|
||||
* Auth state - device is not an SPDM-capable device.
|
||||
*/
|
||||
public static final int AUTH_NO_SPDM = 0xFF;
|
||||
|
||||
/**
|
||||
* DeviceSecurityEventDataHeader2 Constructor.
|
||||
*
|
||||
@ -91,33 +90,43 @@ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader {
|
||||
|
||||
super(dsedBytes);
|
||||
|
||||
final int dsedBytesSrcIndex = 18;
|
||||
byte[] authStateBytes = new byte[1];
|
||||
System.arraycopy(dsedBytes, 18, authStateBytes, 0, 1);
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex, authStateBytes, 0, 1);
|
||||
authState = HexUtils.leReverseInt(authStateBytes);
|
||||
|
||||
// byte[] reserved[Bytes]: 1 byte
|
||||
|
||||
byte[] lengthBytes = new byte[4];
|
||||
System.arraycopy(dsedBytes, 20, lengthBytes, 0, 4);
|
||||
final int dsedBytesSrcIndex2 = 20;
|
||||
final int lengthBytesSize = 4;
|
||||
byte[] lengthBytes = new byte[lengthBytesSize];
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex2, lengthBytes, 0, lengthBytesSize);
|
||||
length = HexUtils.leReverseInt(lengthBytes);
|
||||
|
||||
extractDeviceType(dsedBytes, 24);
|
||||
final int dsedBytesStartByte1 = 24;
|
||||
extractDeviceType(dsedBytes, dsedBytesStartByte1);
|
||||
|
||||
byte[] subHeaderTypeBytes = new byte[4];
|
||||
System.arraycopy(dsedBytes, 28, subHeaderTypeBytes, 0, 4);
|
||||
final int dsedBytesSrcIndex3 = 28;
|
||||
final int subHeaderTypeBytesSize = 4;
|
||||
byte[] subHeaderTypeBytes = new byte[subHeaderTypeBytesSize];
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex3, subHeaderTypeBytes, 0, subHeaderTypeBytesSize);
|
||||
subHeaderType = HexUtils.leReverseInt(subHeaderTypeBytes);
|
||||
|
||||
byte[] subHeaderLengthBytes = new byte[4];
|
||||
System.arraycopy(dsedBytes, 32, subHeaderLengthBytes, 0, 4);
|
||||
final int dsedBytesSrcIndex4 = 32;
|
||||
final int subHeaderLengthBytesSize = 4;
|
||||
byte[] subHeaderLengthBytes = new byte[subHeaderLengthBytesSize];
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex4, subHeaderLengthBytes, 0, subHeaderLengthBytesSize);
|
||||
subHeaderLength = HexUtils.leReverseInt(subHeaderLengthBytes);
|
||||
|
||||
byte[] subHeaderUidBytes = new byte[8];
|
||||
System.arraycopy(dsedBytes, 36, subHeaderUidBytes, 0, 8);
|
||||
final int dsedBytesSrcIndex5 = 36;
|
||||
final int subHeaderUidBytesSize = 8;
|
||||
byte[] subHeaderUidBytes = new byte[subHeaderUidBytesSize];
|
||||
System.arraycopy(dsedBytes, dsedBytesSrcIndex5, subHeaderUidBytes, 0, subHeaderUidBytesSize);
|
||||
subHeaderUidBytes = HexUtils.leReverseByte(subHeaderUidBytes);
|
||||
subHeaderUid = HexUtils.byteArrayToHexString(subHeaderUidBytes);
|
||||
|
||||
int devPathLenStartByte = 44;
|
||||
extractDevicePathAndFinalSize(dsedBytes, devPathLenStartByte);
|
||||
final int dsedBytesStartByte2 = 44;
|
||||
extractDevicePathAndFinalSize(dsedBytes, dsedBytesStartByte2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,22 +148,14 @@ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader {
|
||||
* @return a description of the auth state.
|
||||
*/
|
||||
public String getAuthStateString() {
|
||||
|
||||
switch (authState) {
|
||||
case AUTH_SUCCESS:
|
||||
return ("AUTH_SUCCESS");
|
||||
case AUTH_NO_AUTHORITY:
|
||||
return ("AUTH_NO_AUTHORITY");
|
||||
case AUTH_NO_BINDING:
|
||||
return ("AUTH_NO_BINDING");
|
||||
case AUTH_FAIL_NO_SIG:
|
||||
return ("AUTH_FAIL_NO_SIG");
|
||||
case AUTH_FAIL_INVALID:
|
||||
return ("AUTH_FAIL_INVALID");
|
||||
case AUTH_NO_SPDM:
|
||||
return ("AUTH_NO_SPDM");
|
||||
default:
|
||||
return ("Auth State unknown");
|
||||
}
|
||||
return switch (authState) {
|
||||
case AUTH_SUCCESS -> ("AUTH_SUCCESS");
|
||||
case AUTH_NO_AUTHORITY -> ("AUTH_NO_AUTHORITY");
|
||||
case AUTH_NO_BINDING -> ("AUTH_NO_BINDING");
|
||||
case AUTH_FAIL_NO_SIG -> ("AUTH_FAIL_NO_SIG");
|
||||
case AUTH_FAIL_INVALID -> ("AUTH_FAIL_INVALID");
|
||||
case AUTH_NO_SPDM -> ("AUTH_NO_SPDM");
|
||||
default -> ("Auth State unknown");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -78,28 +78,36 @@ public class DeviceSecurityEventDataPciContext extends DeviceSecurityEventDataDe
|
||||
|
||||
super(dSEDpciContextBytes);
|
||||
|
||||
final int dSEDpciContextBytesSrcIndex1 = 4;
|
||||
byte[] pciVendorIdBytes = new byte[2];
|
||||
System.arraycopy(dSEDpciContextBytes, 4, pciVendorIdBytes, 0, 2);
|
||||
System.arraycopy(dSEDpciContextBytes, dSEDpciContextBytesSrcIndex1, pciVendorIdBytes, 0, 2);
|
||||
vendorId = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciVendorIdBytes));
|
||||
|
||||
final int dSEDpciContextBytesSrcIndex2 = 6;
|
||||
byte[] pciDeviceIdBytes = new byte[2];
|
||||
System.arraycopy(dSEDpciContextBytes, 6, pciDeviceIdBytes, 0, 2);
|
||||
System.arraycopy(dSEDpciContextBytes, dSEDpciContextBytesSrcIndex2, pciDeviceIdBytes, 0, 2);
|
||||
deviceId = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciDeviceIdBytes));
|
||||
|
||||
final int dSEDpciContextBytesSrcIndex3 = 8;
|
||||
byte[] pciRevisionIdBytes = new byte[1];
|
||||
System.arraycopy(dSEDpciContextBytes, 8, pciRevisionIdBytes, 0, 1);
|
||||
System.arraycopy(dSEDpciContextBytes, dSEDpciContextBytesSrcIndex3, pciRevisionIdBytes, 0, 1);
|
||||
revisionId = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciRevisionIdBytes));
|
||||
|
||||
byte[] pciClassCodeBytes = new byte[3];
|
||||
System.arraycopy(dSEDpciContextBytes, 9, pciClassCodeBytes, 0, 3);
|
||||
final int dSEDpciContextBytesSrcIndex4 = 9;
|
||||
final int pciClassCodeBytesSize = 3;
|
||||
byte[] pciClassCodeBytes = new byte[pciClassCodeBytesSize];
|
||||
System.arraycopy(dSEDpciContextBytes, dSEDpciContextBytesSrcIndex4, pciClassCodeBytes, 0,
|
||||
pciClassCodeBytesSize);
|
||||
classCode = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciClassCodeBytes));
|
||||
|
||||
final int dSEDpciContextBytesSrcIndex5 = 12;
|
||||
byte[] pciSubsystemVendorIdBytes = new byte[2];
|
||||
System.arraycopy(dSEDpciContextBytes, 12, pciSubsystemVendorIdBytes, 0, 2);
|
||||
System.arraycopy(dSEDpciContextBytes, dSEDpciContextBytesSrcIndex5, pciSubsystemVendorIdBytes, 0, 2);
|
||||
subsystemVendorId = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciSubsystemVendorIdBytes));
|
||||
|
||||
final int dSEDpciContextBytesSrcIndex6 = 14;
|
||||
byte[] pciSubsystemIdBytes = new byte[2];
|
||||
System.arraycopy(dSEDpciContextBytes, 14, pciSubsystemIdBytes, 0, 2);
|
||||
System.arraycopy(dSEDpciContextBytes, dSEDpciContextBytesSrcIndex6, pciSubsystemIdBytes, 0, 2);
|
||||
subsystemId = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciSubsystemIdBytes));
|
||||
}
|
||||
|
||||
@ -118,8 +126,9 @@ public class DeviceSecurityEventDataPciContext extends DeviceSecurityEventDataDe
|
||||
dSEDpciContextInfo += " RevisionID = " + revisionId + "\n";
|
||||
|
||||
List<String> classCodeList = translateDeviceClass(classCode);
|
||||
final int validClassCodeListSize = 3;
|
||||
dSEDpciContextInfo += " Device Class: \n";
|
||||
if (classCodeList.size() == 3) {
|
||||
if (classCodeList.size() == validClassCodeListSize) {
|
||||
dSEDpciContextInfo += " Class = " + classCodeList.get(0) + "\n";
|
||||
dSEDpciContextInfo += " Subclass = " + classCodeList.get(1) + "\n";
|
||||
dSEDpciContextInfo += " Programming Interface = " + classCodeList.get(2) + "\n";
|
||||
|
@ -61,16 +61,21 @@ public class DeviceSecurityEventDataSubHeaderCertChain extends DeviceSecurityEve
|
||||
|
||||
// byte[] reserved[Bytes]: 1 byte
|
||||
|
||||
byte[] spdmBaseHashAlgoBytes = new byte[4];
|
||||
System.arraycopy(dsedSubHBytes, 4, spdmBaseHashAlgoBytes, 0, 4);
|
||||
final int dsedSybHBytesSrcIndex1 = 4;
|
||||
final int spdmBaseHashAlgoBytesSize = 4;
|
||||
byte[] spdmBaseHashAlgoBytes = new byte[spdmBaseHashAlgoBytesSize];
|
||||
System.arraycopy(dsedSubHBytes, dsedSybHBytesSrcIndex1, spdmBaseHashAlgoBytes, 0,
|
||||
spdmBaseHashAlgoBytesSize);
|
||||
spdmBaseHashAlgo = HexUtils.leReverseInt(spdmBaseHashAlgoBytes);
|
||||
|
||||
// get the size of the SPDM Cert Chain
|
||||
int spdmCertChainSize = dsedSubHBytes.length - 8;
|
||||
final int offsetForSpdmCertChain = 8;
|
||||
int spdmCertChainSize = dsedSubHBytes.length - offsetForSpdmCertChain;
|
||||
|
||||
// extract the bytes that comprise the SPDM Cert Chain
|
||||
final int dsedSybHBytesSrcIndex2 = 8;
|
||||
byte[] spdmCertChainBytes = new byte[spdmCertChainSize];
|
||||
System.arraycopy(dsedSubHBytes, 8, spdmCertChainBytes, 0,
|
||||
System.arraycopy(dsedSubHBytes, dsedSybHBytesSrcIndex2, spdmCertChainBytes, 0,
|
||||
spdmCertChainSize);
|
||||
|
||||
int spdmBaseHashAlgoSize = SpdmHa.tcgAlgIdToByteSize(spdmBaseHashAlgo);
|
||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||
* SPDM_MEASUREMENT_BLOCK SpdmMeasurementBlock[SpdmMeasurementBlockCount];
|
||||
* } DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK;
|
||||
* <p>
|
||||
*
|
||||
* <p>
|
||||
* SpdmMeasurementBlock is an array of SPDM_MEASUREMENT_BLOCKs
|
||||
* The size of each block is the same and can be found by either:
|
||||
* 1) 4 + SpdmMeasurementBlock MeasurementSize
|
||||
@ -33,6 +33,10 @@ import java.util.List;
|
||||
*/
|
||||
public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends DeviceSecurityEventDataSubHeader {
|
||||
|
||||
/**
|
||||
* List of SPDM Measurement Blocks.
|
||||
*/
|
||||
private final List<SpdmMeasurementBlock> spdmMeasurementBlockList;
|
||||
/**
|
||||
* SPDM version.
|
||||
*/
|
||||
@ -48,11 +52,6 @@ public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends Device
|
||||
*/
|
||||
@Getter
|
||||
private int spdmMeasurementHashAlgo = -1;
|
||||
|
||||
/**
|
||||
* List of SPDM Measurement Blocks.
|
||||
*/
|
||||
private List<SpdmMeasurementBlock> spdmMeasurementBlockList;
|
||||
/**
|
||||
* Error reading SPDM Measurement Block.
|
||||
*/
|
||||
@ -77,16 +76,21 @@ public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends Device
|
||||
|
||||
// byte[] reserved[Bytes]: 1 byte
|
||||
|
||||
byte[] spdmMeasurementHashAlgoBytes = new byte[4];
|
||||
System.arraycopy(dsedSubHBytes, 4, spdmMeasurementHashAlgoBytes, 0, 4);
|
||||
final int spdmMeasurementHashAlgoBytesSize = 4;
|
||||
final int dsedSubHBytesSrcIndex1 = 4;
|
||||
byte[] spdmMeasurementHashAlgoBytes = new byte[spdmMeasurementHashAlgoBytesSize];
|
||||
System.arraycopy(dsedSubHBytes, dsedSubHBytesSrcIndex1, spdmMeasurementHashAlgoBytes, 0,
|
||||
spdmMeasurementHashAlgoBytesSize);
|
||||
spdmMeasurementHashAlgo = HexUtils.leReverseInt(spdmMeasurementHashAlgoBytes);
|
||||
|
||||
// get the total size of the SPDM Measurement Block List
|
||||
int spdmMeasurementBlockListSize = dsedSubHBytes.length - 8;
|
||||
final int offsetForspdmMeasurementBlockList = 8;
|
||||
final int spdmMeasurementBlockListSize = dsedSubHBytes.length - offsetForspdmMeasurementBlockList;
|
||||
|
||||
// extract the bytes that comprise the SPDM Measurement Block List
|
||||
final int dsedSubHBytesSrcIndex2 = 8;
|
||||
byte[] spdmMeasurementBlockListBytes = new byte[spdmMeasurementBlockListSize];
|
||||
System.arraycopy(dsedSubHBytes, 8, spdmMeasurementBlockListBytes, 0,
|
||||
System.arraycopy(dsedSubHBytes, dsedSubHBytesSrcIndex2, spdmMeasurementBlockListBytes, 0,
|
||||
spdmMeasurementBlockListSize);
|
||||
|
||||
ByteArrayInputStream spdmMeasurementBlockListData =
|
||||
|
@ -55,7 +55,7 @@ public abstract class DeviceSecurityEventHeader {
|
||||
* UEFI Device Path Length.
|
||||
*/
|
||||
@Getter
|
||||
private final int devicePathLength = 0;
|
||||
private static final int DEVICE_PATH_LENGTH = 0;
|
||||
/**
|
||||
* Contains the size (in bytes) of the header.
|
||||
*/
|
||||
@ -128,13 +128,15 @@ public abstract class DeviceSecurityEventHeader {
|
||||
int startByteUpdated = startByte;
|
||||
|
||||
// get the device path length
|
||||
byte[] devicePathLengthBytes = new byte[8];
|
||||
System.arraycopy(dsedBytes, startByteUpdated, devicePathLengthBytes, 0, 8);
|
||||
final int devicePathLengthBytesSize = 8;
|
||||
byte[] devicePathLengthBytes = new byte[devicePathLengthBytesSize];
|
||||
System.arraycopy(dsedBytes, startByteUpdated, devicePathLengthBytes, 0, devicePathLengthBytesSize);
|
||||
int retrievedDevicePathLength = HexUtils.leReverseInt(devicePathLengthBytes);
|
||||
|
||||
// get the device path
|
||||
if (retrievedDevicePathLength > 0) {
|
||||
startByteUpdated = startByteUpdated + 8;
|
||||
final int startByteUpdatedOffset = 8;
|
||||
startByteUpdated = startByteUpdated + startByteUpdatedOffset;
|
||||
byte[] devPathBytes = new byte[retrievedDevicePathLength];
|
||||
System.arraycopy(dsedBytes, startByteUpdated, devPathBytes,
|
||||
0, retrievedDevicePathLength);
|
||||
@ -153,16 +155,12 @@ public abstract class DeviceSecurityEventHeader {
|
||||
* @return name of the device type
|
||||
*/
|
||||
public String deviceTypeToString(final int deviceTypeInt) {
|
||||
switch (deviceTypeInt) {
|
||||
case DeviceSecurityEventDataDeviceContext.DEVICE_TYPE_NONE:
|
||||
return "No device type";
|
||||
case DeviceSecurityEventDataDeviceContext.DEVICE_TYPE_PCI:
|
||||
return "PCI";
|
||||
case DeviceSecurityEventDataDeviceContext.DEVICE_TYPE_USB:
|
||||
return "USB";
|
||||
default:
|
||||
return "Unknown or invalid Device Type";
|
||||
}
|
||||
return switch (deviceTypeInt) {
|
||||
case DeviceSecurityEventDataDeviceContext.DEVICE_TYPE_NONE -> "No device type";
|
||||
case DeviceSecurityEventDataDeviceContext.DEVICE_TYPE_PCI -> "PCI";
|
||||
case DeviceSecurityEventDataDeviceContext.DEVICE_TYPE_USB -> "USB";
|
||||
default -> "Unknown or invalid Device Type";
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,11 +6,6 @@ package hirs.utils.tpm.eventlog.events;
|
||||
*/
|
||||
public final class EvConstants {
|
||||
|
||||
/**
|
||||
* Default private constructor so checkstyles doesn't complain
|
||||
*/
|
||||
private EvConstants() { }
|
||||
|
||||
/**
|
||||
* Type length = 4 bytes.
|
||||
*/
|
||||
@ -39,11 +34,11 @@ public final class EvConstants {
|
||||
* Each PCR bank holds 24 registers.
|
||||
*/
|
||||
public static final int PCR_COUNT = 24;
|
||||
// Event IDs
|
||||
/**
|
||||
* Pre boot cert Event ID.
|
||||
*/
|
||||
public static final int EV_PREBOOT_CERT = 0x00000000;
|
||||
// Event IDs
|
||||
/**
|
||||
* POST Code Event ID.
|
||||
*/
|
||||
@ -180,4 +175,9 @@ public final class EvConstants {
|
||||
* EFI SPDM Device Authority Event ID.
|
||||
*/
|
||||
public static final int EV_EFI_SPDM_DEVICE_AUTHORITY = 0x800000E4;
|
||||
/**
|
||||
* Default private constructor so checkstyles doesn't complain.
|
||||
*/
|
||||
private EvConstants() {
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class EvNoAction {
|
||||
signature = signature.replaceAll("[^\\P{C}\t\r\n]", ""); // remove null characters
|
||||
if (signature.contains("Spec ID Event03")) { // implies CryptAgileFormat
|
||||
EvEfiSpecIdEvent specIDEvent = new EvEfiSpecIdEvent(eventData);
|
||||
noActionInfo += specIDEventToString(specIDEvent).toString();
|
||||
noActionInfo += specIDEventToString(specIDEvent);
|
||||
bSpecIDEvent = true;
|
||||
specVersion = String.format("%s.%s",
|
||||
specIDEvent.getVersionMajor(),
|
||||
@ -126,25 +126,21 @@ public class EvNoAction {
|
||||
* @return a description of the locality.
|
||||
*/
|
||||
private String getLocality(final byte[] eventData) {
|
||||
String localityInfo = "";
|
||||
final int eventDataSrcIndex = 16;
|
||||
byte[] localityBytes = new byte[1];
|
||||
System.arraycopy(eventData, 16, localityBytes, 0, 1);
|
||||
int locality = HexUtils.leReverseInt(localityBytes);
|
||||
System.arraycopy(eventData, eventDataSrcIndex, localityBytes, 0, 1);
|
||||
final int locality = HexUtils.leReverseInt(localityBytes);
|
||||
|
||||
switch (locality) {
|
||||
case 0:
|
||||
localityInfo += "Locality 0 without an H-CRTM sequence";
|
||||
break;
|
||||
case 3:
|
||||
localityInfo += "Locality 3 without an H-CRTM sequence";
|
||||
break;
|
||||
case 4:
|
||||
localityInfo += "Locality 4 with an H-CRTM sequence initialized";
|
||||
break;
|
||||
default:
|
||||
localityInfo += "Unknown";
|
||||
}
|
||||
return localityInfo;
|
||||
final int locality0 = 0;
|
||||
final int locality3 = 3;
|
||||
final int locality4 = 4;
|
||||
|
||||
return switch (locality) {
|
||||
case locality0 -> "Locality 0 without an H-CRTM sequence";
|
||||
case locality3 -> "Locality 3 without an H-CRTM sequence";
|
||||
case locality4 -> "Locality 4 with an H-CRTM sequence initialized";
|
||||
default -> "Unknown";
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,7 @@ import java.nio.charset.StandardCharsets;
|
||||
* Class to process the NV_INDEX_DYNAMIC_EVENT_LOG_DATA per PFP.
|
||||
* Per PFP, the first 16 bytes of the structure are a String based identifier (Signature),
|
||||
* which are a NULL-terminated ASCII string "NvIndexDynamic".
|
||||
*
|
||||
* <p>
|
||||
* HEADERS defined by PFP v1.06 Rev 52.
|
||||
* Certain fields are common to both ..HEADER and ..HEADER2, and are noted below the structures.
|
||||
* <p>
|
||||
@ -43,13 +43,16 @@ public class NvIndexDynamicEventLogData {
|
||||
*/
|
||||
public NvIndexDynamicEventLogData(final byte[] eventData) {
|
||||
|
||||
byte[] signatureBytes = new byte[16];
|
||||
System.arraycopy(eventData, 0, signatureBytes, 0, 16);
|
||||
final int signatureBytesSize = 16;
|
||||
byte[] signatureBytes = new byte[signatureBytesSize];
|
||||
System.arraycopy(eventData, 0, signatureBytes, 0, signatureBytesSize);
|
||||
signature = new String(signatureBytes, StandardCharsets.UTF_8);
|
||||
signature = signature.replaceAll("[^\\P{C}\t\r\n]", ""); // remove null characters
|
||||
|
||||
byte[] versionBytes = new byte[2];
|
||||
System.arraycopy(eventData, 16, versionBytes, 0, 2);
|
||||
final int versionBytesSize = 2;
|
||||
final int eventDataSrcIndex1 = 16;
|
||||
byte[] versionBytes = new byte[versionBytesSize];
|
||||
System.arraycopy(eventData, eventDataSrcIndex1, versionBytes, 0, versionBytesSize);
|
||||
String nvIndexVersion = HexUtils.byteArrayToHexString(versionBytes);
|
||||
if (nvIndexVersion.isEmpty()) {
|
||||
nvIndexVersion = "version not readable";
|
||||
@ -58,23 +61,28 @@ public class NvIndexDynamicEventLogData {
|
||||
nvIndexDynamicInfo += " Nv Index Dynamic Version = " + nvIndexVersion + "\n";
|
||||
|
||||
// 6 bytes of Reserved data
|
||||
|
||||
byte[] uidBytes = new byte[8];
|
||||
System.arraycopy(eventData, 24, uidBytes, 0, 8);
|
||||
final int uidBytesSize = 8;
|
||||
final int eventDataSrcIndex2 = 24;
|
||||
byte[] uidBytes = new byte[uidBytesSize];
|
||||
System.arraycopy(eventData, eventDataSrcIndex2, uidBytes, 0, uidBytesSize);
|
||||
String uid = HexUtils.byteArrayToHexString(uidBytes);
|
||||
nvIndexDynamicInfo += " UID = " + uid + "\n";
|
||||
|
||||
byte[] descriptionSizeBytes = new byte[2];
|
||||
System.arraycopy(eventData, 32, descriptionSizeBytes, 0, 2);
|
||||
final int descriptionSizeBytesLength = 2;
|
||||
final int eventDataSrcIndex3 = 32;
|
||||
byte[] descriptionSizeBytes = new byte[descriptionSizeBytesLength];
|
||||
System.arraycopy(eventData, eventDataSrcIndex3, descriptionSizeBytes, 0, descriptionSizeBytesLength);
|
||||
int descriptionSize = HexUtils.leReverseInt(descriptionSizeBytes);
|
||||
|
||||
final int eventDataSrcIndex4 = 34;
|
||||
byte[] descriptionBytes = new byte[descriptionSize];
|
||||
System.arraycopy(eventData, 34, descriptionBytes, 0, descriptionSize);
|
||||
System.arraycopy(eventData, eventDataSrcIndex4, descriptionBytes, 0, descriptionSize);
|
||||
String description = new String(descriptionBytes, StandardCharsets.UTF_8);
|
||||
description = description.replaceAll("[^\\P{C}\t\r\n]", ""); // remove null characters
|
||||
nvIndexDynamicInfo += " Description = " + description + "\n";
|
||||
|
||||
int dataSizeStartByte = 34 + descriptionSize;
|
||||
final int dataSizeOffset = 34;
|
||||
int dataSizeStartByte = dataSizeOffset + descriptionSize;
|
||||
byte[] dataSizeBytes = new byte[2];
|
||||
System.arraycopy(eventData, dataSizeStartByte, dataSizeBytes, 0, 2);
|
||||
int dataSize = HexUtils.leReverseInt(dataSizeBytes);
|
||||
|
@ -8,7 +8,7 @@ import java.nio.charset.StandardCharsets;
|
||||
* Class to process the NV_INDEX_INSTANCE_EVENT_LOG_DATA per PFP.
|
||||
* Per PFP, the first 16 bytes of the structure are a String based identifier (Signature),
|
||||
* which are a NULL-terminated ASCII string "NvIndexInstance".
|
||||
*
|
||||
* <p>
|
||||
* HEADERS defined by PFP v1.06 Rev 52.
|
||||
* Certain fields are common to both ..HEADER and ..HEADER2, and are noted below the structures.
|
||||
* <p>
|
||||
@ -45,13 +45,15 @@ public class NvIndexInstanceEventLogData {
|
||||
*/
|
||||
public NvIndexInstanceEventLogData(final byte[] eventData) {
|
||||
|
||||
byte[] signatureBytes = new byte[16];
|
||||
System.arraycopy(eventData, 0, signatureBytes, 0, 16);
|
||||
final int signatureBytesSize = 16;
|
||||
byte[] signatureBytes = new byte[signatureBytesSize];
|
||||
System.arraycopy(eventData, 0, signatureBytes, 0, signatureBytesSize);
|
||||
signature = new String(signatureBytes, StandardCharsets.UTF_8);
|
||||
signature = signature.replaceAll("[^\\P{C}\t\r\n]", ""); // remove null characters
|
||||
|
||||
final int eventDataSrcIndex1 = 16;
|
||||
byte[] versionBytes = new byte[2];
|
||||
System.arraycopy(eventData, 16, versionBytes, 0, 2);
|
||||
System.arraycopy(eventData, eventDataSrcIndex1, versionBytes, 0, 2);
|
||||
String nvIndexVersion = HexUtils.byteArrayToHexString(versionBytes);
|
||||
if (nvIndexVersion == "") {
|
||||
nvIndexVersion = "version not readable";
|
||||
@ -60,14 +62,16 @@ public class NvIndexInstanceEventLogData {
|
||||
nvIndexInstanceInfo += " Nv Index Instance Version = " + nvIndexVersion + "\n";
|
||||
|
||||
// 6 bytes of Reserved data
|
||||
|
||||
byte[] dsedSignatureBytes = new byte[16];
|
||||
System.arraycopy(eventData, 24, dsedSignatureBytes, 0, 16);
|
||||
final int eventDataSrcIndex2 = 24;
|
||||
final int dsedSignatureBytesSize = 16;
|
||||
byte[] dsedSignatureBytes = new byte[dsedSignatureBytesSize];
|
||||
System.arraycopy(eventData, eventDataSrcIndex2, dsedSignatureBytes, 0, dsedSignatureBytesSize);
|
||||
String dsedSignature = new String(dsedSignatureBytes, StandardCharsets.UTF_8);
|
||||
dsedSignature = dsedSignature.replaceAll("[^\\P{C}\t\r\n]", ""); // remove null characters
|
||||
|
||||
final int eventDataSrcIndex3 = 40;
|
||||
byte[] dsedVersionBytes = new byte[2];
|
||||
System.arraycopy(eventData, 40, dsedVersionBytes, 0, 2);
|
||||
System.arraycopy(eventData, eventDataSrcIndex3, dsedVersionBytes, 0, 2);
|
||||
String dsedVersion = HexUtils.byteArrayToHexString(dsedVersionBytes);
|
||||
if (dsedVersion == "") {
|
||||
dsedVersion = "version not readable";
|
||||
@ -75,9 +79,10 @@ public class NvIndexInstanceEventLogData {
|
||||
|
||||
if (dsedSignature.contains("SPDM Device Sec2")) {
|
||||
|
||||
int dsedEventDataSize = eventData.length - 24;
|
||||
final int eventDataSrcIndex4 = 24;
|
||||
final int dsedEventDataSize = eventData.length - eventDataSrcIndex4;
|
||||
byte[] dsedEventData = new byte[dsedEventDataSize];
|
||||
System.arraycopy(eventData, 24, dsedEventData, 0, dsedEventDataSize);
|
||||
System.arraycopy(eventData, eventDataSrcIndex4, dsedEventData, 0, dsedEventDataSize);
|
||||
|
||||
nvIndexInstanceInfo += " Signature = SPDM Device Sec2\n";
|
||||
|
||||
@ -89,7 +94,7 @@ public class NvIndexInstanceEventLogData {
|
||||
+ dsedVersion + "\n";
|
||||
}
|
||||
} else {
|
||||
nvIndexInstanceInfo = " Signature error: should be \'SPDM Device Sec2\' but is "
|
||||
nvIndexInstanceInfo = " Signature error: should be 'SPDM Device Sec2' but is "
|
||||
+ signature + "\n";
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ public class SpdmCertificateChain {
|
||||
// * Length of the certificate chain to include all fields in this structure.
|
||||
// */
|
||||
//private int length = 0;
|
||||
/**
|
||||
* Array List of certs found in the chain.
|
||||
*/
|
||||
private final ArrayList<UefiX509Cert> certList = new ArrayList<UefiX509Cert>();
|
||||
/**
|
||||
* Root hash.
|
||||
*/
|
||||
@ -46,10 +50,6 @@ public class SpdmCertificateChain {
|
||||
* Number of certs in the SPDM cert chain.
|
||||
*/
|
||||
private int numberOfCerts = 0;
|
||||
/**
|
||||
* Array List of certs found in the chain.
|
||||
*/
|
||||
private ArrayList<UefiX509Cert> certList = new ArrayList<UefiX509Cert>();
|
||||
/**
|
||||
* Human-readable description of any error associated with SPDM base hash alg.
|
||||
*/
|
||||
@ -76,11 +76,13 @@ public class SpdmCertificateChain {
|
||||
|
||||
// Reserved: 2 bytes
|
||||
|
||||
final int spdmCertChainBytesSrcIndex = 4;
|
||||
rootHash = new byte[rootHashLength];
|
||||
System.arraycopy(spdmCertChainBytes, 4, rootHash, 0, rootHashLength);
|
||||
System.arraycopy(spdmCertChainBytes, spdmCertChainBytesSrcIndex, rootHash, 0, rootHashLength);
|
||||
|
||||
int certChainStartPos = 4 + rootHashLength;
|
||||
int certChainLength = spdmCertChainBytes.length - certChainStartPos;
|
||||
final int offsetForCertChain = 4;
|
||||
final int certChainStartPos = offsetForCertChain + rootHashLength;
|
||||
final int certChainLength = spdmCertChainBytes.length - certChainStartPos;
|
||||
byte[] certChainBytes = new byte[certChainLength];
|
||||
System.arraycopy(spdmCertChainBytes, certChainStartPos, certChainBytes, 0, certChainLength);
|
||||
|
||||
@ -113,10 +115,11 @@ public class SpdmCertificateChain {
|
||||
byte[] certData = new byte[cLength];
|
||||
certChainDataIS.read(certData);
|
||||
// put the cert back together
|
||||
byte[] certBlob = new byte[cLength + 4];
|
||||
final int certBlobStartIndex = 4;
|
||||
byte[] certBlob = new byte[cLength + certBlobStartIndex];
|
||||
System.arraycopy(certType, 0, certBlob, 0, 2);
|
||||
System.arraycopy(certLength, 0, certBlob, 2, 2);
|
||||
System.arraycopy(certData, 0, certBlob, 4, cLength);
|
||||
System.arraycopy(certData, 0, certBlob, certBlobStartIndex, cLength);
|
||||
cert = new UefiX509Cert(certBlob);
|
||||
//cert = new X509Certificate(certBlob);
|
||||
certList.add(cert);
|
||||
|
@ -4,7 +4,7 @@ package hirs.utils.tpm.eventlog.spdm;
|
||||
* Class for defining hash algorithms referenced in the DMTF SPDM specification.
|
||||
* SPDM 1.3.0, Table 21, MeasurementHashAlgo.
|
||||
*/
|
||||
public class SpdmHa {
|
||||
public final class SpdmHa {
|
||||
|
||||
/**
|
||||
* Spdm Hash Alg = Raw bit stream.
|
||||
@ -49,32 +49,16 @@ public class SpdmHa {
|
||||
* @return name of the algorithm
|
||||
*/
|
||||
public static String tcgAlgIdToString(final int algId) {
|
||||
String alg;
|
||||
switch (algId) {
|
||||
case TPM_ALG_RAW:
|
||||
alg = "Raw Bit Stream";
|
||||
break;
|
||||
case TPM_ALG_SHA_256:
|
||||
alg = "TPM_ALG_SHA_256";
|
||||
break;
|
||||
case TPM_ALG_SHA_384:
|
||||
alg = "TPM_ALG_SHA_384";
|
||||
break;
|
||||
case TPM_ALG_SHA_512:
|
||||
alg = "TPM_ALG_SHA_512";
|
||||
break;
|
||||
case TPM_ALG_SHA3_256:
|
||||
alg = "TPM_ALG_SHA3_256";
|
||||
break;
|
||||
case TPM_ALG_SHA3_384:
|
||||
alg = "TPM_ALG_SHA3_384";
|
||||
break;
|
||||
case TPM_ALG_SHA3_512:
|
||||
alg = "TPM_ALG_SHA3_512";
|
||||
break;
|
||||
default:
|
||||
alg = "Unknown or invalid Hash";
|
||||
}
|
||||
String alg = switch (algId) {
|
||||
case TPM_ALG_RAW -> "Raw Bit Stream";
|
||||
case TPM_ALG_SHA_256 -> "TPM_ALG_SHA_256";
|
||||
case TPM_ALG_SHA_384 -> "TPM_ALG_SHA_384";
|
||||
case TPM_ALG_SHA_512 -> "TPM_ALG_SHA_512";
|
||||
case TPM_ALG_SHA3_256 -> "TPM_ALG_SHA3_256";
|
||||
case TPM_ALG_SHA3_384 -> "TPM_ALG_SHA3_384";
|
||||
case TPM_ALG_SHA3_512 -> "TPM_ALG_SHA3_512";
|
||||
default -> "Unknown or invalid Hash";
|
||||
};
|
||||
return alg;
|
||||
}
|
||||
|
||||
@ -86,26 +70,17 @@ public class SpdmHa {
|
||||
* @return size of the algorithm output
|
||||
*/
|
||||
public static int tcgAlgIdToByteSize(final int algId) {
|
||||
int byteSize;
|
||||
switch (algId) {
|
||||
final int byteSize256 = 32;
|
||||
final int byteSize384 = 48;
|
||||
final int byteSize512 = 64;
|
||||
|
||||
return switch (algId) {
|
||||
// case TPM_ALG_RAW: // add this when have more test data
|
||||
// byteSize = ;
|
||||
// break;
|
||||
case TPM_ALG_SHA_256:
|
||||
byteSize = 32;
|
||||
break;
|
||||
case TPM_ALG_SHA_384, TPM_ALG_SHA3_384:
|
||||
byteSize = 48;
|
||||
break;
|
||||
case TPM_ALG_SHA_512, TPM_ALG_SHA3_512:
|
||||
byteSize = 64;
|
||||
break;
|
||||
case TPM_ALG_SHA3_256:
|
||||
byteSize = 32;
|
||||
break;
|
||||
default:
|
||||
byteSize = -1;
|
||||
}
|
||||
return byteSize;
|
||||
// return ;
|
||||
case TPM_ALG_SHA_256, TPM_ALG_SHA3_256 -> byteSize256;
|
||||
case TPM_ALG_SHA_384, TPM_ALG_SHA3_384 -> byteSize384;
|
||||
case TPM_ALG_SHA_512, TPM_ALG_SHA3_512 -> byteSize512;
|
||||
default -> -1;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,61 @@ import lombok.Getter;
|
||||
*/
|
||||
public class SpdmMeasurement {
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_0 = Immutable ROM.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_0 = 0;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_1 = Mutable firmware.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_1 = 1;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_2 = Hardware configuration.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_2 = 2;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_3 = Firmware configuration.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_3 = 3;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_4 = Freeform measurement manifest.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_4 = 4;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_5 = Structured representation of debug and device mode.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_5 = 5;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_6 = Mutable firmware's version number.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_6 = 6;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_7 = Mutable firmware's security version number.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_7 = 7;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_8 = Hash-extended measurement.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_8 = 8;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_9 = Informational.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_9 = 9;
|
||||
|
||||
/**
|
||||
* MEASUREMENT_VALUE_10 = Structured measurement manifest.
|
||||
*/
|
||||
private static final int MEASUREMENT_VALUE_10 = 10;
|
||||
|
||||
/**
|
||||
* Measurement value (digest).
|
||||
*/
|
||||
@ -69,22 +124,20 @@ public class SpdmMeasurement {
|
||||
* @return a description of the measurement value type.
|
||||
*/
|
||||
public String dmtfSpecMeasurementValueTypeToString(final int measValType) {
|
||||
|
||||
String measValTypeStr = switch (measValType) {
|
||||
case 0 -> "Immutable ROM";
|
||||
case 1 -> "Mutable firmware";
|
||||
case 2 -> "Hardware configuration";
|
||||
case 3 -> "Firmware configuration";
|
||||
case 4 -> "Freeform measurement manifest";
|
||||
case 5 -> "Structured representation of debug and device mode";
|
||||
case 6 -> "Mutable firmware's version number";
|
||||
case 7 -> "Mutable firmware's security version number";
|
||||
case 8 -> "Hash-extended measurement";
|
||||
case 9 -> "Informational";
|
||||
case 10 -> "Structured measurement manifest";
|
||||
return switch (measValType) {
|
||||
case MEASUREMENT_VALUE_0 -> "Immutable ROM";
|
||||
case MEASUREMENT_VALUE_1 -> "Mutable firmware";
|
||||
case MEASUREMENT_VALUE_2 -> "Hardware configuration";
|
||||
case MEASUREMENT_VALUE_3 -> "Firmware configuration";
|
||||
case MEASUREMENT_VALUE_4 -> "Freeform measurement manifest";
|
||||
case MEASUREMENT_VALUE_5 -> "Structured representation of debug and device mode";
|
||||
case MEASUREMENT_VALUE_6 -> "Mutable firmware's version number";
|
||||
case MEASUREMENT_VALUE_7 -> "Mutable firmware's security version number";
|
||||
case MEASUREMENT_VALUE_8 -> "Hash-extended measurement";
|
||||
case MEASUREMENT_VALUE_9 -> "Informational";
|
||||
case MEASUREMENT_VALUE_10 -> "Structured measurement manifest";
|
||||
default -> "Unknown or invalid DMTF Spec Measurement Value Type";
|
||||
};
|
||||
return measValTypeStr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,6 +58,8 @@ public class TCGEventLogTest {
|
||||
NoSuchAlgorithmException {
|
||||
LOGGER.debug("Testing the parsing of a Crypto Agile formatted TCG Event Log");
|
||||
|
||||
|
||||
try {
|
||||
// setup
|
||||
final InputStream log = this.getClass().getResourceAsStream(DEFAULT_EVENT_LOG);
|
||||
final InputStream pcrs = this.getClass().getResourceAsStream(DEFAULT_EXPECTED_PCRS);
|
||||
@ -92,6 +94,9 @@ public class TCGEventLogTest {
|
||||
assertThat(TcgTpmtHa.TPM_ALG_SHA256, equalTo(id));
|
||||
|
||||
LOGGER.debug("OK. Parsing of a Crypto Agile Format Success");
|
||||
} catch (Throwable throwable) {
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,6 +111,7 @@ public class TCGEventLogTest {
|
||||
NoSuchAlgorithmException {
|
||||
LOGGER.debug("Testing the parsing of a SHA1 formated TCG Event Log");
|
||||
|
||||
try {
|
||||
// setup
|
||||
final InputStream log = this.getClass().getResourceAsStream(SHA1_EVENT_LOG);
|
||||
final InputStream pcrs = this.getClass().getResourceAsStream(SHA1_EXPECTED_PCRS);
|
||||
@ -139,5 +145,8 @@ public class TCGEventLogTest {
|
||||
assertThat(TcgTpmtHa.TPM_ALG_SHA1, equalTo(id));
|
||||
|
||||
LOGGER.debug("OK. Parsing of a SHA1 formatted TCG Event Log Success");
|
||||
} catch (Throwable throwable) {
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
build.gradle
14
build.gradle
@ -1,5 +1,4 @@
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.gradle.api.tasks.Copy
|
||||
|
||||
plugins {
|
||||
// Apply the application plugin to add support for building a CLI application in Java.
|
||||
@ -19,13 +18,12 @@ subprojects {
|
||||
|
||||
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
|
||||
reports {
|
||||
html {
|
||||
enabled = true
|
||||
}
|
||||
html.required = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
@ -36,10 +34,10 @@ dependencies {
|
||||
def projectVersion = rootProject.file('VERSION').text.trim()
|
||||
|
||||
def buildTime = { ->
|
||||
Date latestdate = new Date();
|
||||
def time = latestdate.getTime();
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time);
|
||||
return seconds;
|
||||
Date latestdate = new Date()
|
||||
def time = latestdate.getTime()
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(time)
|
||||
return seconds
|
||||
}
|
||||
|
||||
def gitHash = { ->
|
||||
|
Loading…
Reference in New Issue
Block a user