Changed up some of the encoded for the rim byte array

This commit is contained in:
Cyrus 2021-05-25 13:11:57 -04:00
parent efa2cada2d
commit 8fbd6e1a39
3 changed files with 9 additions and 7 deletions

View File

@ -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();

View File

@ -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;
}

View File

@ -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));
}
}