mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-18 20:47:58 +00:00
spdm initial output
This commit is contained in:
parent
49108ab144
commit
4547998384
Binary file not shown.
@ -63,26 +63,26 @@ public class DeviceSecurityEventData {
|
||||
*/
|
||||
@Getter
|
||||
private String version = "";
|
||||
/**
|
||||
* Contains the human-readable info inside the Device Security Event.
|
||||
*/
|
||||
@Getter
|
||||
private String dSEDinfo = "";
|
||||
// /**
|
||||
// * Contains the human-readable info inside the Device Security Event.
|
||||
// */
|
||||
// @Getter
|
||||
// private String dsedInfo = "";
|
||||
/**
|
||||
* DeviceSecurityEventDataHeader Object.
|
||||
*/
|
||||
@Getter
|
||||
private DeviceSecurityEventDataHeader dSEDheader = null;
|
||||
private DeviceSecurityEventDataHeader dsedHeader = null;
|
||||
/**
|
||||
* DeviceSecurityEventDataSubHeader Object.
|
||||
*/
|
||||
@Getter
|
||||
private DeviceSecurityEventDataHeader dSEDsubHeader = null;
|
||||
// @Getter
|
||||
// private DeviceSecurityEventDataSubHeader dsedSubHeader = null;
|
||||
/**
|
||||
* DeviceSecurityEventDataDeviceContext Object.
|
||||
*/
|
||||
@Getter
|
||||
private DeviceSecurityEventDataDeviceContext dSEDdeviceContext = null;
|
||||
private DeviceSecurityEventDataDeviceContext dsedDeviceContext = null;
|
||||
|
||||
/**
|
||||
* DeviceSecurityEventData Constructor.
|
||||
@ -95,56 +95,65 @@ public class DeviceSecurityEventData {
|
||||
System.arraycopy(dSEDbytes, 0, signatureBytes, 0, UefiConstants.SIZE_16);
|
||||
//signature = HexUtils.byteArrayToHexString(signatureBytes);
|
||||
signature = new String(signatureBytes, StandardCharsets.UTF_8)
|
||||
.substring(0, UefiConstants.SIZE_15);
|
||||
.substring(0, UefiConstants.SIZE_15); // size 15 bc last letter is a 00 (null)
|
||||
|
||||
byte[] versionBytes = new byte[UefiConstants.SIZE_4];
|
||||
byte[] versionBytes = new byte[UefiConstants.SIZE_2];
|
||||
System.arraycopy(dSEDbytes, UefiConstants.OFFSET_16, versionBytes, 0,
|
||||
UefiConstants.SIZE_4);
|
||||
UefiConstants.SIZE_2);
|
||||
version = HexUtils.byteArrayToHexString(versionBytes);
|
||||
|
||||
// int byteOffset = 0;
|
||||
// byteOffset = dsedHeader.getDsedHeaderByteSize();
|
||||
|
||||
// If version is 0x01, the event is a DEVICE_SECURITY_EVENT_DATA
|
||||
// If version is 0x02, the event is a DEVICE_SECURITY_EVENT_DATA2
|
||||
int byteOffset = 0;
|
||||
dSEDheader = new DeviceSecurityEventDataHeader(dSEDbytes);
|
||||
byteOffset = dSEDheader.getDSEDheaderByteSize();
|
||||
if (version == "2") {
|
||||
// dSEDsubHeader = new DeviceSecurityEventDataSubHeader(dSEDbytes,byteOffset);
|
||||
// byteOffset = dSEDheader.getDSEDsubHeaderByteSize();
|
||||
}
|
||||
dSEDdeviceContext = new DeviceSecurityEventDataDeviceContext(dSEDbytes, byteOffset);
|
||||
switch (version) {
|
||||
case "0100":
|
||||
dsedHeader = new DeviceSecurityEventDataHeader(dSEDbytes);
|
||||
// dsedDeviceContext = new DeviceSecurityEventDataDeviceContext(dSEDbytes,
|
||||
// dsedHeader.getDSEDheaderByteSize());
|
||||
break;
|
||||
case "0200":
|
||||
dsedHeader = new DeviceSecurityEventDataHeader(dSEDbytes);
|
||||
// dsedSubHeader = new DeviceSecurityEventDataSubHeader(dSEDbytes,byteOffset);
|
||||
// byteOffset = dsedHeader.getDSEDsubHeaderByteSize();
|
||||
// dsedDeviceContext = new DeviceSecurityEventDataDeviceContext(dSEDbytes, byteOffset);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
// if (version == "1") {
|
||||
// dSEDinfo =+
|
||||
// dSEDataHeader.getDSEDheaderInfo();
|
||||
// dSEDinfo =+
|
||||
// dSEDdeviceContext.getdSEDdeviceContextInfo();
|
||||
// dsedDeviceContext.getdSEDdeviceContextInfo();
|
||||
// } else if (version == "2") {
|
||||
// dSEDinfo =+
|
||||
// dSEDheader.getDSEDheaderInfo();
|
||||
// dSEDinfo =+
|
||||
// dSEDsubHeader.getDSEDsubHeaderInfo();
|
||||
// dsedSubHeader.getDSEDsubHeaderInfo();
|
||||
// dSEDinfo =+
|
||||
// dSEDdeviceContext.getDSEDdeviceContextInfo();
|
||||
// dsedDeviceContext.getDSEDdeviceContextInfo();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String specInfo = "";
|
||||
|
||||
specInfo += " Signature = SPDM Device Sec : ";
|
||||
// if (specIDEvent.isCryptoAgile()) {
|
||||
// specInfo += "Log format is Crypto Agile\n";
|
||||
// } else {
|
||||
// specInfo += "Log format is SHA 1 (NOT Crypto Agile)\n";
|
||||
// }
|
||||
// specInfo += " Platform Profile Specification version = "
|
||||
// + specIDEvent.getVersionMajor() + "." + specIDEvent.getVersionMinor()
|
||||
// + " using errata version " + specIDEvent.getErrata();
|
||||
// specInfo += DeviceSecurityEventData.toString();
|
||||
// } else {
|
||||
// specInfo = "EV_EFI_SPDM_FIRMWARE_BLOB event named " + signature
|
||||
// + " encountered but support for processing it has not been added to this application.\n";
|
||||
// }
|
||||
return specInfo;
|
||||
String dsedInfo = "";
|
||||
switch (version) {
|
||||
case "0100":
|
||||
dsedInfo += dsedHeader.toString();
|
||||
// dsedInfo += dsedDeviceContext.toString();
|
||||
break;
|
||||
case "0200":
|
||||
// dsedInfo += dsedHeader.toString();
|
||||
// dsedInfo += dsedSubHeader.toString();
|
||||
// dsedInfo += dsedDeviceContext.toString();
|
||||
break;
|
||||
default:
|
||||
dsedInfo += " Unknown SPDM Device Security Event Data version " + version + " found" + "\n";
|
||||
}
|
||||
return dsedInfo;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
* UNIT8 DevicePath[DevicePathLength]
|
||||
* } DEVICE_SECURITY_EVENT_DATA_HEADER;
|
||||
* <p>
|
||||
* typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER2 {
|
||||
* typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER2 { - NOT IMPLEMENTED YET
|
||||
* UINT8 Signature[16];
|
||||
* UINT16 Version;
|
||||
* UINT8 AuthState;
|
||||
@ -73,11 +73,14 @@ import java.util.List;
|
||||
*/
|
||||
public class DeviceSecurityEventDataHeader {
|
||||
|
||||
/**
|
||||
* Contains the human-readable info inside the Device Security Event.
|
||||
// /**
|
||||
// * Contains the human-readable info inside the Device Security Event.
|
||||
// */
|
||||
// @Getter
|
||||
// private String dSEDheaderInfo = "";
|
||||
|
||||
/** ----------- Variables common to all Header Types -----------
|
||||
*/
|
||||
@Getter
|
||||
private String dSEDheaderInfo = "";
|
||||
/**
|
||||
* Contains the size (in bytes) of the Header.
|
||||
*/
|
||||
@ -94,21 +97,42 @@ public class DeviceSecurityEventDataHeader {
|
||||
*/
|
||||
@Getter
|
||||
private String version = "";
|
||||
/**
|
||||
* Event data length.
|
||||
*/
|
||||
@Getter
|
||||
private String length = "";
|
||||
/**
|
||||
* SPDM hash algorithm.
|
||||
*/
|
||||
@Getter
|
||||
private String spdmHashAlgo = "";
|
||||
/**
|
||||
* Device type.
|
||||
*/
|
||||
@Getter
|
||||
private String deviceType = "";
|
||||
/**
|
||||
* Device path length.
|
||||
*/
|
||||
@Getter
|
||||
private String devicePathLength = "";
|
||||
/**
|
||||
* Device path.
|
||||
*/
|
||||
@Getter
|
||||
private String devicePath = "";
|
||||
|
||||
/** ----------- Variables specific to Header Type 1 -----------
|
||||
/**
|
||||
* Type Header 1 event data length.
|
||||
*/
|
||||
@Getter
|
||||
private String h1Length = "";
|
||||
/**
|
||||
* Type Header 1 SPDM hash algorithm.
|
||||
*/
|
||||
@Getter
|
||||
private String h1SpdmHashAlgo = "";
|
||||
/**
|
||||
* Type Header 1 SPDM measurement block.
|
||||
*/
|
||||
@Getter
|
||||
private String h1SpdmMeasurementBlock = "";
|
||||
|
||||
/** ----------- Variables specific to Header Type 2 -----------
|
||||
*/
|
||||
// TBD
|
||||
|
||||
/**
|
||||
* DeviceSecurityEventDataHeader Constructor.
|
||||
@ -123,33 +147,26 @@ public class DeviceSecurityEventDataHeader {
|
||||
signature = new String(signatureBytes, StandardCharsets.UTF_8)
|
||||
.substring(0, UefiConstants.SIZE_15);
|
||||
|
||||
byte[] versionBytes = new byte[UefiConstants.SIZE_4];
|
||||
byte[] versionBytes = new byte[UefiConstants.SIZE_2];
|
||||
System.arraycopy(dSEDbytes, UefiConstants.OFFSET_16, versionBytes, 0,
|
||||
UefiConstants.SIZE_4);
|
||||
UefiConstants.SIZE_2);
|
||||
version = HexUtils.byteArrayToHexString(versionBytes);
|
||||
|
||||
byte[] lengthBytes = new byte[UefiConstants.SIZE_4];
|
||||
System.arraycopy(dSEDbytes, UefiConstants.OFFSET_20, lengthBytes, 0,
|
||||
UefiConstants.SIZE_4);
|
||||
length = HexUtils.byteArrayToHexString(lengthBytes);
|
||||
byte[] lengthBytes = new byte[UefiConstants.SIZE_2];
|
||||
System.arraycopy(dSEDbytes, 18, lengthBytes, 0,
|
||||
UefiConstants.SIZE_2);
|
||||
h1Length = HexUtils.byteArrayToHexString(lengthBytes);
|
||||
|
||||
byte[] spdmHashAlgoBytes = new byte[UefiConstants.SIZE_8];
|
||||
System.arraycopy(dSEDbytes, UefiConstants.OFFSET_24, spdmHashAlgoBytes, 0,
|
||||
byte[] spdmHashAlgoBytes = new byte[UefiConstants.SIZE_4];
|
||||
System.arraycopy(dSEDbytes, UefiConstants.OFFSET_20, spdmHashAlgoBytes, 0,
|
||||
UefiConstants.SIZE_4);
|
||||
spdmHashAlgo = HexUtils.byteArrayToHexString(spdmHashAlgoBytes);
|
||||
h1SpdmHashAlgo = HexUtils.byteArrayToHexString(spdmHashAlgoBytes);
|
||||
|
||||
byte[] deviceTypeBytes = new byte[UefiConstants.SIZE_8];
|
||||
byte[] deviceTypeBytes = new byte[UefiConstants.SIZE_4];
|
||||
System.arraycopy(dSEDbytes, UefiConstants.OFFSET_24, deviceTypeBytes, 0,
|
||||
UefiConstants.SIZE_4);
|
||||
deviceType = HexUtils.byteArrayToHexString(deviceTypeBytes);
|
||||
|
||||
// byte[] specVersionMajorBytes = new byte[1];
|
||||
// System.arraycopy(efiSpecId, UefiConstants.OFFSET_21, specVersionMajorBytes, 0, 1);
|
||||
// versionMajor = HexUtils.byteArrayToHexString(specVersionMajorBytes);
|
||||
//
|
||||
// byte[] specErrataBytes = new byte[1];
|
||||
// System.arraycopy(efiSpecId, UefiConstants.OFFSET_22, specErrataBytes, 0, 1);
|
||||
// errata = HexUtils.byteArrayToHexString(specErrataBytes);
|
||||
//
|
||||
// byte[] numberOfAlgBytes = new byte[UefiConstants.SIZE_4];
|
||||
// System.arraycopy(efiSpecId, UefiConstants.OFFSET_24, numberOfAlgBytes, 0,
|
||||
@ -170,23 +187,24 @@ public class DeviceSecurityEventDataHeader {
|
||||
// cryptoAgile = true;
|
||||
// }
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * Returns a human readable description of the data within this event.
|
||||
// *
|
||||
// * @return a description of this event..
|
||||
// */
|
||||
// public String toString() {
|
||||
// String specInfo = "";
|
||||
// if (signature.equals("Spec ID Event#")) {
|
||||
// specInfo += "Platform Profile Specification version = " + versionMajor + "." + versionMinor
|
||||
// + " using errata version" + errata;
|
||||
// } else {
|
||||
// specInfo = "EV_NO_ACTION event named " + signature
|
||||
// + " encountered but support for processing it has not been added to this application";
|
||||
// }
|
||||
// return specInfo;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Returns a human readable description of the data within this event.
|
||||
*
|
||||
* @return a description of this event..
|
||||
*/
|
||||
public String toString() {
|
||||
String dsedHeaderInfo = "";
|
||||
if (version.equals("0100")) {
|
||||
dsedHeaderInfo += "\n SPDM hash algorithm = " + h1SpdmHashAlgo;
|
||||
dsedHeaderInfo += "\n SPDM Device";
|
||||
dsedHeaderInfo += "\n Device Type: " + deviceType;
|
||||
dsedHeaderInfo += "\n Device Path: " + devicePath;
|
||||
dsedHeaderInfo += "\n SPDM Measurement Block " + h1SpdmMeasurementBlock;
|
||||
} else if(version.equals("0200")) {
|
||||
dsedHeaderInfo = "tbd";
|
||||
}
|
||||
return dsedHeaderInfo;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,22 +80,14 @@ public class EvEfiSpdmFirmwareBlob {
|
||||
* @return Human readable description of this event.
|
||||
*/
|
||||
public String toString() {
|
||||
String specInfo = "";
|
||||
String spdmInfo = "";
|
||||
if (bDeviceSecurityEventData) {
|
||||
specInfo += " Signature = SPDM Device Sec : ";
|
||||
// if (specIDEvent.isCryptoAgile()) {
|
||||
// specInfo += "Log format is Crypto Agile\n";
|
||||
// } else {
|
||||
// specInfo += "Log format is SHA 1 (NOT Crypto Agile)\n";
|
||||
// }
|
||||
// specInfo += " Platform Profile Specification version = "
|
||||
// + specIDEvent.getVersionMajor() + "." + specIDEvent.getVersionMinor()
|
||||
// + " using errata version " + specIDEvent.getErrata();
|
||||
// specInfo += DeviceSecurityEventData.toString();
|
||||
spdmInfo += " Signature = SPDM Device Sec";
|
||||
spdmInfo += deviceSecurityEventData.toString();
|
||||
} else {
|
||||
specInfo = "EV_EFI_SPDM_FIRMWARE_BLOB event named " + signature
|
||||
spdmInfo = "EV_EFI_SPDM_FIRMWARE_BLOB event named " + signature
|
||||
+ " encountered but support for processing it has not been added to this application.\n";
|
||||
}
|
||||
return specInfo;
|
||||
return spdmInfo;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package hirs.utils.tpm.eventlog.spdm;
|
||||
|
||||
public class SpdmMeasurement {
|
||||
|
||||
public SpdmMeasurement(final byte[] spdmMeasBytes) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return "TEMP TEST SpdmMeasurement";
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package hirs.utils.tpm.eventlog.spdm;
|
||||
|
||||
public class SpdmMeasurementBlock {
|
||||
|
||||
public SpdmMeasurementBlock(final byte[] spdmMeasBlockBytes) {
|
||||
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "TEMP TEST spdmMeasBlockBytes";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user