From c6e5dd125c82ad98f34ab3c57377dc6bab68f360 Mon Sep 17 00:00:00 2001 From: iadgovuser58 <124906646+iadgovuser58@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:28:30 -0400 Subject: [PATCH] combined SPDM_FIRMWARE_BLOB and SPDM_FIRMWARE_CONFIG as they have the same internal data structure --- .../hirs/utils/tpm/eventlog/TpmPcrEvent.java | 12 +++--- .../events/EvEfiSpdmDevicePolicy.java | 14 +++++++ ...java => EvEfiSpdmDeviceSecurityEvent.java} | 37 ++++++++++--------- 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmDevicePolicy.java rename HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/{EvEfiSpdmFirmwareBlob.java => EvEfiSpdmDeviceSecurityEvent.java} (78%) diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/TpmPcrEvent.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/TpmPcrEvent.java index 9858cdee..f28b655f 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/TpmPcrEvent.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/TpmPcrEvent.java @@ -5,7 +5,8 @@ import hirs.utils.tpm.eventlog.events.EvCompactHash; import hirs.utils.tpm.eventlog.events.EvConstants; import hirs.utils.tpm.eventlog.events.EvEfiGptPartition; import hirs.utils.tpm.eventlog.events.EvEfiHandoffTable; -import hirs.utils.tpm.eventlog.events.EvEfiSpdmFirmwareBlob; +import hirs.utils.tpm.eventlog.events.EvEfiSpdmDevicePolicy; +import hirs.utils.tpm.eventlog.events.EvEfiSpdmDeviceSecurityEvent; import hirs.utils.tpm.eventlog.events.EvEfiSpecIdEvent; import hirs.utils.tpm.eventlog.events.EvEventTag; import hirs.utils.tpm.eventlog.events.EvIPL; @@ -388,15 +389,14 @@ public class TpmPcrEvent { case EvConstants.EV_EFI_HCRTM_EVENT: break; case EvConstants.EV_EFI_SPDM_FIRMWARE_BLOB: + case EvConstants.EV_EFI_SPDM_FIRMWARE_CONFIG: try { - sb.append(new EvEfiSpdmFirmwareBlob(eventContent).toString()); + sb.append(new EvEfiSpdmDeviceSecurityEvent(eventContent).toString()); } catch (UnsupportedEncodingException ueEx) { log.error(ueEx); sb.append(ueEx.toString()); } break; - case EvConstants.EV_EFI_SPDM_FIRMWARE_CONFIG: - break; case EvConstants.EV_EFI_SPDM_DEVICE_POLICY: break; default: @@ -563,10 +563,10 @@ public class TpmPcrEvent { vendorTableFileStatus = efiVarAuth.getVendorTableFileStatus(); break; case EvConstants.EV_EFI_SPDM_FIRMWARE_BLOB: - description += "Event Content:\n" + new EvEfiSpdmFirmwareBlob(content).toString(); + description += "Event Content:\n" + new EvEfiSpdmDeviceSecurityEvent(content).toString(); break; case EvConstants.EV_EFI_SPDM_FIRMWARE_CONFIG: - description += "Event Content:\n" + new EvEfiSpdmFirmwareConfig(content).toString(); + description += "Event Content:\n" + new EvEfiSpdmDeviceSecurityEvent(content).toString(); break; case EvConstants.EV_EFI_SPDM_DEVICE_POLICY: description += "Event Content:\n" + new EvEfiSpdmDevicePolicy(content).toString(); diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmDevicePolicy.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmDevicePolicy.java new file mode 100644 index 00000000..7f6eb4b9 --- /dev/null +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmDevicePolicy.java @@ -0,0 +1,14 @@ +package hirs.utils.tpm.eventlog.events; + +public class EvEfiSpdmDevicePolicy { + + + /** + * EvEfiSpdmDevicePolicy constructor. + * + * @param eventData byte array holding the event to process. + */ + public EvEfiSpdmDevicePolicy(final byte[] eventData) { + } + +} diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmFirmwareBlob.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmDeviceSecurityEvent.java similarity index 78% rename from HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmFirmwareBlob.java rename to HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmDeviceSecurityEvent.java index f371d213..cfdcdd20 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmFirmwareBlob.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvEfiSpdmDeviceSecurityEvent.java @@ -7,7 +7,8 @@ import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; /** - * Class to process the EV_EFI_SPDM_FIRMWARE_BLOB event. The event field MUST be a + * Abstract class to process any SPDM event that is solely a DEVICE_SECURITY_EVENT_DATA or + * DEVICE_SECURITY_EVENT_DATA2. The event field MUST be a * 1) DEVICE_SECURITY_EVENT_DATA or * 2) DEVICE_SECURITY_EVENT_DATA2 * DEVICE_SECURITY_EVENT_DATA has 2 structures: @@ -28,7 +29,7 @@ import java.nio.charset.StandardCharsets; * firmware, such as immutable ROM, mutable firmware, firmware version, firmware secure version * number, etc. */ -public class EvEfiSpdmFirmwareBlob { +public class EvEfiSpdmDeviceSecurityEvent { /** * Signature (text) data. @@ -49,7 +50,7 @@ public class EvEfiSpdmFirmwareBlob { * @param eventData byte array holding the event to process. * @throws java.io.UnsupportedEncodingException if input fails to parse. */ - public EvEfiSpdmFirmwareBlob(final byte[] eventData) throws UnsupportedEncodingException { + public EvEfiSpdmDeviceSecurityEvent(final byte[] eventData) throws UnsupportedEncodingException { byte[] signatureBytes = new byte[UefiConstants.SIZE_15]; System.arraycopy(eventData, 0, signatureBytes, 0, UefiConstants.SIZE_15); @@ -78,14 +79,14 @@ public class EvEfiSpdmFirmwareBlob { } } - /** - * Determines if this event is a DeviceSecurityEventData. - * - * @return true of the event is a DeviceSecurityEventData. - */ - public boolean isSpdmDeviceSecurityEventData() { - return bSpdmDeviceSecurityEventData; - } +// /** +// * Determines if this event is a DeviceSecurityEventData. +// * +// * @return true of the event is a DeviceSecurityEventData. +// */ +// public boolean isSpdmDeviceSecurityEventData() { +// return bSpdmDeviceSecurityEventData; +// } /** * Returns a description of this event. @@ -93,12 +94,14 @@ public class EvEfiSpdmFirmwareBlob { * @return Human readable description of this event. */ public String toString() { - if (bSpdmDeviceSecurityEventData) { - spdmInfo = " Signature = SPDM Device Sec" + spdmInfo; - } else { - spdmInfo = "EV_EFI_SPDM_FIRMWARE_BLOB event named " + signature - + " encountered but support for processing it has not been added to this application.\n"; - } + + spdmInfo = " Signature = SPDM Device Sec" + spdmInfo; +// if (bSpdmDeviceSecurityEventData) { +// spdmInfo = " Signature = SPDM Device Sec" + spdmInfo; +// } else { +// spdmInfo = "EV_EFI_SPDM_FIRMWARE_BLOB event named " + signature +// + " encountered but support for processing it has not been added to this application.\n"; +// } return spdmInfo; } }