From e463c0cf76dc17d70da2ec617b2c2611a6623a9f Mon Sep 17 00:00:00 2001 From: iadgovuser58 <124906646+iadgovuser58@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:01:58 -0400 Subject: [PATCH] fixing NoAction event --- .../hirs/utils/tpm/eventlog/TpmPcrEvent.java | 45 ++++++++++--------- .../utils/tpm/eventlog/events/EvNoAction.java | 45 +++++++++---------- 2 files changed, 46 insertions(+), 44 deletions(-) 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 6226de2b..6a704724 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 @@ -6,7 +6,6 @@ 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.EvEfiSpdmDeviceSecurityEvent; -import hirs.utils.tpm.eventlog.events.EvEfiSpecIdEvent; import hirs.utils.tpm.eventlog.events.EvEventTag; import hirs.utils.tpm.eventlog.events.EvIPL; import hirs.utils.tpm.eventlog.events.EvNoAction; @@ -113,7 +112,6 @@ public class TpmPcrEvent { * Event hash for Crypto Agile events. */ private byte[] eventDataSha256hash; - private EvPostCode evPostCode; @Setter @Getter private int eventNumber; @Setter @Getter @@ -232,7 +230,7 @@ public class TpmPcrEvent { */ protected void setEventContent(final byte[] eventData) { eventContent = new byte[eventData.length]; - evPostCode = new EvPostCode(eventContent); + //EvPostCode evPostCode = new EvPostCode(eventContent); System.arraycopy(eventData, 0, eventContent, 0, eventData.length); } @@ -263,22 +261,25 @@ public class TpmPcrEvent { 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.getSpecIDEvent(); - specVersion = String.format("%s.%s", - specID.getVersionMajor(), - specID.getVersionMinor()); - specErrataVersion = specID.getErrata(); - } - } catch (UnsupportedEncodingException ueEx) { - log.error(ueEx); - sb.append(ueEx.toString()); +// EvNoAction noAction = null; +// try { +// noAction = new EvNoAction(eventContent); + EvNoAction noAction = new EvNoAction(eventContent); + sb.append(noAction.toString()); + if (noAction.isSpecIDEvent()) { +// // this should be in the constructor +// EvEfiSpecIdEvent specID = noAction.getSpecIDEvent(); +// specVersion = String.format("%s.%s", +// specID.getVersionMajor(), +// specID.getVersionMinor()); +// specErrataVersion = specID.getErrata(); + specVersion = noAction.getSpecVersion(); + specErrataVersion = noAction.getSpecErrataVersion(); } +// } catch (UnsupportedEncodingException ueEx) { +// log.error(ueEx); +// sb.append(ueEx.toString()); +// } break; case EvConstants.EV_SEPARATOR: if (EvPostCode.isAscii(eventContent) @@ -458,9 +459,11 @@ public class TpmPcrEvent { EvNoAction noAction = new EvNoAction(content); description += "Event Content:\n" + noAction.toString(); if (noAction.isSpecIDEvent()) { - EvEfiSpecIdEvent specID = noAction.getSpecIDEvent(); - specVersion = specID.getVersionMajor() + "." + specID.getVersionMinor(); - specErrataVersion = specID.getErrata(); +// EvEfiSpecIdEvent specID = noAction.getSpecIDEvent(); +// specVersion = specID.getVersionMajor() + "." + specID.getVersionMinor(); +// specErrataVersion = specID.getErrata(); + specVersion = noAction.getSpecVersion(); + specErrataVersion = noAction.getSpecErrataVersion(); } break; case EvConstants.EV_SEPARATOR: diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvNoAction.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvNoAction.java index 2f557abf..2e223bf7 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvNoAction.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/EvNoAction.java @@ -32,6 +32,16 @@ public class EvNoAction { * True of the event is a SpecIDEvent. */ private boolean bSpecIDEvent = false; + /** + * TCG Event Log spec version. + */ + @Getter + private String specVersion = "Unknown"; + /** + * TCG Event Log errata version. + */ + @Getter + private String specErrataVersion = "Unknown"; // /** // * EvEfiSpecIdEvent Object. // */ @@ -55,7 +65,8 @@ public class EvNoAction { * @param eventData byte array holding the event to process. * @throws java.io.UnsupportedEncodingException if input fails to parse. */ - public EvNoAction(final byte[] eventData) throws UnsupportedEncodingException { +// public EvNoAction(final byte[] eventData) throws UnsupportedEncodingException { + public EvNoAction(final byte[] eventData) { byte[] signatureBytes = new byte[UefiConstants.SIZE_15]; System.arraycopy(eventData, 0, signatureBytes, 0, UefiConstants.SIZE_15); signature = new String(signatureBytes, StandardCharsets.UTF_8); @@ -64,13 +75,20 @@ public class EvNoAction { EvEfiSpecIdEvent specIDEvent = new EvEfiSpecIdEvent(eventData); noActionInfo += specIDEventToString(specIDEvent).toString(); bSpecIDEvent = true; + specVersion = String.format("%s.%s", + specIDEvent.getVersionMajor(), + specIDEvent.getVersionMinor()); + specErrataVersion = specIDEvent.getErrata(); } else if (signature.contains("StartupLocality")) { noActionInfo += " Signature = StartupLocality: "; noActionInfo += "\n " + getLocality(eventData); - } - else if (signature.contains("NvIndexInstance")) { + } else if (signature.contains("NvIndexInstance")) { NvIndexInstanceEventLogData nvIndexInstanceEvent = new NvIndexInstanceEventLogData(eventData); noActionInfo += nvIndexInstanceEvent.toString(); + } else { + noActionInfo = "EV_NO_ACTION event named " + signature + + " encountered but support for processing it has not been" + + " added to this application.\n"; } } @@ -95,7 +113,7 @@ public class EvNoAction { specIdInfo += " Platform Profile Specification version = " + specIDEvent.getVersionMajor() + "." + specIDEvent.getVersionMinor() + " using errata version " + specIDEvent.getErrata(); - + return specIdInfo; } @@ -126,25 +144,6 @@ public class EvNoAction { * @return Human-readable description of this event. */ public String toString() { - String noActionInfo = ""; - if (bSpecIDEvent) { - noActionInfo += " Signature = Spec ID Event03 : "; - if (specIDEvent.isCryptoAgile()) { - noActionInfo += "Log format is Crypto Agile\n"; - } else { - noActionInfo += "Log format is SHA 1 (NOT Crypto Agile)\n"; - } - noActionInfo += " Platform Profile Specification version = " - + specIDEvent.getVersionMajor() + "." + specIDEvent.getVersionMinor() - + " using errata version " + specIDEvent.getErrata(); - } else if (b) { - noActionInfo = nvIndexInstanceEvent.toString(); - } else if (bNvIndexInstance) { - noActionInfo = nvIndexInstanceEvent.toString(); - } else { - noActionInfo = "EV_NO_ACTION event named " + signature - + " encountered but support for processing it has not been added to this application.\n"; - } return noActionInfo; } }