diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java index 63527556..fbb73305 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java @@ -94,6 +94,7 @@ import java.security.interfaces.RSAPublicKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.MGF1ParameterSpec; import java.security.spec.RSAPublicKeySpec; +import java.util.Base64; import java.util.Calendar; import java.util.Date; import java.util.HashSet; @@ -788,7 +789,7 @@ public abstract class AbstractAttestationCertificateAuthority try { support = SupportReferenceManifest.select(referenceManifestManager) .includeArchived() - .byHashCode(Hex.encodeHexString(messageDigest.digest( + .byHashCode(Base64.getEncoder().encodeToString(messageDigest.digest( logFile.toByteArray()))) .getRIM(); if (support == null) { @@ -830,7 +831,7 @@ public abstract class AbstractAttestationCertificateAuthority try { dbBaseRim = BaseReferenceManifest.select(referenceManifestManager) .includeArchived() - .byHashCode(Hex.encodeHexString(messageDigest.digest( + .byHashCode(Base64.getEncoder().encodeToString(messageDigest.digest( swidFile.toByteArray()))) .getRIM(); if (dbBaseRim == null) { @@ -864,7 +865,7 @@ public abstract class AbstractAttestationCertificateAuthority for (ByteString swidFile : dv.getSwidfileList()) { dbBaseRim = BaseReferenceManifest.select(referenceManifestManager) .includeArchived() - .byHashCode(Hex.encodeHexString(messageDigest.digest( + .byHashCode(Base64.getEncoder().encodeToString(messageDigest.digest( swidFile.toByteArray()))) .getRIM(); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java index 691d1703..a30ded72 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java @@ -413,7 +413,8 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe for (SwidResource swidRes : resources) { supportReferenceManifest = SupportReferenceManifest.select(referenceManifestManager) .byRimHash(swidRes.getHashValue()).getRIM(); - if (swidRes.getName().equals(supportReferenceManifest.getFileName())) { + if (supportReferenceManifest !=null + && swidRes.getName().equals(supportReferenceManifest.getFileName())) { referenceManifestValidator.validateSupportRimHash( supportReferenceManifest.getRimBytes(), swidRes.getHashValue()); } else { @@ -422,7 +423,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe } if (supportReferenceManifest == null) { fwStatus = new AppraisalStatus(FAIL, - "Support Reference Integrity Manifest\n"); + "Support Reference Integrity Manifest can not be found\n"); passed = false; } diff --git a/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceManifest.java b/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceManifest.java index 2368a88c..4e78e0cf 100644 --- a/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceManifest.java +++ b/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceManifest.java @@ -2,7 +2,6 @@ package hirs.data.persist; import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.base.Preconditions; -import org.apache.commons.codec.binary.Hex; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.hibernate.annotations.Type; @@ -19,6 +18,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; +import java.util.Base64; import java.util.UUID; /** @@ -139,7 +139,7 @@ public abstract class ReferenceManifest extends ArchivableEntity { if (digest == null) { this.rimHash = ""; } else { - this.rimHash = Hex.encodeHexString( + this.rimHash = Base64.getEncoder().encodeToString( digest.digest(rimBytes)); } }