cleaning up

This commit is contained in:
iadgovuser58 2024-08-07 11:15:22 -04:00
parent 042a830a6e
commit 6124e63201
22 changed files with 108 additions and 138 deletions

View File

@ -318,12 +318,8 @@ public class TpmPcrEvent {
case EvConstants.EV_EFI_EVENT_BASE: case EvConstants.EV_EFI_EVENT_BASE:
break; break;
case EvConstants.EV_EFI_VARIABLE_DRIVER_CONFIG: case EvConstants.EV_EFI_VARIABLE_DRIVER_CONFIG:
UefiVariable efiVar = null;
try { try {
efiVar = new UefiVariable(eventContent); sb.append(new UefiVariable(eventContent).toString());
String efiVarDescription = efiVar.toString().replace("\n", "\n ");
sb.append(efiVarDescription.substring(0,
efiVarDescription.length() - INDENT_3));
} catch (CertificateException cEx) { } catch (CertificateException cEx) {
log.error(cEx); log.error(cEx);
sb.append(cEx.toString()); sb.append(cEx.toString());
@ -508,9 +504,7 @@ public class TpmPcrEvent {
break; break;
case EvConstants.EV_EFI_VARIABLE_DRIVER_CONFIG: case EvConstants.EV_EFI_VARIABLE_DRIVER_CONFIG:
UefiVariable efiVar = new UefiVariable(content); UefiVariable efiVar = new UefiVariable(content);
String efiVarDescription = efiVar.toString().replace("\n", "\n "); description += "Event Content:\n" + efiVar.toString();
description += "Event Content:\n " + efiVarDescription.substring(0,
efiVarDescription.length() - INDENT_3);
vendorTableFileStatus = efiVar.getVendorTableFileStatus(); vendorTableFileStatus = efiVar.getVendorTableFileStatus();
break; break;
case EvConstants.EV_EFI_VARIABLE_BOOT: case EvConstants.EV_EFI_VARIABLE_BOOT:

View File

@ -2,9 +2,6 @@ package hirs.utils.tpm.eventlog.events;
import lombok.Getter; import lombok.Getter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
/** /**
* Class to process DEVICE_SECURITY_EVENT_DATA. * Class to process DEVICE_SECURITY_EVENT_DATA.
* Parses event data per PFP v1.06 Rev52 Table 20. * Parses event data per PFP v1.06 Rev52 Table 20.

View File

@ -2,8 +2,6 @@ package hirs.utils.tpm.eventlog.events;
import lombok.Getter; import lombok.Getter;
import java.io.UnsupportedEncodingException;
/** /**
* Class to process DEVICE_SECURITY_EVENT_DATA2. * Class to process DEVICE_SECURITY_EVENT_DATA2.
* Parses event data per PFP v1.06 Rev52 Table 26. * Parses event data per PFP v1.06 Rev52 Table 26.

View File

@ -69,6 +69,5 @@ public abstract class DeviceSecurityEventDataDeviceContext {
return dSEDdeviceContextCommonInfo; return dSEDdeviceContextCommonInfo;
} }
} }

View File

@ -7,7 +7,7 @@ import hirs.utils.tpm.eventlog.uefi.UefiConstants;
import lombok.Getter; import lombok.Getter;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException; import java.io.IOException;
/** /**
* Class to process the DEVICE_SECURITY_EVENT_DATA_HEADER. * Class to process the DEVICE_SECURITY_EVENT_DATA_HEADER.
@ -89,8 +89,12 @@ public class DeviceSecurityEventDataHeader extends DeviceSecurityEventHeader {
ByteArrayInputStream spdmMeasurementBlockData = ByteArrayInputStream spdmMeasurementBlockData =
new ByteArrayInputStream(spdmMeasBlockBytes); new ByteArrayInputStream(spdmMeasBlockBytes);
spdmMeasurementBlock = new SpdmMeasurementBlock(spdmMeasurementBlockData); try {
spdmMeasurementBlockInfo = spdmMeasurementBlock.toString(); spdmMeasurementBlock = new SpdmMeasurementBlock(spdmMeasurementBlockData);
spdmMeasurementBlockInfo = spdmMeasurementBlock.toString();
} catch (IOException e) {
spdmMeasurementBlockInfo = " Error reading SPDM Measurement Block";
}
int devPathLenStartByte = 28 + sizeOfSpdmMeasBlock; int devPathLenStartByte = 28 + sizeOfSpdmMeasBlock;
extractDevicePathAndFinalSize(dsedBytes, devPathLenStartByte); extractDevicePathAndFinalSize(dsedBytes, devPathLenStartByte);

View File

@ -3,8 +3,6 @@ package hirs.utils.tpm.eventlog.events;
import hirs.utils.HexUtils; import hirs.utils.HexUtils;
import lombok.Getter; import lombok.Getter;
import java.io.UnsupportedEncodingException;
/** /**
* Class to process the DEVICE_SECURITY_EVENT_DATA_HEADER2. * Class to process the DEVICE_SECURITY_EVENT_DATA_HEADER2.
* DEVICE_SECURITY_EVENT_DATA_HEADER2 contains the measurement(s) and hash algorithm identifier * DEVICE_SECURITY_EVENT_DATA_HEADER2 contains the measurement(s) and hash algorithm identifier
@ -84,6 +82,11 @@ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader {
*/ */
public static final int AUTH_NO_SPDM = 0xFF; public static final int AUTH_NO_SPDM = 0xFF;
/**
* DeviceSecurityEventDataHeader2 Constructor.
*
* @param dsedBytes byte array holding the DeviceSecurityEventData2.
*/
public DeviceSecurityEventDataHeader2(final byte[] dsedBytes) { public DeviceSecurityEventDataHeader2(final byte[] dsedBytes) {
super(dsedBytes); super(dsedBytes);
@ -130,6 +133,11 @@ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader {
return dsedHeader2Info; return dsedHeader2Info;
} }
/**
* Returns a human-readable description of auth state based on numeric representation lookup.
*
* @return a description of the auth state.
*/
public String getAuthStateString() { public String getAuthStateString() {
switch (authState) { switch (authState) {

View File

@ -3,7 +3,6 @@ package hirs.utils.tpm.eventlog.events;
import hirs.utils.HexUtils; import hirs.utils.HexUtils;
import lombok.Getter; import lombok.Getter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static hirs.utils.PciIds.translateDevice; import static hirs.utils.PciIds.translateDevice;
@ -102,7 +101,6 @@ public class DeviceSecurityEventDataPciContext extends DeviceSecurityEventDataDe
byte[] pciSubsystemIdBytes = new byte[2]; byte[] pciSubsystemIdBytes = new byte[2];
System.arraycopy(dSEDpciContextBytes, 14, pciSubsystemIdBytes, 0, 2); System.arraycopy(dSEDpciContextBytes, 14, pciSubsystemIdBytes, 0, 2);
subsystemId = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciSubsystemIdBytes)); subsystemId = HexUtils.byteArrayToHexString(HexUtils.leReverseByte(pciSubsystemIdBytes));
} }
/** /**

View File

@ -1,6 +1,5 @@
package hirs.utils.tpm.eventlog.events; package hirs.utils.tpm.eventlog.events;
/** /**
* Class to process the DEVICE_SECURITY_EVENT_DATA_SUB_HEADER event per PFP. * Class to process the DEVICE_SECURITY_EVENT_DATA_SUB_HEADER event per PFP.
* *
@ -23,6 +22,10 @@ public abstract class DeviceSecurityEventDataSubHeader {
*/ */
public static final int SUBHEADERTYPE_CERT_CHAIN = 1; public static final int SUBHEADERTYPE_CERT_CHAIN = 1;
/**
* DeviceSecurityEventDataSubHeader Default Constructor.
*
*/
public DeviceSecurityEventDataSubHeader() { public DeviceSecurityEventDataSubHeader() {
} }

View File

@ -3,10 +3,6 @@ package hirs.utils.tpm.eventlog.events;
import hirs.utils.HexUtils; import hirs.utils.HexUtils;
import hirs.utils.tpm.eventlog.spdm.SpdmCertificateChain; import hirs.utils.tpm.eventlog.spdm.SpdmCertificateChain;
import hirs.utils.tpm.eventlog.spdm.SpdmHa; import hirs.utils.tpm.eventlog.spdm.SpdmHa;
import lombok.Getter;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
/** /**
* Class to process the DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN event per PFP. * Class to process the DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN event per PFP.
@ -85,7 +81,6 @@ public class DeviceSecurityEventDataSubHeaderCertChain extends DeviceSecurityEve
else { else {
spdmBaseHashAlgoError += "SPDM base hash algorithm size is not >0"; spdmBaseHashAlgoError += "SPDM base hash algorithm size is not >0";
} }
} }
/** /**

View File

@ -6,6 +6,7 @@ import hirs.utils.tpm.eventlog.spdm.SpdmMeasurementBlock;
import lombok.Getter; import lombok.Getter;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -52,6 +53,10 @@ public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends Device
* List of SPDM Measurement Blocks. * List of SPDM Measurement Blocks.
*/ */
private List<SpdmMeasurementBlock> spdmMeasurementBlockList; private List<SpdmMeasurementBlock> spdmMeasurementBlockList;
/**
* Error reading SPDM Measurement Block.
*/
private boolean spdmMeasurementBlockReadError = false;
/** /**
* DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock Constructor. * DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock Constructor.
@ -87,9 +92,14 @@ public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends Device
ByteArrayInputStream spdmMeasurementBlockListData = ByteArrayInputStream spdmMeasurementBlockListData =
new ByteArrayInputStream(spdmMeasurementBlockListBytes); new ByteArrayInputStream(spdmMeasurementBlockListBytes);
while (spdmMeasurementBlockListData.available() > 0) { while (spdmMeasurementBlockListData.available() > 0) {
SpdmMeasurementBlock spdmMeasurementBlock; try {
spdmMeasurementBlock = new SpdmMeasurementBlock(spdmMeasurementBlockListData); SpdmMeasurementBlock spdmMeasurementBlock =
spdmMeasurementBlockList.add(spdmMeasurementBlock); new SpdmMeasurementBlock(spdmMeasurementBlockListData);
spdmMeasurementBlockList.add(spdmMeasurementBlock);
} catch (IOException e) {
spdmMeasurementBlockReadError = true;
break;
}
} }
} }
@ -105,13 +115,18 @@ public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends Device
dsedSubHeaderInfo += " SPDM Hash Algorithm = " + spdmHashAlgoStr + "\n"; dsedSubHeaderInfo += " SPDM Hash Algorithm = " + spdmHashAlgoStr + "\n";
// SPDM Measurement Block List output // SPDM Measurement Block List output
dsedSubHeaderInfo += " Number of SPDM Measurement Blocks = " + spdmMeasurementBlockList.size() + "\n"; dsedSubHeaderInfo += " Number of SPDM Measurement Blocks = " +
spdmMeasurementBlockList.size() + "\n";
int spdmMeasBlockCnt = 1; int spdmMeasBlockCnt = 1;
for (SpdmMeasurementBlock spdmMeasBlock : spdmMeasurementBlockList) { for (SpdmMeasurementBlock spdmMeasBlock : spdmMeasurementBlockList) {
dsedSubHeaderInfo += " SPDM Measurement Block # " + spdmMeasBlockCnt++ + " of " + dsedSubHeaderInfo += " SPDM Measurement Block # " + spdmMeasBlockCnt++ + " of " +
spdmMeasurementBlockList.size() + "\n"; spdmMeasurementBlockList.size() + "\n";
dsedSubHeaderInfo += spdmMeasBlock.toString(); dsedSubHeaderInfo += spdmMeasBlock.toString();
} }
if(spdmMeasurementBlockReadError) {
dsedSubHeaderInfo += " Error reading SPDM Measurement Block #" +
spdmMeasBlockCnt + ", halting processing\n";
}
return dsedSubHeaderInfo; return dsedSubHeaderInfo;
} }

View File

@ -5,7 +5,6 @@ import hirs.utils.tpm.eventlog.uefi.UefiConstants;
import hirs.utils.tpm.eventlog.uefi.UefiDevicePath; import hirs.utils.tpm.eventlog.uefi.UefiDevicePath;
import lombok.Getter; import lombok.Getter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** /**

View File

@ -3,7 +3,6 @@ package hirs.utils.tpm.eventlog.events;
import hirs.utils.HexUtils; import hirs.utils.HexUtils;
import hirs.utils.tpm.eventlog.uefi.UefiConstants; import hirs.utils.tpm.eventlog.uefi.UefiConstants;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** /**

View File

@ -106,6 +106,11 @@ public class EvNoAction {
return specIdInfo; return specIdInfo;
} }
/**
* Returns a human-readable description of locality based on numeric representation lookup.
*
* @return a description of the locality.
*/
private String getLocality(final byte[] eventData) { private String getLocality(final byte[] eventData) {
String localityInfo = ""; String localityInfo = "";
byte[] localityBytes = new byte[1]; byte[] localityBytes = new byte[1];

View File

@ -39,7 +39,7 @@ public class EvSCrtmVersion {
if (UefiGuid.isValidUUID(data)) { if (UefiGuid.isValidUUID(data)) {
guid = new UefiGuid(data); guid = new UefiGuid(data);
String guidInfo = guid.toStringNoLookup(); String guidInfo = guid.toStringNoLookup();
description = " SCRM Version = " + guidInfo; description = " SCRM Version = " + guidInfo;
} }
} else if (data.length < UefiConstants.SIZE_4) { } else if (data.length < UefiConstants.SIZE_4) {
description = HexUtils.byteArrayToHexString(data); description = HexUtils.byteArrayToHexString(data);

View File

@ -2,7 +2,6 @@ package hirs.utils.tpm.eventlog.events;
import hirs.utils.HexUtils; import hirs.utils.HexUtils;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** /**

View File

@ -63,6 +63,7 @@ public class SpdmCertificateChain {
* SpdmCertificateChain Constructor. * SpdmCertificateChain Constructor.
* *
* @param spdmCertChainBytes byte array holding the SPDM Cert Chain bytes. * @param spdmCertChainBytes byte array holding the SPDM Cert Chain bytes.
* @param rootHashLength length of RootHash.
*/ */
public SpdmCertificateChain(final byte[] spdmCertChainBytes, final int rootHashLength) { public SpdmCertificateChain(final byte[] spdmCertChainBytes, final int rootHashLength) {
@ -108,7 +109,7 @@ public class SpdmCertificateChain {
certChainDataIS.read(certType); certChainDataIS.read(certType);
byte[] certLength = new byte[2]; byte[] certLength = new byte[2];
certChainDataIS.read(certLength); certChainDataIS.read(certLength);
// int cLength = new BigInteger(certLength).intValue() + UefiConstants.SIZE_4; //int cLength = new BigInteger(certLength).intValue() + UefiConstants.SIZE_4;
int cLength = new BigInteger(certLength).intValue(); int cLength = new BigInteger(certLength).intValue();
byte[] certData = new byte[cLength]; byte[] certData = new byte[cLength];
certChainDataIS.read(certData); certChainDataIS.read(certData);

View File

@ -76,13 +76,12 @@ public class SpdmHa {
return alg; return alg;
} }
/** /**
* Returns the hash name via a lookup. * Returns the hash value size based on the hash algorithm.
* Lookup based upon SPDM Spec v1.03 section 10.4. * Lookup based upon SPDM Spec v1.03 section 10.4.
* *
* @param algId int to convert to string * @param algId int to convert to string
* @return name of the algorithm * @return size of the algorithm output
*/ */
public static int tcgAlgIdToByteSize(final int algId) { public static int tcgAlgIdToByteSize(final int algId) {
int byteSize; int byteSize;

View File

@ -1,7 +1,6 @@
package hirs.utils.tpm.eventlog.spdm; package hirs.utils.tpm.eventlog.spdm;
import hirs.utils.HexUtils; import hirs.utils.HexUtils;
import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
/** /**
@ -36,7 +35,7 @@ public class SpdmMeasurement {
/** /**
* Measurement value (digest). * Measurement value (digest).
*/ */
private byte[] dmtfSpecMeasurementValue = null; private byte[] dmtfSpecMeasurementValue;
/** /**
* SpdmMeasurement Constructor. * SpdmMeasurement Constructor.

View File

@ -1,16 +1,10 @@
package hirs.utils.tpm.eventlog.spdm; package hirs.utils.tpm.eventlog.spdm;
import hirs.utils.HexUtils; import hirs.utils.HexUtils;
import hirs.utils.tpm.eventlog.uefi.UefiConstants;
import lombok.Getter; import lombok.Getter;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/** /**
* Class to process the SpdmMeasurementBlock. * Class to process the SpdmMeasurementBlock.
@ -46,38 +40,30 @@ public class SpdmMeasurementBlock {
* SPDM Measurement. * SPDM Measurement.
*/ */
private SpdmMeasurement spdmMeasurement; private SpdmMeasurement spdmMeasurement;
/**
* Error reading SPDM Measurement Block.
*/
private boolean spdmMeasurementBlockReadError = false;
/** /**
* SpdmMeasurementBlock Constructor. * SpdmMeasurementBlock Constructor.
* *
* @param spdmMeasBlocks byte array holding the SPDM Measurement Block bytes. * @param spdmMeasBlocks byte array holding the SPDM Measurement Block bytes.
*/ */
public SpdmMeasurementBlock(final ByteArrayInputStream spdmMeasBlocks) { public SpdmMeasurementBlock(final ByteArrayInputStream spdmMeasBlocks) throws IOException {
try { byte[] indexBytes = new byte[1];
byte[] indexBytes = new byte[1]; spdmMeasBlocks.read(indexBytes);
spdmMeasBlocks.read(indexBytes); index = HexUtils.leReverseInt(indexBytes);
index = HexUtils.leReverseInt(indexBytes);
byte[] measurementSpecBytes = new byte[1]; byte[] measurementSpecBytes = new byte[1];
spdmMeasBlocks.read(measurementSpecBytes); spdmMeasBlocks.read(measurementSpecBytes);
measurementSpec = HexUtils.leReverseInt(measurementSpecBytes); measurementSpec = HexUtils.leReverseInt(measurementSpecBytes);
// in future, can crosscheck this measurement size with the MeasurementSpec hash alg size // in future, can crosscheck this measurement size with the MeasurementSpec hash alg size
byte[] measurementSizeBytes = new byte[2]; byte[] measurementSizeBytes = new byte[2];
spdmMeasBlocks.read(measurementSizeBytes); spdmMeasBlocks.read(measurementSizeBytes);
int measurementSize = HexUtils.leReverseInt(measurementSizeBytes); int measurementSize = HexUtils.leReverseInt(measurementSizeBytes);
byte[] measurementBytes = new byte[measurementSize]; byte[] measurementBytes = new byte[measurementSize];
spdmMeasBlocks.read(measurementBytes); spdmMeasBlocks.read(measurementBytes);
spdmMeasurement = new SpdmMeasurement(measurementBytes); spdmMeasurement = new SpdmMeasurement(measurementBytes);
} catch (IOException ioEx) {
spdmMeasurementBlockReadError = true;
}
} }
/** /**
@ -89,14 +75,9 @@ public class SpdmMeasurementBlock {
String spdmMeasBlockInfo = ""; String spdmMeasBlockInfo = "";
if(spdmMeasurementBlockReadError) { spdmMeasBlockInfo += " Index = " + index + "\n";
spdmMeasBlockInfo += " Error reading SPDM Measurement Block\n"; spdmMeasBlockInfo += " MeasurementSpec = " + measurementSpec + "\n";
} spdmMeasBlockInfo += spdmMeasurement.toString();
else {
spdmMeasBlockInfo += " Index = " + index + "\n";
spdmMeasBlockInfo += " MeasurementSpec = " + measurementSpec + "\n";
spdmMeasBlockInfo += spdmMeasurement.toString();
}
return spdmMeasBlockInfo; return spdmMeasBlockInfo;
} }

View File

@ -38,18 +38,18 @@ public class UefiSecureBoot {
} }
/** /**
* Provides a human readable value for the Secure Boot variable. * Provides a human-readable value for the Secure Boot variable.
* *
* @return Human readable description. * @return Human readable description.
*/ */
public String toString() { public String toString() {
if (!berror) { if (!berror) {
if (secureBootVariable == 1) { if (secureBootVariable == 1) {
info += " Secure Boot is enabled "; info += " Secure Boot is enabled ";
} else if (secureBootVariable == 0) { } else if (secureBootVariable == 0) {
info += " Secure Boot is NOT enabled "; info += " Secure Boot is NOT enabled ";
} else { } else {
info += " Unkown State: Secure Variable is undefined "; info += " Unknown State: Secure Variable is undefined ";
} }
} }
return info; return info;

View File

@ -112,37 +112,37 @@ public class UefiSignatureList {
@Getter @Getter
private String vendorTableFileStatus = FILESTATUS_NOT_ACCESSIBLE; private String vendorTableFileStatus = FILESTATUS_NOT_ACCESSIBLE;
/** // /**
* UefiSignatureList constructor. // * UefiSignatureList constructor.
* // *
* @param list byte array holding the signature list. // * @param list byte array holding the signature list.
* @throws java.security.cert.CertificateException If there a problem parsing the X509 certificate. // * @throws java.security.cert.CertificateException If there a problem parsing the X509 certificate.
* @throws java.security.NoSuchAlgorithmException if there's a problem hashing the certificate. // * @throws java.security.NoSuchAlgorithmException if there's a problem hashing the certificate.
* @throws java.io.IOException If there's a problem parsing the signature data. // * @throws java.io.IOException If there's a problem parsing the signature data.
*/ // */
UefiSignatureList(final byte[] list) // UefiSignatureList(final byte[] list)
throws CertificateException, NoSuchAlgorithmException, IOException { // throws CertificateException, NoSuchAlgorithmException, IOException {
//
byte[] guid = new byte[UefiConstants.SIZE_16]; // byte[] guid = new byte[UefiConstants.SIZE_16];
System.arraycopy(list, 0, guid, 0, UefiConstants.SIZE_16); // System.arraycopy(list, 0, guid, 0, UefiConstants.SIZE_16);
signatureType = new UefiGuid(guid); // signatureType = new UefiGuid(guid);
vendorTableFileStatus = signatureType.getVendorTableFileStatus(); // vendorTableFileStatus = signatureType.getVendorTableFileStatus();
//
byte[] lSize = new byte[UefiConstants.SIZE_4]; // byte[] lSize = new byte[UefiConstants.SIZE_4];
System.arraycopy(list, UefiConstants.OFFSET_16, lSize, 0, UefiConstants.SIZE_4); // System.arraycopy(list, UefiConstants.OFFSET_16, lSize, 0, UefiConstants.SIZE_4);
listSize = HexUtils.leReverseInt(lSize); // listSize = HexUtils.leReverseInt(lSize);
//
byte[] hSize = new byte[UefiConstants.SIZE_4]; // byte[] hSize = new byte[UefiConstants.SIZE_4];
System.arraycopy(list, UefiConstants.OFFSET_20, hSize, 0, UefiConstants.SIZE_4); // System.arraycopy(list, UefiConstants.OFFSET_20, hSize, 0, UefiConstants.SIZE_4);
//
byte[] sSize = new byte[UefiConstants.SIZE_4]; // byte[] sSize = new byte[UefiConstants.SIZE_4];
System.arraycopy(list, UefiConstants.OFFSET_24, sSize, 0, UefiConstants.SIZE_4); // System.arraycopy(list, UefiConstants.OFFSET_24, sSize, 0, UefiConstants.SIZE_4);
signatureSize = HexUtils.leReverseInt(sSize); // signatureSize = HexUtils.leReverseInt(sSize);
//
sigData = new byte[signatureSize]; // sigData = new byte[signatureSize];
System.arraycopy(list, UefiConstants.OFFSET_28, sigData, 0, signatureSize); // System.arraycopy(list, UefiConstants.OFFSET_28, sigData, 0, signatureSize);
processSignatureList(sigData); // processSignatureList(sigData);
} // }
/** /**
* EFI Signature list constructor. * EFI Signature list constructor.
@ -163,7 +163,6 @@ public class UefiSignatureList {
// however, if signatureType is valid, but some of the data later on is invalid, that will // however, if signatureType is valid, but some of the data later on is invalid, that will
// be caught when UefiSignatureData is processed // be caught when UefiSignatureData is processed
if (!isValidSigListGUID(signatureType)) { if (!isValidSigListGUID(signatureType)) {
//processSignatureData(lists);
signatureTypeValid = false; signatureTypeValid = false;
} else { // valid SigData Processing } else { // valid SigData Processing
signatureTypeValid = true; signatureTypeValid = true;
@ -207,28 +206,6 @@ public class UefiSignatureList {
} }
} }
/**
* Method for processing a set of EFI SignatureList(s).
*
* @param sigDataIS Byte array holding one or more SignatureLists.
* @throws java.security.cert.CertificateException If there's a problem parsing the X509 certificate.
* @throws java.security.NoSuchAlgorithmException if there's a problem hashing the certificate.
* @throws java.io.IOException If there's a problem parsing the signature data.
*/
private void processSignatureData(final ByteArrayInputStream sigDataIS)
throws CertificateException, NoSuchAlgorithmException, IOException {
while (sigDataIS.available() > 0) {
UefiSignatureData tmpigData = new UefiSignatureData(sigDataIS, signatureType);
if (!tmpigData.isValid()) {
dataValid = false;
dataInvalidStatus = tmpigData.getStatus();
break;
}
sigList.add(tmpigData);
numberOfCerts++;
}
}
/** /**
* Checks to see if GUID is listed on page 1729 of UEFI spec version 2.8. * Checks to see if GUID is listed on page 1729 of UEFI spec version 2.8.
* *

View File

@ -248,7 +248,7 @@ public class UefiVariable {
/** /**
* Print out all the interesting characteristics available on this UEFI Variable. * Print out all the interesting characteristics available on this UEFI Variable.
* *
* @return human readable description of the UEFi variable. * @return human-readable description of the UEFi variable.
*/ */
public String toString() { public String toString() {
StringBuilder efiVariable = new StringBuilder(); StringBuilder efiVariable = new StringBuilder();
@ -320,11 +320,11 @@ public class UefiVariable {
} }
/** /**
* Retrieves human readable description from a Certificate. * Retrieves human-readable description from a Certificate.
* *
* @param data byte[] holding the certificate. * @param data byte[] holding the certificate.
* @param offset offset to start of the certificate within the byte array. * @param offset offset to start of the certificate within the byte array.
* @return human readable description of a certificate. * @return human-readable description of a certificate.
*/ */
public String printCert(final byte[] data, final int offset) { public String printCert(final byte[] data, final int offset) {
String certInfo = ""; String certInfo = "";