From 96354113a5e78a7804e155d364a2d59e9bfeb69c Mon Sep 17 00:00:00 2001 From: iadgovuser26 <33069955+iadgovuser26@users.noreply.github.com> Date: Tue, 2 Aug 2022 13:52:22 -0400 Subject: [PATCH] addessed checkstyle errors --- .../src/main/java/hirs/tpm/eventlog/TpmPcrEvent.java | 12 +++++++----- .../main/java/hirs/tpm/eventlog/TpmPcrEvent1.java | 2 +- .../main/java/hirs/tpm/eventlog/TpmPcrEvent2.java | 3 +-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent.java b/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent.java index aa9bef41..ca798b0a 100644 --- a/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent.java +++ b/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent.java @@ -121,9 +121,10 @@ public class TpmPcrEvent { * This can be SHA1 for older event structures or any algorithm for newer structure. * * @param digestData cryptographic hash + * @param digestLength length of the cryptographic hash */ protected void setEventDigest(final byte[] digestData, final int digestLength) { - digest = new byte[digestLength]; + digest = new byte[digestLength]; System.arraycopy(digestData, 0, digest, 0, digestLength); } @@ -138,7 +139,7 @@ public class TpmPcrEvent { System.arraycopy(digest, 0, digestCopy, 0, this.digestLength); return digestCopy; } - + /** * Returns a hex representation of the event digest. * @return hex string @@ -469,6 +470,7 @@ public class TpmPcrEvent { * @param event the byte array holding the event data. * @param eventContent the byte array holding the event content. * @param eventNumber event position within the event log. + * @param hashName name of the hash algorithm used by the event log * @return String description of the event. * @throws CertificateException if the event contains an event that cannot be processed. * @throws NoSuchAlgorithmException if an event contains an unsupported algorithm. @@ -485,11 +487,11 @@ public class TpmPcrEvent { description += "\n"; if (hashName.compareToIgnoreCase("TPM_ALG_SHA1") == 0) { // Digest description += "digest (SHA-1): " + Hex.encodeHexString(this.digest); - } else if (hashName.compareToIgnoreCase("TPM_ALG_SHA256") == 0) { // Digest + } else if (hashName.compareToIgnoreCase("TPM_ALG_SHA256") == 0) { // Digest description += "digest (SHA256): " + Hex.encodeHexString(this.digest); - } else if (hashName.compareToIgnoreCase("TPM_ALG_SHA384") == 0) { // Digest + } else if (hashName.compareToIgnoreCase("TPM_ALG_SHA384") == 0) { // Digest description += "digest (SHA384): " + Hex.encodeHexString(this.digest); - } else if (hashName.compareToIgnoreCase("TPM_ALG_SHA512") == 0) { // Digest + } else if (hashName.compareToIgnoreCase("TPM_ALG_SHA512") == 0) { // Digest description += "digest (SHA512): " + Hex.encodeHexString(this.digest); } else { description += "Unsupported Hash Algorithm encoutered"; diff --git a/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent1.java b/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent1.java index ef49a521..c9057a91 100644 --- a/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent1.java +++ b/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent1.java @@ -49,7 +49,7 @@ public class TpmPcrEvent1 extends TpmPcrEvent { byte[] rawEventSize = new byte[UefiConstants.SIZE_4]; byte[] eventDigest = new byte[EvConstants.SHA1_LENGTH]; byte[] eventContent = null; - int digestSize= EvConstants.SHA1_LENGTH; + int digestSize = EvConstants.SHA1_LENGTH; int eventSize = 0; String hashName = "TPM_ALG_SHA1"; if (is.available() > UefiConstants.SIZE_32) { diff --git a/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent2.java b/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent2.java index fe58a26d..a1b6ef1e 100644 --- a/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent2.java +++ b/HIRS_Utils/src/main/java/hirs/tpm/eventlog/TpmPcrEvent2.java @@ -104,9 +104,8 @@ public class TpmPcrEvent2 extends TpmPcrEvent { hashName = hashAlg.getHashName(); hashlist.add(hashAlg); eventDigest = new byte[hashAlg.getHashLength()]; - setEventDigest(hashAlg.getDigest(),hashAlg.getHashLength()); + setEventDigest(hashAlg.getDigest(), hashAlg.getHashLength()); } - is.read(rawEventSize); eventSize = HexUtils.leReverseInt(rawEventSize); eventContent = new byte[eventSize];