mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-18 20:47:58 +00:00
issue_847: Reduced styling errors in CA module to less than 100
This commit is contained in:
parent
64c74eae5c
commit
571d107e1b
@ -626,7 +626,7 @@ public abstract class Certificate extends ArchivableEntity {
|
|||||||
* on the portal.
|
* on the portal.
|
||||||
*
|
*
|
||||||
* @return A list of URLs that inform the location of the certificate revocation lists
|
* @return A list of URLs that inform the location of the certificate revocation lists
|
||||||
* @throws java.io.IOException
|
* @throws IOException if there is an issue while retrieving the CRL Distribution point
|
||||||
*/
|
*/
|
||||||
private String getCRLDistributionPoint() throws IOException {
|
private String getCRLDistributionPoint() throws IOException {
|
||||||
List<String> crlUrls = new ArrayList<>();
|
List<String> crlUrls = new ArrayList<>();
|
||||||
@ -972,6 +972,11 @@ public abstract class Certificate extends ArchivableEntity {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the Certificate object.
|
||||||
|
*
|
||||||
|
* @return a string representation of the Certificate object.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Certificate{%s, AuthID=%s, serialNumber=%s, "
|
return String.format("Certificate{%s, AuthID=%s, serialNumber=%s, "
|
||||||
@ -982,6 +987,13 @@ public abstract class Certificate extends ArchivableEntity {
|
|||||||
signatureAlgorithm, certificateHash);
|
signatureAlgorithm, certificateHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares this certificate to the provided object to verify that both this and the provided certificate
|
||||||
|
* objects are equal.
|
||||||
|
*
|
||||||
|
* @param o object to compare
|
||||||
|
* @return true if both the provided certificate and this certificate are equal, false otherwise
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@ -997,6 +1009,11 @@ public abstract class Certificate extends ArchivableEntity {
|
|||||||
return Arrays.equals(certificateBytes, that.certificateBytes);
|
return Arrays.equals(certificateBytes, that.certificateBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an integer hash code for this Certificate object.
|
||||||
|
*
|
||||||
|
* @return integer hash code
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Arrays.hashCode(certificateBytes);
|
return Arrays.hashCode(certificateBytes);
|
||||||
|
@ -18,8 +18,8 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Represents an issued attestation certificate to a HIRS Client.
|
* Represents an issued attestation certificate to a HIRS Client.
|
||||||
*/
|
*/
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
@Entity
|
@Entity
|
||||||
public class IssuedAttestationCertificate extends DeviceAssociatedCertificate {
|
public class IssuedAttestationCertificate extends DeviceAssociatedCertificate {
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ public class IssuedAttestationCertificate extends DeviceAssociatedCertificate {
|
|||||||
public static final String AIC_TYPE_LABEL = "TCPA Trusted Platform Identity";
|
public static final String AIC_TYPE_LABEL = "TCPA Trusted Platform Identity";
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
public boolean isLDevID;
|
private boolean isLDevID;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "ek_id")
|
@JoinColumn(name = "ek_id")
|
||||||
|
@ -126,6 +126,11 @@ public class CommonCriteriaMeasures {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a custom string representation of the Common Criteria Measures object.
|
||||||
|
*
|
||||||
|
* @return a string representation of Common Criteria Measures
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -27,12 +27,17 @@ public class ComponentAddress {
|
|||||||
public static final int IDENTIFIER_NUMBER = 2;
|
public static final int IDENTIFIER_NUMBER = 2;
|
||||||
|
|
||||||
private static final String ETHERNET_MAC = "2.23.133.17.1";
|
private static final String ETHERNET_MAC = "2.23.133.17.1";
|
||||||
|
|
||||||
private static final String WLAN_MAC = "2.23.133.17.2";
|
private static final String WLAN_MAC = "2.23.133.17.2";
|
||||||
|
|
||||||
private static final String BLUETOOTH_MAC = "2.23.133.17.3";
|
private static final String BLUETOOTH_MAC = "2.23.133.17.3";
|
||||||
|
|
||||||
private ASN1ObjectIdentifier addressType;
|
private ASN1ObjectIdentifier addressType;
|
||||||
|
|
||||||
private ASN1UTF8String addressValue;
|
private ASN1UTF8String addressValue;
|
||||||
|
|
||||||
private String addressTypeString;
|
private String addressTypeString;
|
||||||
|
|
||||||
private String addressValueString;
|
private String addressValueString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,6 +79,12 @@ public class ComponentAddress {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the Component Address object.
|
||||||
|
*
|
||||||
|
* @return a string representation of the Component Address object.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ComponentAddress{"
|
return "ComponentAddress{"
|
||||||
|
@ -201,6 +201,11 @@ public class ComponentIdentifier {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the Component Identifier object.
|
||||||
|
*
|
||||||
|
* @return a string representation of the Component Identifier object.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -3,6 +3,7 @@ package hirs.attestationca.persist.entity.userdefined.certificate.attributes;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import org.bouncycastle.asn1.ASN1Boolean;
|
import org.bouncycastle.asn1.ASN1Boolean;
|
||||||
import org.bouncycastle.asn1.ASN1Enumerated;
|
import org.bouncycastle.asn1.ASN1Enumerated;
|
||||||
import org.bouncycastle.asn1.ASN1IA5String;
|
import org.bouncycastle.asn1.ASN1IA5String;
|
||||||
@ -17,18 +18,18 @@ import org.bouncycastle.asn1.ASN1Sequence;
|
|||||||
* plus BOOLEAN DEFAULT FALSE }
|
* plus BOOLEAN DEFAULT FALSE }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
public class FIPSLevel {
|
public class FIPSLevel {
|
||||||
|
|
||||||
private static final int MAX_SEQUENCE_SIZE = 3;
|
private static final int MAX_SEQUENCE_SIZE = 3;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private ASN1IA5String version;
|
private ASN1IA5String version;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private SecurityLevel level;
|
private SecurityLevel level;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private ASN1Boolean plus;
|
private ASN1Boolean plus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,15 +66,6 @@ public class FIPSLevel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "FIPSLevel{"
|
|
||||||
+ "version=" + version.getString()
|
|
||||||
+ ", level=" + level.getValue()
|
|
||||||
+ ", plus=" + plus.toString()
|
|
||||||
+ '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type to handle the security Level used in the FIPS Level.
|
* A type to handle the security Level used in the FIPS Level.
|
||||||
* Ordering of enum types is intentional and their ordinal values correspond to enum
|
* Ordering of enum types is intentional and their ordinal values correspond to enum
|
||||||
@ -87,6 +79,8 @@ public class FIPSLevel {
|
|||||||
* level4 (4) }
|
* level4 (4) }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
public enum SecurityLevel {
|
public enum SecurityLevel {
|
||||||
/**
|
/**
|
||||||
* Security Level 1.
|
* Security Level 1.
|
||||||
@ -106,23 +100,5 @@ public class FIPSLevel {
|
|||||||
LEVEL4("level 4");
|
LEVEL4("level 4");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic constructor.
|
|
||||||
*
|
|
||||||
* @param value string containing the value.
|
|
||||||
*/
|
|
||||||
SecurityLevel(final String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the string value from the StrengthOfFunction.
|
|
||||||
*
|
|
||||||
* @return the string containing the value.
|
|
||||||
*/
|
|
||||||
public String getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,11 @@ public class PlatformConfigurationV1 extends PlatformConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the Platform Configuration V1 object.
|
||||||
|
*
|
||||||
|
* @return a string representation of the Platform Configuration V1 object.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -3,6 +3,7 @@ package hirs.attestationca.persist.entity.userdefined.certificate.attributes;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import org.bouncycastle.asn1.ASN1Sequence;
|
import org.bouncycastle.asn1.ASN1Sequence;
|
||||||
import org.bouncycastle.asn1.ASN1UTF8String;
|
import org.bouncycastle.asn1.ASN1UTF8String;
|
||||||
import org.bouncycastle.asn1.DERUTF8String;
|
import org.bouncycastle.asn1.DERUTF8String;
|
||||||
@ -19,14 +20,18 @@ import org.bouncycastle.asn1.DERUTF8String;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
public class PlatformProperty {
|
public class PlatformProperty {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of identifiers for version 1.
|
* Number of identifiers for version 1.
|
||||||
*/
|
*/
|
||||||
protected static final int IDENTIFIER_NUMBER = 2;
|
protected static final int IDENTIFIER_NUMBER = 2;
|
||||||
|
|
||||||
private static final String NOT_SPECIFIED = "Not Specified";
|
private static final String NOT_SPECIFIED = "Not Specified";
|
||||||
|
|
||||||
private ASN1UTF8String propertyName;
|
private ASN1UTF8String propertyName;
|
||||||
|
|
||||||
private ASN1UTF8String propertyValue;
|
private ASN1UTF8String propertyValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,12 +59,4 @@ public class PlatformProperty {
|
|||||||
this.propertyName = ASN1UTF8String.getInstance(sequence.getObjectAt(0));
|
this.propertyName = ASN1UTF8String.getInstance(sequence.getObjectAt(0));
|
||||||
this.propertyValue = ASN1UTF8String.getInstance(sequence.getObjectAt(1));
|
this.propertyValue = ASN1UTF8String.getInstance(sequence.getObjectAt(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "PlatformProperty{"
|
|
||||||
+ "propertyName=" + propertyName.getString()
|
|
||||||
+ ", propertyValue=" + propertyValue.getString()
|
|
||||||
+ "}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package hirs.attestationca.persist.entity.userdefined.certificate.attributes;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import org.bouncycastle.asn1.ASN1Boolean;
|
import org.bouncycastle.asn1.ASN1Boolean;
|
||||||
import org.bouncycastle.asn1.ASN1Enumerated;
|
import org.bouncycastle.asn1.ASN1Enumerated;
|
||||||
import org.bouncycastle.asn1.ASN1IA5String;
|
import org.bouncycastle.asn1.ASN1IA5String;
|
||||||
@ -24,17 +26,28 @@ import java.math.BigInteger;
|
|||||||
* iso9000Uri IA5STRING (SIZE (1..URIMAX)) OPTIONAL }
|
* iso9000Uri IA5STRING (SIZE (1..URIMAX)) OPTIONAL }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
public class TBBSecurityAssertion {
|
public class TBBSecurityAssertion {
|
||||||
|
|
||||||
private static final int CCINFO = 0;
|
private static final int CCINFO = 0;
|
||||||
|
|
||||||
private static final int FIPSLEVEL = 1;
|
private static final int FIPSLEVEL = 1;
|
||||||
|
|
||||||
private static final int RTMTYPE = 2;
|
private static final int RTMTYPE = 2;
|
||||||
|
|
||||||
private ASN1Integer version;
|
private ASN1Integer version;
|
||||||
|
|
||||||
private CommonCriteriaMeasures ccInfo;
|
private CommonCriteriaMeasures ccInfo;
|
||||||
|
|
||||||
private FIPSLevel fipsLevel;
|
private FIPSLevel fipsLevel;
|
||||||
|
|
||||||
private MeasurementRootType rtmType;
|
private MeasurementRootType rtmType;
|
||||||
|
|
||||||
private ASN1Boolean iso9000Certified;
|
private ASN1Boolean iso9000Certified;
|
||||||
|
|
||||||
private ASN1IA5String iso9000Uri;
|
private ASN1IA5String iso9000Uri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,118 +128,6 @@ public class TBBSecurityAssertion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the version
|
|
||||||
*/
|
|
||||||
public ASN1Integer getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param version the version to set
|
|
||||||
*/
|
|
||||||
public void setVersion(final ASN1Integer version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the ccInfo
|
|
||||||
*/
|
|
||||||
public CommonCriteriaMeasures getCcInfo() {
|
|
||||||
return ccInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ccInfo the ccInfo to set
|
|
||||||
*/
|
|
||||||
public void setCcInfo(final CommonCriteriaMeasures ccInfo) {
|
|
||||||
this.ccInfo = ccInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the fipsLevel
|
|
||||||
*/
|
|
||||||
public FIPSLevel getFipsLevel() {
|
|
||||||
return fipsLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fipsLevel the fipsLevel to set
|
|
||||||
*/
|
|
||||||
public void setFipsLevel(final FIPSLevel fipsLevel) {
|
|
||||||
this.fipsLevel = fipsLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rtmType
|
|
||||||
*/
|
|
||||||
public MeasurementRootType getRtmType() {
|
|
||||||
return rtmType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rtmType the rtmType to set
|
|
||||||
*/
|
|
||||||
public void setRtmType(final MeasurementRootType rtmType) {
|
|
||||||
this.rtmType = rtmType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the iso9000Certified
|
|
||||||
*/
|
|
||||||
public ASN1Boolean getIso9000Certified() {
|
|
||||||
return iso9000Certified;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param iso9000Certified the iso9000Certified to set
|
|
||||||
*/
|
|
||||||
public void setIso9000Certified(final ASN1Boolean iso9000Certified) {
|
|
||||||
this.iso9000Certified = iso9000Certified;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the iso9000Uri
|
|
||||||
*/
|
|
||||||
public ASN1IA5String getIso9000Uri() {
|
|
||||||
return iso9000Uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param iso9000Uri the iso9000Uri to set
|
|
||||||
*/
|
|
||||||
public void setIso9000Uri(final ASN1IA5String iso9000Uri) {
|
|
||||||
this.iso9000Uri = iso9000Uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("TBBSecurityAssertion{");
|
|
||||||
sb.append("version=").append(version.toString());
|
|
||||||
//Optional values not null
|
|
||||||
sb.append(", ccInfo=");
|
|
||||||
if (ccInfo != null) {
|
|
||||||
sb.append(ccInfo);
|
|
||||||
}
|
|
||||||
sb.append(", fipsLevel=");
|
|
||||||
if (fipsLevel != null) {
|
|
||||||
sb.append(fipsLevel);
|
|
||||||
}
|
|
||||||
sb.append(", rtmType=");
|
|
||||||
if (rtmType != null) {
|
|
||||||
sb.append(rtmType.getValue());
|
|
||||||
}
|
|
||||||
sb.append(", iso9000Certified=").append(iso9000Certified.toString());
|
|
||||||
sb.append(", iso9000Uri=");
|
|
||||||
if (iso9000Uri != null) {
|
|
||||||
sb.append(iso9000Uri.getString());
|
|
||||||
}
|
|
||||||
sb.append("}");
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type to handle the evaluation status used in the Common Criteria Measurement.
|
* A type to handle the evaluation status used in the Common Criteria Measurement.
|
||||||
* Ordering of enum types is intentional and their ordinal values correspond to enum
|
* Ordering of enum types is intentional and their ordinal values correspond to enum
|
||||||
|
@ -7,6 +7,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -21,22 +22,27 @@ import java.math.BigInteger;
|
|||||||
* www.trustedcomputinggroup.org/wp-content/uploads/Credential_Profile_EK_V2.0_R14_published.pdf
|
* www.trustedcomputinggroup.org/wp-content/uploads/Credential_Profile_EK_V2.0_R14_published.pdf
|
||||||
* for specifications for TPM 2.0 (pg. 19).
|
* for specifications for TPM 2.0 (pg. 19).
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
|
@ToString
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class TPMSecurityAssertions implements Serializable {
|
public class TPMSecurityAssertions implements Serializable {
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
private BigInteger tpmSecAssertsVersion; //default v1
|
private BigInteger tpmSecAssertsVersion; //default v1
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
private boolean fieldUpgradeable; //default false
|
private boolean fieldUpgradeable; //default false
|
||||||
@Column(nullable = true)
|
|
||||||
|
@Column
|
||||||
private EkGenerationType ekGenType; //optional
|
private EkGenerationType ekGenType; //optional
|
||||||
@Column(nullable = true)
|
|
||||||
private EkGenerationLocation ekGenerationLocation; //optional
|
@Column
|
||||||
@Column(nullable = true)
|
private EkGenerationLocation ekGenerationLocation; //optionalv
|
||||||
|
|
||||||
|
@Column
|
||||||
private EkGenerationLocation ekCertificateGenerationLocation; //optional
|
private EkGenerationLocation ekCertificateGenerationLocation; //optional
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,17 +58,6 @@ public class TPMSecurityAssertions implements Serializable {
|
|||||||
this.fieldUpgradeable = fieldUpgradeable;
|
this.fieldUpgradeable = fieldUpgradeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "TPMSecurityAssertions{"
|
|
||||||
+ "version=" + tpmSecAssertsVersion
|
|
||||||
+ ", fieldUpgradeable=" + fieldUpgradeable
|
|
||||||
+ ", ekGenType=" + ekGenType
|
|
||||||
+ ", ekGenLoc=" + ekGenerationLocation
|
|
||||||
+ ", ekCertGenLoc=" + ekCertificateGenerationLocation
|
|
||||||
+ '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Future work (may need to create other classes):
|
// Future work (may need to create other classes):
|
||||||
//private CommonCriteriaMeasures commCritMeasures; //optional
|
//private CommonCriteriaMeasures commCritMeasures; //optional
|
||||||
//private FIPSLevel fipsLevel; //optional
|
//private FIPSLevel fipsLevel; //optional
|
||||||
|
@ -6,6 +6,7 @@ import lombok.AccessLevel;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -20,9 +21,10 @@ import java.math.BigInteger;
|
|||||||
* www.trustedcomputinggroup.org/wp-content/uploads/Credential_Profile_EK_V2.0_R14_published.pdf
|
* www.trustedcomputinggroup.org/wp-content/uploads/Credential_Profile_EK_V2.0_R14_published.pdf
|
||||||
* for specifications for TPM 2.0.
|
* for specifications for TPM 2.0.
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class TPMSpecification implements Serializable {
|
public class TPMSpecification implements Serializable {
|
||||||
|
|
||||||
@ -48,13 +50,4 @@ public class TPMSpecification implements Serializable {
|
|||||||
this.level = level;
|
this.level = level;
|
||||||
this.revision = revision;
|
this.revision = revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "TPMSpecification{"
|
|
||||||
+ "family='" + family + '\''
|
|
||||||
+ ", level=" + level
|
|
||||||
+ ", revision=" + revision
|
|
||||||
+ '}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,13 @@ import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class URIReference {
|
public class URIReference {
|
||||||
private static final int PLATFORM_PROPERTIES_URI_MAX = 3;
|
private static final int PLATFORM_PROPERTIES_URI_MAX = 3;
|
||||||
|
|
||||||
private static final int PLATFORM_PROPERTIES_URI_MIN = 1;
|
private static final int PLATFORM_PROPERTIES_URI_MIN = 1;
|
||||||
|
|
||||||
private ASN1IA5String uniformResourceIdentifier;
|
private ASN1IA5String uniformResourceIdentifier;
|
||||||
|
|
||||||
private AlgorithmIdentifier hashAlgorithm;
|
private AlgorithmIdentifier hashAlgorithm;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private ASN1BitString hashValue;
|
private ASN1BitString hashValue;
|
||||||
|
|
||||||
@ -70,6 +74,11 @@ public class URIReference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the URI Reference object.
|
||||||
|
*
|
||||||
|
* @return a string representation of URI Reference
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -4,6 +4,7 @@ import hirs.attestationca.persist.entity.userdefined.certificate.attributes.Comp
|
|||||||
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentClass;
|
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentClass;
|
||||||
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentIdentifier;
|
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentIdentifier;
|
||||||
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.URIReference;
|
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.URIReference;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bouncycastle.asn1.ASN1Boolean;
|
import org.bouncycastle.asn1.ASN1Boolean;
|
||||||
@ -16,7 +17,6 @@ import org.bouncycastle.asn1.ASN1UTF8String;
|
|||||||
import org.bouncycastle.asn1.DERUTF8String;
|
import org.bouncycastle.asn1.DERUTF8String;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,17 +40,24 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class ComponentIdentifierV2 extends ComponentIdentifier {
|
public class ComponentIdentifierV2 extends ComponentIdentifier {
|
||||||
|
|
||||||
private static final int MANDATORY_ELEMENTS = 3;
|
private static final int MANDATORY_ELEMENTS = 3;
|
||||||
|
|
||||||
// Additional optional identifiers for version 2
|
// Additional optional identifiers for version 2
|
||||||
private static final int COMPONENT_PLATFORM_CERT = 5;
|
private static final int COMPONENT_PLATFORM_CERT = 5;
|
||||||
|
|
||||||
private static final int COMPONENT_PLATFORM_URI = 6;
|
private static final int COMPONENT_PLATFORM_URI = 6;
|
||||||
|
|
||||||
private static final int ATTRIBUTE_STATUS = 7;
|
private static final int ATTRIBUTE_STATUS = 7;
|
||||||
|
|
||||||
private ComponentClass componentClass;
|
private ComponentClass componentClass;
|
||||||
|
|
||||||
private CertificateIdentifier certificateIdentifier;
|
private CertificateIdentifier certificateIdentifier;
|
||||||
|
|
||||||
private URIReference componentPlatformUri;
|
private URIReference componentPlatformUri;
|
||||||
|
|
||||||
private AttributeStatus attributeStatus;
|
private AttributeStatus attributeStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,30 +208,11 @@ public class ComponentIdentifierV2 extends ComponentIdentifier {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean equals(Object o) {
|
* Creates a string representation of the Component Identifier V2 object.
|
||||||
if (this == o) {
|
*
|
||||||
return true;
|
* @return a string representation of the Component Identifier V2 object.
|
||||||
}
|
*/
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!super.equals(o)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ComponentIdentifierV2 that = (ComponentIdentifierV2) o;
|
|
||||||
return Objects.equals(componentClass, that.componentClass)
|
|
||||||
&& Objects.equals(certificateIdentifier, that.certificateIdentifier)
|
|
||||||
&& Objects.equals(componentPlatformUri, that.componentPlatformUri)
|
|
||||||
&& attributeStatus == that.attributeStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(super.hashCode(), componentClass,
|
|
||||||
certificateIdentifier, componentPlatformUri, attributeStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -87,6 +87,11 @@ public class PlatformConfigurationV2 extends PlatformConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the Platform Configuration V2 object.
|
||||||
|
*
|
||||||
|
* @return a string representation of the Platform Configuration V2 object.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -17,10 +17,10 @@ import org.bouncycastle.asn1.ASN1UTF8String;
|
|||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
public class PlatformPropertyV2 extends PlatformProperty {
|
public class PlatformPropertyV2 extends PlatformProperty {
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private AttributeStatus attributeStatus;
|
private AttributeStatus attributeStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,6 +83,12 @@ public class PlatformPropertyV2 extends PlatformProperty {
|
|||||||
return getAttributeStatus() != AttributeStatus.REMOVED;
|
return getAttributeStatus() != AttributeStatus.REMOVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the PlatformPropertyV2 object.
|
||||||
|
*
|
||||||
|
* @return a string representation of the PlatformPropertyV2 object
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -9,6 +9,7 @@ import jakarta.persistence.DiscriminatorType;
|
|||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.xml.bind.annotation.XmlElement;
|
import jakarta.xml.bind.annotation.XmlElement;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
@ -24,6 +25,7 @@ import java.util.Objects;
|
|||||||
@Entity
|
@Entity
|
||||||
@Getter
|
@Getter
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@DiscriminatorColumn(name = "componentTypeEnum", discriminatorType = DiscriminatorType.STRING)
|
@DiscriminatorColumn(name = "componentTypeEnum", discriminatorType = DiscriminatorType.STRING)
|
||||||
public class ComponentInfo extends ArchivableEntity {
|
public class ComponentInfo extends ArchivableEntity {
|
||||||
|
|
||||||
@ -152,31 +154,6 @@ public class ComponentInfo extends ArchivableEntity {
|
|||||||
|| StringUtils.isEmpty(componentModel));
|
|| StringUtils.isEmpty(componentModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Equals for the component info that just uses this classes attributes.
|
|
||||||
*
|
|
||||||
* @param object the object to compare
|
|
||||||
* @return the boolean result
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object) {
|
|
||||||
if (this == object) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (object == null || getClass() != object.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComponentInfo that = (ComponentInfo) object;
|
|
||||||
return Objects.equals(deviceName, that.deviceName)
|
|
||||||
&& Objects.equals(componentManufacturer,
|
|
||||||
that.componentManufacturer)
|
|
||||||
&& Objects.equals(componentModel, that.componentModel)
|
|
||||||
&& Objects.equals(componentSerial, that.componentSerial)
|
|
||||||
&& Objects.equals(componentRevision, that.componentRevision)
|
|
||||||
&& Objects.equals(componentClass, that.componentClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a hash code that is associated with common fields for components.
|
* Returns a hash code that is associated with common fields for components.
|
||||||
*
|
*
|
||||||
@ -186,16 +163,4 @@ public class ComponentInfo extends ArchivableEntity {
|
|||||||
return Objects.hash(componentManufacturer, componentModel,
|
return Objects.hash(componentManufacturer, componentModel,
|
||||||
componentSerial, componentRevision, componentClass);
|
componentSerial, componentRevision, componentClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hash method for the attributes of this class.
|
|
||||||
*
|
|
||||||
* @return int value that represents this class
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(deviceName, componentManufacturer,
|
|
||||||
componentModel, componentSerial, componentRevision,
|
|
||||||
componentClass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,6 @@ public class TPMInfo implements Serializable {
|
|||||||
* @param tpmQuoteHash short representing the minor revision number for the TPM
|
* @param tpmQuoteHash short representing the minor revision number for the TPM
|
||||||
* @param tpmQuoteSignature byte array with the value of the identity certificate
|
* @param tpmQuoteSignature byte array with the value of the identity certificate
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("parameternumber")
|
|
||||||
public TPMInfo(final String tpmMake, final short tpmVersionMajor,
|
public TPMInfo(final String tpmMake, final short tpmVersionMajor,
|
||||||
final short tpmVersionMinor, final short tpmVersionRevMajor,
|
final short tpmVersionMinor, final short tpmVersionRevMajor,
|
||||||
final short tpmVersionRevMinor,
|
final short tpmVersionRevMinor,
|
||||||
@ -110,7 +109,6 @@ public class TPMInfo implements Serializable {
|
|||||||
* @param tpmQuoteHash short representing the minor revision number for the TPM
|
* @param tpmQuoteHash short representing the minor revision number for the TPM
|
||||||
* @param tpmQuoteSignature byte array with the value of the identity certificate
|
* @param tpmQuoteSignature byte array with the value of the identity certificate
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("parameternumber")
|
|
||||||
public TPMInfo(final String tpmMake, final short tpmVersionMajor,
|
public TPMInfo(final String tpmMake, final short tpmVersionMajor,
|
||||||
final short tpmVersionMinor, final short tpmVersionRevMajor,
|
final short tpmVersionMinor, final short tpmVersionRevMajor,
|
||||||
final short tpmVersionRevMinor, final byte[] pcrValues,
|
final short tpmVersionRevMinor, final byte[] pcrValues,
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Entity
|
@Entity
|
||||||
public class BaseReferenceManifest extends ReferenceManifest {
|
public class BaseReferenceManifest extends ReferenceManifest {
|
||||||
/**
|
/**
|
||||||
@ -377,6 +377,11 @@ public class BaseReferenceManifest extends ReferenceManifest {
|
|||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a string representation of the Base Reference Manifest object.
|
||||||
|
*
|
||||||
|
* @return a string representation of the Base Reference Manifest object.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("ReferenceManifest{swidName=%s,"
|
return String.format("ReferenceManifest{swidName=%s,"
|
||||||
|
@ -8,6 +8,7 @@ import jakarta.persistence.Column;
|
|||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.Enumerated;
|
import jakarta.persistence.Enumerated;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
@ -26,6 +27,7 @@ import java.util.Collection;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@EqualsAndHashCode
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Entity
|
@Entity
|
||||||
public class EventLogMeasurements extends SupportReferenceManifest {
|
public class EventLogMeasurements extends SupportReferenceManifest {
|
||||||
@ -105,22 +107,4 @@ public class EventLogMeasurements extends SupportReferenceManifest {
|
|||||||
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(final Object object) {
|
|
||||||
if (this == object) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (object == null || getClass() != object.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
EventLogMeasurements that = (EventLogMeasurements) object;
|
|
||||||
|
|
||||||
return this.getHexDecHash().equals(that.getHexDecHash());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return super.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import hirs.utils.tpm.eventlog.TCGEventLog;
|
|||||||
import hirs.utils.tpm.eventlog.TpmPcrEvent;
|
import hirs.utils.tpm.eventlog.TpmPcrEvent;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
@ -16,7 +17,6 @@ import java.security.cert.CertificateException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub class that will just focus on PCR Values and Events.
|
* Sub class that will just focus on PCR Values and Events.
|
||||||
@ -24,12 +24,14 @@ import java.util.Objects;
|
|||||||
@Log4j2
|
@Log4j2
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Entity
|
@Entity
|
||||||
public class SupportReferenceManifest extends ReferenceManifest {
|
public class SupportReferenceManifest extends ReferenceManifest {
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private int pcrHash = 0;
|
private int pcrHash = 0;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
private boolean updated = false;
|
private boolean updated = false;
|
||||||
|
|
||||||
@ -79,12 +81,8 @@ public class SupportReferenceManifest extends ReferenceManifest {
|
|||||||
TCGEventLog logProcessor = new TCGEventLog(this.getRimBytes());
|
TCGEventLog logProcessor = new TCGEventLog(this.getRimBytes());
|
||||||
this.pcrHash = Arrays.hashCode(logProcessor.getExpectedPCRValues());
|
this.pcrHash = Arrays.hashCode(logProcessor.getExpectedPCRValues());
|
||||||
return logProcessor.getExpectedPCRValues();
|
return logProcessor.getExpectedPCRValues();
|
||||||
} catch (CertificateException cEx) {
|
} catch (CertificateException | NoSuchAlgorithmException | IOException exception) {
|
||||||
log.error(cEx);
|
log.error(exception);
|
||||||
} catch (NoSuchAlgorithmException noSaEx) {
|
|
||||||
log.error(noSaEx);
|
|
||||||
} catch (IOException ioEx) {
|
|
||||||
log.error(ioEx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String[0];
|
return new String[0];
|
||||||
@ -100,12 +98,8 @@ public class SupportReferenceManifest extends ReferenceManifest {
|
|||||||
try {
|
try {
|
||||||
logProcessor = new TCGEventLog(this.getRimBytes());
|
logProcessor = new TCGEventLog(this.getRimBytes());
|
||||||
return logProcessor.getEventList();
|
return logProcessor.getEventList();
|
||||||
} catch (CertificateException cEx) {
|
} catch (CertificateException | NoSuchAlgorithmException | IOException exception) {
|
||||||
log.error(cEx);
|
log.error(exception);
|
||||||
} catch (NoSuchAlgorithmException noSaEx) {
|
|
||||||
log.error(noSaEx);
|
|
||||||
} catch (IOException ioEx) {
|
|
||||||
log.error(ioEx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -120,24 +114,4 @@ public class SupportReferenceManifest extends ReferenceManifest {
|
|||||||
public boolean isBaseSupport() {
|
public boolean isBaseSupport() {
|
||||||
return !this.isSwidSupplemental() && !this.isSwidPatch();
|
return !this.isSwidSupplemental() && !this.isSwidPatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!super.equals(o)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SupportReferenceManifest that = (SupportReferenceManifest) o;
|
|
||||||
return pcrHash == that.pcrHash && updated == that.updated;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(super.hashCode(), pcrHash, updated);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package hirs.attestationca.persist.enums;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -11,6 +12,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
public enum HealthStatus {
|
public enum HealthStatus {
|
||||||
/**
|
/**
|
||||||
* The trusted state, no issues with the device.
|
* The trusted state, no issues with the device.
|
||||||
@ -35,9 +37,4 @@ public enum HealthStatus {
|
|||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
.contains(healthStatus);
|
.contains(healthStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getHealthStatus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -40,16 +40,16 @@ import java.util.Date;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class AbstractProcessor {
|
public class AbstractProcessor {
|
||||||
|
|
||||||
@Getter
|
|
||||||
private int validDays;
|
private int validDays;
|
||||||
@Getter
|
|
||||||
private PrivateKey privateKey;
|
private PrivateKey privateKey;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
|
||||||
private PolicyRepository policyRepository;
|
private PolicyRepository policyRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,7 +247,8 @@ public class AbstractProcessor {
|
|||||||
final byte[] derEncodedAttestationCertificate,
|
final byte[] derEncodedAttestationCertificate,
|
||||||
final EndorsementCredential endorsementCredential,
|
final EndorsementCredential endorsementCredential,
|
||||||
final List<PlatformCredential> platformCredentials,
|
final List<PlatformCredential> platformCredentials,
|
||||||
final Device device, boolean isLDevID) {
|
final Device device,
|
||||||
|
final boolean isLDevID) {
|
||||||
List<IssuedAttestationCertificate> issuedAc;
|
List<IssuedAttestationCertificate> issuedAc;
|
||||||
boolean generateCertificate = true;
|
boolean generateCertificate = true;
|
||||||
PolicyRepository scp = getPolicyRepository();
|
PolicyRepository scp = getPolicyRepository();
|
||||||
@ -269,9 +270,9 @@ public class AbstractProcessor {
|
|||||||
generateCertificate = isLDevID ? policySettings.isIssueDevIdCertificate()
|
generateCertificate = isLDevID ? policySettings.isIssueDevIdCertificate()
|
||||||
: policySettings.isIssueAttestationCertificate();
|
: policySettings.isIssueAttestationCertificate();
|
||||||
|
|
||||||
if (issuedAc != null && issuedAc.size() > 0 &&
|
if (issuedAc != null && issuedAc.size() > 0
|
||||||
(isLDevID ? policySettings.isDevIdExpirationFlag()
|
&& (isLDevID ? policySettings.isDevIdExpirationFlag()
|
||||||
: policySettings.isGenerateOnExpiration())) {
|
: policySettings.isGenerateOnExpiration())) {
|
||||||
if (issuedAc.get(0).getEndValidity().after(currentDate)) {
|
if (issuedAc.get(0).getEndValidity().after(currentDate)) {
|
||||||
// so the issued AC is not expired
|
// so the issued AC is not expired
|
||||||
// however are we within the threshold
|
// however are we within the threshold
|
||||||
|
@ -97,7 +97,7 @@ public final class ProvisionUtils {
|
|||||||
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This private constructor was created to silence one of checkstyle errors
|
* This private constructor was created to silence one of checkstyle errors.
|
||||||
*/
|
*/
|
||||||
private ProvisionUtils() {
|
private ProvisionUtils() {
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,6 @@ public class SupplyChainValidationService {
|
|||||||
* @param referenceDigestValueRepository the even manager
|
* @param referenceDigestValueRepository the even manager
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
@SuppressWarnings("ParameterNumberCheck")
|
|
||||||
public SupplyChainValidationService(
|
public SupplyChainValidationService(
|
||||||
final CACredentialRepository caCredentialRepository,
|
final CACredentialRepository caCredentialRepository,
|
||||||
final PolicyRepository policyRepository,
|
final PolicyRepository policyRepository,
|
||||||
|
@ -169,16 +169,18 @@ public class ValidationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param deviceInfoReport
|
* Evaluates delta attributes status.
|
||||||
* @param base
|
*
|
||||||
* @param deltaMapping
|
* @param deviceInfoReport device information report
|
||||||
* @param certificateRepository
|
* @param base base platform credential
|
||||||
* @param componentResultRepository
|
* @param deltaMapping delta mapping
|
||||||
* @param componentAttributeRepository
|
* @param certificateRepository certificate repository
|
||||||
* @param componentInfos
|
* @param componentResultRepository component result repository
|
||||||
* @param provisionSessionId
|
* @param componentAttributeRepository component attribute repository
|
||||||
* @param ignoreRevisionAttribute
|
* @param componentInfos list of component information
|
||||||
* @return
|
* @param provisionSessionId uuid representation of the provision session ID
|
||||||
|
* @param ignoreRevisionAttribute whether to ignore the revision attribute
|
||||||
|
* @return a supply chain validation
|
||||||
*/
|
*/
|
||||||
public static SupplyChainValidation evaluateDeltaAttributesStatus(
|
public static SupplyChainValidation evaluateDeltaAttributesStatus(
|
||||||
final DeviceInfoReport deviceInfoReport,
|
final DeviceInfoReport deviceInfoReport,
|
||||||
@ -221,12 +223,14 @@ public class ValidationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param device
|
* Evaluates the firmware status.
|
||||||
* @param policySettings
|
*
|
||||||
* @param rimRepo
|
* @param device device
|
||||||
* @param rdvRepo
|
* @param policySettings policy settings
|
||||||
* @param caRepo
|
* @param rimRepo reference manifest repository
|
||||||
* @return
|
* @param rdvRepo reference digest value repository
|
||||||
|
* @param caRepo CA Credential repository
|
||||||
|
* @return a supply chain validation
|
||||||
*/
|
*/
|
||||||
public static SupplyChainValidation evaluateFirmwareStatus(
|
public static SupplyChainValidation evaluateFirmwareStatus(
|
||||||
final Device device,
|
final Device device,
|
||||||
@ -338,6 +342,7 @@ public class ValidationService {
|
|||||||
* @param credential the credential whose CA chain should be retrieved
|
* @param credential the credential whose CA chain should be retrieved
|
||||||
* @param previouslyQueriedSubjects a list of organizations to refrain
|
* @param previouslyQueriedSubjects a list of organizations to refrain
|
||||||
* from querying
|
* from querying
|
||||||
|
* @param caCredentialRepository CA Credential repository
|
||||||
* @return a Set containing all relevant CA credentials to the given
|
* @return a Set containing all relevant CA credentials to the given
|
||||||
* certificate's organization
|
* certificate's organization
|
||||||
*/
|
*/
|
||||||
@ -379,6 +384,14 @@ public class ValidationService {
|
|||||||
return caCreds;
|
return caCreds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key store using the provided set of certificate authority credentials.
|
||||||
|
*
|
||||||
|
* @param certs set of certificate authority credentials
|
||||||
|
* @return a keystore
|
||||||
|
* @throws KeyStoreException if there is an issue creating a key store
|
||||||
|
* @throws IOException if there is an issue creating a key store
|
||||||
|
*/
|
||||||
public static KeyStore caCertSetToKeystore(final Set<CertificateAuthorityCredential> certs)
|
public static KeyStore caCertSetToKeystore(final Set<CertificateAuthorityCredential> certs)
|
||||||
throws KeyStoreException, IOException {
|
throws KeyStoreException, IOException {
|
||||||
KeyStore keyStore = KeyStore.getInstance("JKS");
|
KeyStore keyStore = KeyStore.getInstance("JKS");
|
||||||
|
@ -130,8 +130,9 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
public void setupTests() throws Exception {
|
public void setupTests() throws Exception {
|
||||||
|
|
||||||
//BeforeSuite
|
//BeforeSuite
|
||||||
|
final int keySize = 2048;
|
||||||
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
|
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
|
||||||
keyPairGenerator.initialize(2048);
|
keyPairGenerator.initialize(keySize);
|
||||||
keyPair = keyPairGenerator.generateKeyPair();
|
keyPair = keyPairGenerator.generateKeyPair();
|
||||||
|
|
||||||
//BeforeTest
|
//BeforeTest
|
||||||
@ -257,8 +258,11 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
SymmetricKey symmetricKey = ProvisionUtils.generateSymmetricKey();
|
SymmetricKey symmetricKey = ProvisionUtils.generateSymmetricKey();
|
||||||
|
|
||||||
// assert the symmetric algorithm, scheme, and key size are all set appropriately
|
// assert the symmetric algorithm, scheme, and key size are all set appropriately
|
||||||
assertTrue(symmetricKey.getAlgorithmId() == 6);
|
final int expectedAlgorithmId = 6;
|
||||||
assertTrue(symmetricKey.getEncryptionScheme() == 255);
|
final int expectedEncryptionScheme = 255;
|
||||||
|
|
||||||
|
assertTrue(symmetricKey.getAlgorithmId() == expectedAlgorithmId);
|
||||||
|
assertTrue(symmetricKey.getEncryptionScheme() == expectedEncryptionScheme);
|
||||||
assertTrue(symmetricKey.getKeySize() == symmetricKey.getKey().length);
|
assertTrue(symmetricKey.getKeySize() == symmetricKey.getKey().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,8 +341,9 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
assertNotNull(attestation);
|
assertNotNull(attestation);
|
||||||
|
|
||||||
// validate the attestation algorithm
|
// validate the attestation algorithm
|
||||||
|
final int expectedAlgorithmId = 6;
|
||||||
assertNotNull(attestation.getAlgorithm());
|
assertNotNull(attestation.getAlgorithm());
|
||||||
assertTrue(attestation.getAlgorithm().getAlgorithmId() == 6);
|
assertTrue(attestation.getAlgorithm().getAlgorithmId() == expectedAlgorithmId);
|
||||||
assertTrue(attestation.getAlgorithm().getEncryptionScheme() == 0x1);
|
assertTrue(attestation.getAlgorithm().getEncryptionScheme() == 0x1);
|
||||||
assertTrue(attestation.getAlgorithm().getSignatureScheme() == 0);
|
assertTrue(attestation.getAlgorithm().getSignatureScheme() == 0);
|
||||||
assertTrue(attestation.getAlgorithm().getParamsSize() == 0);
|
assertTrue(attestation.getAlgorithm().getParamsSize() == 0);
|
||||||
@ -465,7 +470,8 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
|
|
||||||
// assert that the exponent and the modulus are the same. the exponents should be the well
|
// assert that the exponent and the modulus are the same. the exponents should be the well
|
||||||
// known prime, 101
|
// known prime, 101
|
||||||
assertTrue(publicKey.getPublicExponent().equals(new BigInteger("010001", 16)));
|
final int radix = 16;
|
||||||
|
assertTrue(publicKey.getPublicExponent().equals(new BigInteger("010001", radix)));
|
||||||
assertTrue(publicKey.getModulus().equals(modulus));
|
assertTrue(publicKey.getModulus().equals(modulus));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +492,8 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
|
|
||||||
// assert that the exponent and the modulus are the same. the exponents should be the well
|
// assert that the exponent and the modulus are the same. the exponents should be the well
|
||||||
// known prime, 101.
|
// known prime, 101.
|
||||||
assertTrue(publicKey.getPublicExponent().equals(new BigInteger("010001", 16)));
|
final int radix = 16;
|
||||||
|
assertTrue(publicKey.getPublicExponent().equals(new BigInteger("010001", radix)));
|
||||||
assertTrue(publicKey.getModulus().equals(modulus));
|
assertTrue(publicKey.getModulus().equals(modulus));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +511,8 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
byte[] ekFile = Files.readAllBytes(ekPath);
|
byte[] ekFile = Files.readAllBytes(ekPath);
|
||||||
|
|
||||||
RSAPublicKey ek = ProvisionUtils.parsePublicKey(ekFile);
|
RSAPublicKey ek = ProvisionUtils.parsePublicKey(ekFile);
|
||||||
assertTrue(ek.getPublicExponent().equals(new BigInteger("010001", 16)));
|
final int radix = 16;
|
||||||
|
assertTrue(ek.getPublicExponent().equals(new BigInteger("010001", radix)));
|
||||||
|
|
||||||
byte[] mod = ek.getModulus().toByteArray();
|
byte[] mod = ek.getModulus().toByteArray();
|
||||||
// big integer conversion is signed so it can add a 0 byte
|
// big integer conversion is signed so it can add a 0 byte
|
||||||
@ -532,7 +540,8 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
byte[] akFile = Files.readAllBytes(akPath);
|
byte[] akFile = Files.readAllBytes(akPath);
|
||||||
|
|
||||||
RSAPublicKey ak = ProvisionUtils.parsePublicKey(akFile);
|
RSAPublicKey ak = ProvisionUtils.parsePublicKey(akFile);
|
||||||
assertTrue(ak.getPublicExponent().equals(new BigInteger("010001", 16)));
|
final int radix = 16;
|
||||||
|
assertTrue(ak.getPublicExponent().equals(new BigInteger("010001", radix)));
|
||||||
|
|
||||||
byte[] mod = ak.getModulus().toByteArray();
|
byte[] mod = ak.getModulus().toByteArray();
|
||||||
// big integer conversion is signed so it can add a 0 byte
|
// big integer conversion is signed so it can add a 0 byte
|
||||||
@ -598,7 +607,7 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
RSAPublicKey akPub = ProvisionUtils.parsePublicKey(akPubFile);
|
RSAPublicKey akPub = ProvisionUtils.parsePublicKey(akPubFile);
|
||||||
|
|
||||||
// prepare the nonce and wrap it with keys
|
// prepare the nonce and wrap it with keys
|
||||||
byte[] nonce = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
final byte[] nonce = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||||
ByteString blob = ProvisionUtils.tpm20MakeCredential(ekPub, akPub, nonce);
|
ByteString blob = ProvisionUtils.tpm20MakeCredential(ekPub, akPub, nonce);
|
||||||
|
|
||||||
@ -636,12 +645,12 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
* Test helper method that encrypts a blob using a shared key and IV using the specified
|
* Test helper method that encrypts a blob using a shared key and IV using the specified
|
||||||
* transformation.
|
* transformation.
|
||||||
*
|
*
|
||||||
* @param blob to be encrypted
|
* @param blob blob to be encrypted
|
||||||
* @param key shared key
|
* @param key shared key
|
||||||
* @param iv to encrypt with
|
* @param iv to encrypt with
|
||||||
* @param transformation of the encryption cipher
|
* @param transformation of the encryption cipher
|
||||||
* @return encrypted blob
|
* @return encrypted blob
|
||||||
* @throws Exception
|
* @throws Exception if there are any issues while encrypting the blob
|
||||||
*/
|
*/
|
||||||
private byte[] encryptBlob(final byte[] blob, final byte[] key, final byte[] iv,
|
private byte[] encryptBlob(final byte[] blob, final byte[] key, final byte[] iv,
|
||||||
final String transformation) throws Exception {
|
final String transformation) throws Exception {
|
||||||
@ -664,9 +673,9 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
/**
|
/**
|
||||||
* Test helper method to decrypt blobs.
|
* Test helper method to decrypt blobs.
|
||||||
*
|
*
|
||||||
* @param blob to be decrypted
|
* @param blob blob to be decrypted
|
||||||
* @return decrypted blob
|
* @return decrypted blob
|
||||||
* @throws Exception
|
* @throws Exception if there are any issues while decrypting the blob
|
||||||
*/
|
*/
|
||||||
private byte[] decryptBlob(final byte[] blob) throws Exception {
|
private byte[] decryptBlob(final byte[] blob) throws Exception {
|
||||||
// initialize a cipher using the specified transformation
|
// initialize a cipher using the specified transformation
|
||||||
@ -686,12 +695,12 @@ public class AttestationCertificateAuthorityTest {
|
|||||||
* Test helper method that decrypts a blob using a shared key and IV using the specified.
|
* Test helper method that decrypts a blob using a shared key and IV using the specified.
|
||||||
* transformation.
|
* transformation.
|
||||||
*
|
*
|
||||||
* @param blob to be decrypted
|
* @param blob blob to be decrypted
|
||||||
* @param key shared key
|
* @param key shared key
|
||||||
* @param iv to decrypt with
|
* @param iv to decrypt with
|
||||||
* @param transformation of the decryption cipher
|
* @param transformation of the decryption cipher
|
||||||
* @return decrypted blob
|
* @return decrypted blob
|
||||||
* @throws Exception
|
* @throws Exception if there are any issues while decrypting the blob
|
||||||
*/
|
*/
|
||||||
private byte[] decryptBlob(final byte[] blob, final byte[] key, final byte[] iv,
|
private byte[] decryptBlob(final byte[] blob, final byte[] key, final byte[] iv,
|
||||||
final String transformation) throws Exception {
|
final String transformation) throws Exception {
|
||||||
|
@ -172,14 +172,20 @@ public class TPM2ProvisionerStateTest {
|
|||||||
|
|
||||||
RANDOM_GENERATOR.nextBytes(nonce);
|
RANDOM_GENERATOR.nextBytes(nonce);
|
||||||
RANDOM_GENERATOR.nextBytes(identityClaim);
|
RANDOM_GENERATOR.nextBytes(identityClaim);
|
||||||
|
|
||||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(nonce));
|
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(nonce));
|
||||||
Long index = dis.readLong();
|
Long index = dis.readLong();
|
||||||
dis.close();
|
dis.close();
|
||||||
|
|
||||||
TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim);
|
TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim);
|
||||||
|
|
||||||
when(tpm2ProvisionerStateRepository.findByFirstPartOfNonce(index)).thenReturn(value);
|
when(tpm2ProvisionerStateRepository.findByFirstPartOfNonce(index)).thenReturn(value);
|
||||||
|
|
||||||
|
final int nonce2Size = 7;
|
||||||
TPM2ProvisionerState tpm2ProvisionerState =
|
TPM2ProvisionerState tpm2ProvisionerState =
|
||||||
TPM2ProvisionerState.getTPM2ProvisionerState(tpm2ProvisionerStateRepository, new byte[7]);
|
TPM2ProvisionerState.getTPM2ProvisionerState(tpm2ProvisionerStateRepository,
|
||||||
|
new byte[nonce2Size]);
|
||||||
|
|
||||||
assertNull(tpm2ProvisionerState);
|
assertNull(tpm2ProvisionerState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,18 +40,15 @@ public class AbstractUserdefinedEntityTest {
|
|||||||
* Location of a test (fake) SGI intermediate CA certificate.
|
* Location of a test (fake) SGI intermediate CA certificate.
|
||||||
*/
|
*/
|
||||||
public static final String FAKE_SGI_INT_CA_FILE = "/certificates/fakeSGIIntermediateCA.cer";
|
public static final String FAKE_SGI_INT_CA_FILE = "/certificates/fakeSGIIntermediateCA.cer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location of a test (fake) Intel intermediate CA certificate.
|
* Location of a test (fake) Intel intermediate CA certificate.
|
||||||
*/
|
*/
|
||||||
public static final String FAKE_INTEL_INT_CA_FILE =
|
public static final String FAKE_INTEL_INT_CA_FILE =
|
||||||
"/certificates/fakeIntelIntermediateCA.cer";
|
"/certificates/fakeIntelIntermediateCA.cer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Location of a test (fake) root CA certificate.
|
* Location of a test (fake) root CA certificate.
|
||||||
*/
|
*/
|
||||||
public static final String FAKE_ROOT_CA_FILE = "/certificates/fakeRootCA.cer";
|
public static final String FAKE_ROOT_CA_FILE = "/certificates/fakeRootCA.cer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hex-encoded subject key identifier for the FAKE_ROOT_CA_FILE.
|
* Hex-encoded subject key identifier for the FAKE_ROOT_CA_FILE.
|
||||||
*/
|
*/
|
||||||
@ -97,6 +94,12 @@ public class AbstractUserdefinedEntityTest {
|
|||||||
private static final String TEST_IDENTITY_CERT = "/tpm/sample_identity_cert.cer";
|
private static final String TEST_IDENTITY_CERT = "/tpm/sample_identity_cert.cer";
|
||||||
private static final Logger LOGGER = LogManager.getLogger(DeviceInfoReportTest.class);
|
private static final Logger LOGGER = LogManager.getLogger(DeviceInfoReportTest.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This protected constructor was created to silence one of checkstyle errors.
|
||||||
|
*/
|
||||||
|
protected AbstractUserdefinedEntityTest() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a test certificate from the given parameters.
|
* Construct a test certificate from the given parameters.
|
||||||
*
|
*
|
||||||
@ -121,13 +124,14 @@ public class AbstractUserdefinedEntityTest {
|
|||||||
* @param endorsementCredential the endorsement credentials (can be null)
|
* @param endorsementCredential the endorsement credentials (can be null)
|
||||||
* @param platformCredentials the platform credentials (can be null)
|
* @param platformCredentials the platform credentials (can be null)
|
||||||
* @return the newly-constructed Certificate
|
* @return the newly-constructed Certificate
|
||||||
* @throws IOException if there is a problem constructing the test certificate
|
* @throws IOException if there is a problem constructing the test certificate
|
||||||
|
* @throws IllegalArgumentException if there is a problem retrieving the certificate class simple name
|
||||||
*/
|
*/
|
||||||
public static <T extends ArchivableEntity> Certificate getTestCertificate(
|
public static <T extends ArchivableEntity> Certificate getTestCertificate(
|
||||||
final Class<T> certificateClass, final String filename,
|
final Class<T> certificateClass, final String filename,
|
||||||
final EndorsementCredential endorsementCredential,
|
final EndorsementCredential endorsementCredential,
|
||||||
final List<PlatformCredential> platformCredentials)
|
final List<PlatformCredential> platformCredentials)
|
||||||
throws IOException {
|
throws IOException, IllegalArgumentException {
|
||||||
|
|
||||||
Path certPath;
|
Path certPath;
|
||||||
try {
|
try {
|
||||||
@ -139,23 +143,17 @@ public class AbstractUserdefinedEntityTest {
|
|||||||
throw new IOException("Could not resolve path URI", e);
|
throw new IOException("Could not resolve path URI", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (certificateClass.getSimpleName()) {
|
return switch (certificateClass.getSimpleName()) {
|
||||||
case "CertificateAuthorityCredential":
|
case "CertificateAuthorityCredential" -> new CertificateAuthorityCredential(certPath);
|
||||||
return new CertificateAuthorityCredential(certPath);
|
case "ConformanceCredential" -> new ConformanceCredential(certPath);
|
||||||
case "ConformanceCredential":
|
case "EndorsementCredential" -> new EndorsementCredential(certPath);
|
||||||
return new ConformanceCredential(certPath);
|
case "PlatformCredential" -> new PlatformCredential(certPath);
|
||||||
case "EndorsementCredential":
|
case "IssuedAttestationCertificate" -> new IssuedAttestationCertificate(certPath,
|
||||||
return new EndorsementCredential(certPath);
|
endorsementCredential, platformCredentials, false);
|
||||||
case "PlatformCredential":
|
default -> throw new IllegalArgumentException(
|
||||||
return new PlatformCredential(certPath);
|
String.format("Unknown certificate class %s", certificateClass.getName())
|
||||||
case "IssuedAttestationCertificate":
|
);
|
||||||
return new IssuedAttestationCertificate(certPath,
|
};
|
||||||
endorsementCredential, platformCredentials, false);
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
String.format("Unknown certificate class %s", certificateClass.getName())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,8 +190,9 @@ public class AbstractUserdefinedEntityTest {
|
|||||||
public static NetworkInfo createTestNetworkInfo() {
|
public static NetworkInfo createTestNetworkInfo() {
|
||||||
try {
|
try {
|
||||||
final String hostname = "test.hostname";
|
final String hostname = "test.hostname";
|
||||||
|
final byte[] byteAddress = new byte[] {127, 0, 0, 1};
|
||||||
final InetAddress ipAddress =
|
final InetAddress ipAddress =
|
||||||
InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
|
InetAddress.getByAddress(byteAddress);
|
||||||
final byte[] macAddress = new byte[] {11, 22, 33, 44, 55, 66};
|
final byte[] macAddress = new byte[] {11, 22, 33, 44, 55, 66};
|
||||||
return new NetworkInfo(hostname, ipAddress, macAddress);
|
return new NetworkInfo(hostname, ipAddress, macAddress);
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import java.net.URISyntaxException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.security.NoSuchProviderException;
|
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.CertificateFactory;
|
import java.security.cert.CertificateFactory;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
@ -80,10 +79,12 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
|
|
||||||
private static final String RDN_COMMA_SEPARATED =
|
private static final String RDN_COMMA_SEPARATED =
|
||||||
"CN=STM TPM EK Intermediate CA 02, O=STMicroelectronics NV, C=CH";
|
"CN=STM TPM EK Intermediate CA 02, O=STMicroelectronics NV, C=CH";
|
||||||
|
|
||||||
private static final String RDN_MULTIVALUE =
|
private static final String RDN_MULTIVALUE =
|
||||||
"CN=Nuvoton TPM Root CA 2010+O=Nuvoton Technology Corporation+C=TW";
|
"CN=Nuvoton TPM Root CA 2010+O=Nuvoton Technology Corporation+C=TW";
|
||||||
|
|
||||||
private static final String RDN_COMMA_SEPARATED_ORGANIZATION = "STMicroelectronics NV";
|
private static final String RDN_COMMA_SEPARATED_ORGANIZATION = "STMicroelectronics NV";
|
||||||
|
|
||||||
private static final String RDN_MULTIVALUE_ORGANIZATION = "Nuvoton Technology Corporation";
|
private static final String RDN_MULTIVALUE_ORGANIZATION = "Nuvoton Technology Corporation";
|
||||||
|
|
||||||
private static final String EK_CERT_WITH_PADDED_BYTES =
|
private static final String EK_CERT_WITH_PADDED_BYTES =
|
||||||
@ -135,6 +136,7 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
FAKE_ROOT_CA_FILE)).toURI())
|
FAKE_ROOT_CA_FILE)).toURI())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"CN=Fake Root CA",
|
"CN=Fake Root CA",
|
||||||
certificate.getX509Certificate().getIssuerX500Principal().getName()
|
certificate.getX509Certificate().getIssuerX500Principal().getName()
|
||||||
@ -144,12 +146,11 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Ensure that a Certificate cannot be created from a null byte array.
|
* Ensure that a Certificate cannot be created from a null byte array.
|
||||||
*
|
*
|
||||||
* @throws IOException if the certificate could not be constructed properly
|
* @throws IllegalArgumentException if there is a problem de/serializing the certificate
|
||||||
* @throws CertificateException if there is a problem de/serializing the certificate
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testConstructCertFromNullByteArray()
|
public void testConstructCertFromNullByteArray()
|
||||||
throws IOException, CertificateException {
|
throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new CertificateAuthorityCredential((byte[]) null));
|
new CertificateAuthorityCredential((byte[]) null));
|
||||||
}
|
}
|
||||||
@ -157,12 +158,11 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Ensure that a Certificate cannot be created from an empty byte array.
|
* Ensure that a Certificate cannot be created from an empty byte array.
|
||||||
*
|
*
|
||||||
* @throws IOException if the certificate could not be constructed properly
|
* @throws IllegalArgumentException if there is a problem de/serializing the certificate
|
||||||
* @throws CertificateException if there is a problem de/serializing the certificate
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testConstructCertFromEmptyByteArray()
|
public void testConstructCertFromEmptyByteArray()
|
||||||
throws IOException, CertificateException {
|
throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new CertificateAuthorityCredential(new byte[] {}));
|
new CertificateAuthorityCredential(new byte[] {}));
|
||||||
}
|
}
|
||||||
@ -179,6 +179,7 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
Paths.get(Objects.requireNonNull(this.getClass().getResource(
|
Paths.get(Objects.requireNonNull(this.getClass().getResource(
|
||||||
FAKE_ROOT_CA_FILE)).toURI())
|
FAKE_ROOT_CA_FILE)).toURI())
|
||||||
);
|
);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"CN=Fake Root CA",
|
"CN=Fake Root CA",
|
||||||
certificate.getX509Certificate().getIssuerX500Principal().getName()
|
certificate.getX509Certificate().getIssuerX500Principal().getName()
|
||||||
@ -188,11 +189,10 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that a certificate cannot be constructed from a null path.
|
* Tests that a certificate cannot be constructed from a null path.
|
||||||
*
|
*
|
||||||
* @throws IOException if there is a problem reading the cert file at the given path
|
* @throws IllegalArgumentException if there is a problem constructing the URI
|
||||||
* @throws URISyntaxException if there is a problem constructing the URI
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testConstructCertFromNullPath() throws URISyntaxException, IOException {
|
public void testConstructCertFromNullPath() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new CertificateAuthorityCredential((Path) null));
|
new CertificateAuthorityCredential((Path) null));
|
||||||
}
|
}
|
||||||
@ -208,6 +208,7 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
assertEquals(
|
assertEquals(
|
||||||
Certificate.CertificateType.X509_CERTIFICATE,
|
Certificate.CertificateType.X509_CERTIFICATE,
|
||||||
getTestCertificate(FAKE_ROOT_CA_FILE).getCertificateType());
|
getTestCertificate(FAKE_ROOT_CA_FILE).getCertificateType());
|
||||||
|
|
||||||
assertNotEquals(
|
assertNotEquals(
|
||||||
Certificate.CertificateType.ATTRIBUTE_CERTIFICATE,
|
Certificate.CertificateType.ATTRIBUTE_CERTIFICATE,
|
||||||
getTestCertificate(FAKE_ROOT_CA_FILE).getCertificateType());
|
getTestCertificate(FAKE_ROOT_CA_FILE).getCertificateType());
|
||||||
@ -222,7 +223,6 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
getTestCertificate(
|
getTestCertificate(
|
||||||
PlatformCredential.class,
|
PlatformCredential.class,
|
||||||
TEST_PLATFORM_CERT_3).getCertificateType());
|
TEST_PLATFORM_CERT_3).getCertificateType());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -256,7 +256,6 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
"GETY42100160",
|
"GETY42100160",
|
||||||
((PlatformCredential) platformCredential).getPlatformSerial()
|
((PlatformCredential) platformCredential).getPlatformSerial()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -289,6 +288,7 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testX509CertificateParsingExtended() throws IOException {
|
public void testX509CertificateParsingExtended() throws IOException {
|
||||||
Certificate rootCert = getTestCertificate(INTEL_INT_CA_FILE);
|
Certificate rootCert = getTestCertificate(INTEL_INT_CA_FILE);
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"https://trustedservices.intel.com/"
|
"https://trustedservices.intel.com/"
|
||||||
+ "content/TSC/certs/TSC_SS_RootCA_Certificate.cer\n",
|
+ "content/TSC/certs/TSC_SS_RootCA_Certificate.cer\n",
|
||||||
@ -336,12 +336,11 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
* Tests that Certificate correctly parses out non-standard fields from an X509 attribute
|
* Tests that Certificate correctly parses out non-standard fields from an X509 attribute
|
||||||
* certificate.
|
* certificate.
|
||||||
*
|
*
|
||||||
* @throws IOException if there is a problem reading the cert file at the given path
|
* @throws IOException if there is a problem reading the cert file at the given path
|
||||||
* @throws URISyntaxException if there is a problem constructing the file's URI
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testX509AttributeCertificateParsingExtended()
|
public void testX509AttributeCertificateParsingExtended()
|
||||||
throws IOException, URISyntaxException {
|
throws IOException {
|
||||||
Certificate platformCert = getTestCertificate(
|
Certificate platformCert = getTestCertificate(
|
||||||
PlatformCredential.class, TEST_PLATFORM_CERT_6);
|
PlatformCredential.class, TEST_PLATFORM_CERT_6);
|
||||||
|
|
||||||
@ -362,7 +361,10 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
public void testCertificateTrim() throws IOException, URISyntaxException {
|
public void testCertificateTrim() throws IOException, URISyntaxException {
|
||||||
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
||||||
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
||||||
byte[] expectedCertBytes = Arrays.copyOfRange(rawFileBytes, 0, 908);
|
|
||||||
|
final int finalPosition = 908;
|
||||||
|
byte[] expectedCertBytes = Arrays.copyOfRange(rawFileBytes, 0, finalPosition);
|
||||||
|
|
||||||
Certificate ekCert = getTestCertificate(EndorsementCredential.class,
|
Certificate ekCert = getTestCertificate(EndorsementCredential.class,
|
||||||
EK_CERT_WITH_PADDED_BYTES);
|
EK_CERT_WITH_PADDED_BYTES);
|
||||||
assertEquals(new BigInteger("16842032579184247954"), ekCert.getSerialNumber());
|
assertEquals(new BigInteger("16842032579184247954"), ekCert.getSerialNumber());
|
||||||
@ -384,6 +386,7 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
URISyntaxException {
|
URISyntaxException {
|
||||||
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
||||||
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new EndorsementCredential(Arrays.copyOfRange(rawFileBytes, 0, 2)),
|
new EndorsementCredential(Arrays.copyOfRange(rawFileBytes, 0, 2)),
|
||||||
".* No certificate length field could be found\\.");
|
".* No certificate length field could be found\\.");
|
||||||
@ -401,8 +404,10 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
URISyntaxException {
|
URISyntaxException {
|
||||||
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
||||||
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
||||||
|
|
||||||
|
final int finalPosition = 4;
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new EndorsementCredential(Arrays.copyOfRange(rawFileBytes, 0, 4)),
|
new EndorsementCredential(Arrays.copyOfRange(rawFileBytes, 0, finalPosition)),
|
||||||
".* Certificate is nothing more than ASN.1 Sequence\\\\.");
|
".* Certificate is nothing more than ASN.1 Sequence\\\\.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,8 +423,10 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
URISyntaxException {
|
URISyntaxException {
|
||||||
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
byte[] rawFileBytes = Files.readAllBytes(Paths.get(Objects.requireNonNull(CertificateTest.class
|
||||||
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
.getResource(EK_CERT_WITH_PADDED_BYTES)).toURI()));
|
||||||
|
|
||||||
|
final int finalPosition = 42;
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new EndorsementCredential(Arrays.copyOfRange(rawFileBytes, 0, 42)),
|
new EndorsementCredential(Arrays.copyOfRange(rawFileBytes, 0, finalPosition)),
|
||||||
".* Value of certificate length field extends beyond"
|
".* Value of certificate length field extends beyond"
|
||||||
+ " length of provided certificate\\.");
|
+ " length of provided certificate\\.");
|
||||||
}
|
}
|
||||||
@ -427,13 +434,11 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that the equals method on {@link Certificate} works as expected.
|
* Tests that the equals method on {@link Certificate} works as expected.
|
||||||
*
|
*
|
||||||
* @throws IOException if the certificate could not be constructed properly
|
* @throws IOException if the certificate could not be constructed properly
|
||||||
* @throws CertificateException if there is a problem with the KeyStore or de/serializing the
|
* @throws URISyntaxException if there is a problem constructing the path to the certificate
|
||||||
* certificate
|
|
||||||
* @throws URISyntaxException if there is a problem constructing the path to the certificate
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() throws CertificateException, IOException, URISyntaxException {
|
public void testEquals() throws IOException, URISyntaxException {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
getTestCertificate(FAKE_ROOT_CA_FILE),
|
getTestCertificate(FAKE_ROOT_CA_FILE),
|
||||||
getTestCertificate(FAKE_ROOT_CA_FILE)
|
getTestCertificate(FAKE_ROOT_CA_FILE)
|
||||||
@ -471,15 +476,10 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that the isIssuer method on {@link Certificate} works as expected.
|
* Tests that the isIssuer method on {@link Certificate} works as expected.
|
||||||
*
|
*
|
||||||
* @throws IOException if the certificate could not be constructed properly
|
* @throws IOException if the certificate could not be constructed properly
|
||||||
* @throws CertificateException if there is a problem with the KeyStore or de/serializing the
|
|
||||||
* certificate
|
|
||||||
* @throws NoSuchProviderException if the Bouncy Castle security provider is unavailable
|
|
||||||
* @throws URISyntaxException if there is a problem constructing the path to the certificate
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIsIssuer() throws CertificateException, IOException, NoSuchProviderException,
|
public void testIsIssuer() throws IOException {
|
||||||
URISyntaxException {
|
|
||||||
Certificate issuerCert = getTestCertificate(FAKE_ROOT_CA_FILE);
|
Certificate issuerCert = getTestCertificate(FAKE_ROOT_CA_FILE);
|
||||||
Certificate cert = getTestCertificate(INT_CA_CERT02);
|
Certificate cert = getTestCertificate(INT_CA_CERT02);
|
||||||
|
|
||||||
@ -490,13 +490,11 @@ public class CertificateTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that the hashCode method on {@link Certificate} works as expected.
|
* Tests that the hashCode method on {@link Certificate} works as expected.
|
||||||
*
|
*
|
||||||
* @throws IOException if the certificate could not be constructed properly
|
* @throws IOException if the certificate could not be constructed properly
|
||||||
* @throws CertificateException if there is a problem with the KeyStore or de/serializing the
|
* @throws URISyntaxException if there is a problem constructing the path to the certificate
|
||||||
* certificate
|
|
||||||
* @throws URISyntaxException if there is a problem constructing the path to the certificate
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testHashCode() throws CertificateException, IOException, URISyntaxException {
|
public void testHashCode() throws IOException, URISyntaxException {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
getTestCertificate(FAKE_ROOT_CA_FILE).hashCode(),
|
getTestCertificate(FAKE_ROOT_CA_FILE).hashCode(),
|
||||||
getTestCertificate(FAKE_ROOT_CA_FILE).hashCode()
|
getTestCertificate(FAKE_ROOT_CA_FILE).hashCode()
|
||||||
|
@ -20,7 +20,7 @@ class SupplyChainValidationTest extends AbstractUserdefinedEntityTest {
|
|||||||
* multiple test certificates.
|
* multiple test certificates.
|
||||||
*
|
*
|
||||||
* @return the test SupplyChainValidation
|
* @return the test SupplyChainValidation
|
||||||
* @throws IOException if there si
|
* @throws IOException if there is a problem deserializing certificates
|
||||||
*/
|
*/
|
||||||
public static SupplyChainValidation getTestSupplyChainValidation() throws IOException {
|
public static SupplyChainValidation getTestSupplyChainValidation() throws IOException {
|
||||||
return getTestSupplyChainValidation(
|
return getTestSupplyChainValidation(
|
||||||
@ -52,10 +52,10 @@ class SupplyChainValidationTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Test that a SupplyChainValidation can't be instantiated with a null validation type.
|
* Test that a SupplyChainValidation can't be instantiated with a null validation type.
|
||||||
*
|
*
|
||||||
* @throws IOException if there is a problem deserializing certificates
|
* @throws IllegalArgumentException if there is a problem deserializing certificates
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testNullValidationType() throws IOException {
|
public void testNullValidationType() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new SupplyChainValidation(
|
new SupplyChainValidation(
|
||||||
null,
|
null,
|
||||||
@ -68,10 +68,10 @@ class SupplyChainValidationTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Test that a SupplyChainValidation can't be instantiated with a null certificate list.
|
* Test that a SupplyChainValidation can't be instantiated with a null certificate list.
|
||||||
*
|
*
|
||||||
* @throws IOException if there is a problem deserializing certificates
|
* @throws IllegalArgumentException if there is a problem deserializing certificates
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testNullCertificates() throws IOException {
|
public void testNullCertificates() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new SupplyChainValidation(
|
new SupplyChainValidation(
|
||||||
SupplyChainValidation.ValidationType.ENDORSEMENT_CREDENTIAL,
|
SupplyChainValidation.ValidationType.ENDORSEMENT_CREDENTIAL,
|
||||||
|
@ -153,7 +153,7 @@ public class PlatformCredentialTest extends AbstractUserdefinedEntityTest {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
new PlatformCredential(certPath);
|
new PlatformCredential(certPath);
|
||||||
//fail if it manage to parse the certificate
|
//fail if it manages to parse the certificate
|
||||||
fail("Invalid certificate was parsed.");
|
fail("Invalid certificate was parsed.");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
if (ex == null || ex.getMessage().isEmpty()) {
|
if (ex == null || ex.getMessage().isEmpty()) {
|
||||||
@ -194,8 +194,7 @@ public class PlatformCredentialTest extends AbstractUserdefinedEntityTest {
|
|||||||
Assertions.assertEquals(sigStr.toUpperCase(), EXPECTED_CERT_SIGNATURE_FOR_CERT_2);
|
Assertions.assertEquals(sigStr.toUpperCase(), EXPECTED_CERT_SIGNATURE_FOR_CERT_2);
|
||||||
|
|
||||||
String issuer = Certificate.getAttributeCertificateIssuerNames(
|
String issuer = Certificate.getAttributeCertificateIssuerNames(
|
||||||
credential.getAttributeCertificate().getAcinfo().getIssuer()
|
credential.getAttributeCertificate().getAcinfo().getIssuer())[0].toString();
|
||||||
)[0].toString();
|
|
||||||
|
|
||||||
Assertions.assertEquals(credential.getManufacturer(), "Intel");
|
Assertions.assertEquals(credential.getManufacturer(), "Intel");
|
||||||
Assertions.assertEquals(credential.getModel(), "DE3815TYKH");
|
Assertions.assertEquals(credential.getModel(), "DE3815TYKH");
|
||||||
|
@ -19,14 +19,19 @@ public class TPMSecurityAssertionsTest {
|
|||||||
public void testEkGenTypeEnum() {
|
public void testEkGenTypeEnum() {
|
||||||
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[0],
|
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[0],
|
||||||
TPMSecurityAssertions.EkGenerationType.INTERNAL);
|
TPMSecurityAssertions.EkGenerationType.INTERNAL);
|
||||||
|
|
||||||
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[1],
|
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[1],
|
||||||
TPMSecurityAssertions.EkGenerationType.INJECTED);
|
TPMSecurityAssertions.EkGenerationType.INJECTED);
|
||||||
|
|
||||||
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[2],
|
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[2],
|
||||||
TPMSecurityAssertions.EkGenerationType.INTERNAL_REVOCABLE);
|
TPMSecurityAssertions.EkGenerationType.INTERNAL_REVOCABLE);
|
||||||
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[3],
|
|
||||||
|
final int thirdPosition = 3;
|
||||||
|
assertEquals(TPMSecurityAssertions.EkGenerationType.values()[thirdPosition],
|
||||||
TPMSecurityAssertions.EkGenerationType.INJECTED_REVOCABLE);
|
TPMSecurityAssertions.EkGenerationType.INJECTED_REVOCABLE);
|
||||||
try {
|
try {
|
||||||
assertNull(TPMSecurityAssertions.EkGenerationType.values()[4]);
|
final int positionOutOfBounds = 4;
|
||||||
|
assertNull(TPMSecurityAssertions.EkGenerationType.values()[positionOutOfBounds]);
|
||||||
fail();
|
fail();
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
}
|
}
|
||||||
@ -40,12 +45,15 @@ public class TPMSecurityAssertionsTest {
|
|||||||
public void testGenLocationEnum() {
|
public void testGenLocationEnum() {
|
||||||
assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[0],
|
assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[0],
|
||||||
TPMSecurityAssertions.EkGenerationLocation.TPM_MANUFACTURER);
|
TPMSecurityAssertions.EkGenerationLocation.TPM_MANUFACTURER);
|
||||||
|
|
||||||
assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[1],
|
assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[1],
|
||||||
TPMSecurityAssertions.EkGenerationLocation.PLATFORM_MANUFACTURER);
|
TPMSecurityAssertions.EkGenerationLocation.PLATFORM_MANUFACTURER);
|
||||||
|
|
||||||
assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[2],
|
assertEquals(TPMSecurityAssertions.EkGenerationLocation.values()[2],
|
||||||
TPMSecurityAssertions.EkGenerationLocation.EK_CERT_SIGNER);
|
TPMSecurityAssertions.EkGenerationLocation.EK_CERT_SIGNER);
|
||||||
try {
|
try {
|
||||||
assertNull(TPMSecurityAssertions.EkGenerationLocation.values()[3]);
|
final int positionOutOfBounds = 3;
|
||||||
|
assertNull(TPMSecurityAssertions.EkGenerationLocation.values()[positionOutOfBounds]);
|
||||||
fail();
|
fail();
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,19 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||||||
public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
||||||
|
|
||||||
private static final String TPM_MAKE = "test tpmMake";
|
private static final String TPM_MAKE = "test tpmMake";
|
||||||
private static final String LONG_TPM_MAKE = StringUtils.rightPad("test tpmMake", 65);
|
|
||||||
|
private static final int RIGHT_PADDING_SIZE = 65;
|
||||||
|
private static final String LONG_TPM_MAKE = StringUtils.rightPad("test tpmMake", RIGHT_PADDING_SIZE);
|
||||||
|
|
||||||
private static final short VERSION_MAJOR = 1;
|
private static final short VERSION_MAJOR = 1;
|
||||||
|
|
||||||
private static final short VERSION_MINOR = 2;
|
private static final short VERSION_MINOR = 2;
|
||||||
|
|
||||||
private static final short VERSION_REV_MAJOR = 3;
|
private static final short VERSION_REV_MAJOR = 3;
|
||||||
|
|
||||||
private static final short VERSION_REV_MINOR = 4;
|
private static final short VERSION_REV_MINOR = 4;
|
||||||
private static final Logger LOGGER = LogManager
|
|
||||||
.getLogger(TPMInfoTest.class);
|
private static final Logger LOGGER = LogManager.getLogger(TPMInfoTest.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests instantiation and getters of a TPMInfo object.
|
* Tests instantiation and getters of a TPMInfo object.
|
||||||
@ -59,9 +64,11 @@ public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the TPM make information cannot be null.
|
* Tests that the TPM make information cannot be null.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if one of the provided parameters is an illegal/invalid value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void tpmMakeNullTest() {
|
public final void tpmMakeNullTest() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new TPMInfo(null, VERSION_MAJOR, VERSION_MINOR, VERSION_REV_MAJOR,
|
new TPMInfo(null, VERSION_MAJOR, VERSION_MINOR, VERSION_REV_MAJOR,
|
||||||
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
||||||
@ -69,9 +76,11 @@ public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the TPM make information cannot be longer than 64 characters.
|
* Tests that the TPM make information cannot be longer than 64 characters.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if one of the provided parameters is an illegal/invalid value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void tpmMakeLongTest() {
|
public final void tpmMakeLongTest() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new TPMInfo(LONG_TPM_MAKE, VERSION_MAJOR, VERSION_MINOR, VERSION_REV_MAJOR,
|
new TPMInfo(LONG_TPM_MAKE, VERSION_MAJOR, VERSION_MINOR, VERSION_REV_MAJOR,
|
||||||
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
||||||
@ -80,9 +89,11 @@ public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that the version major number info cannot be set to negative
|
* Tests that the version major number info cannot be set to negative
|
||||||
* values.
|
* values.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if one of the provided parameters is an illegal/invalid value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testTPMInfoInvalidVersionMajor() {
|
public final void testTPMInfoInvalidVersionMajor() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new TPMInfo(TPM_MAKE, (short) -1, VERSION_MINOR, VERSION_REV_MAJOR,
|
new TPMInfo(TPM_MAKE, (short) -1, VERSION_MINOR, VERSION_REV_MAJOR,
|
||||||
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
||||||
@ -91,9 +102,11 @@ public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that the version minor number info cannot be set to negative
|
* Tests that the version minor number info cannot be set to negative
|
||||||
* values.
|
* values.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if one of the provided parameters is an illegal/invalid value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testTPMInfoInvalidVersionMinor() {
|
public final void testTPMInfoInvalidVersionMinor() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new TPMInfo(TPM_MAKE, VERSION_MAJOR, (short) -1, VERSION_REV_MAJOR,
|
new TPMInfo(TPM_MAKE, VERSION_MAJOR, (short) -1, VERSION_REV_MAJOR,
|
||||||
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
||||||
@ -102,9 +115,11 @@ public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that the version revision major numbers cannot be set to negative
|
* Tests that the version revision major numbers cannot be set to negative
|
||||||
* values.
|
* values.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if one of the provided parameters is an illegal/invalid value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testTPMInfoInvalidVersionRevMajor() {
|
public final void testTPMInfoInvalidVersionRevMajor() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new TPMInfo(TPM_MAKE, VERSION_MAJOR, VERSION_MINOR, (short) -1,
|
new TPMInfo(TPM_MAKE, VERSION_MAJOR, VERSION_MINOR, (short) -1,
|
||||||
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
VERSION_REV_MINOR, getTestIdentityCertificate()));
|
||||||
@ -113,9 +128,11 @@ public class TPMInfoTest extends AbstractUserdefinedEntityTest {
|
|||||||
/**
|
/**
|
||||||
* Tests that the version revision minor numbers cannot be set to negative
|
* Tests that the version revision minor numbers cannot be set to negative
|
||||||
* values.
|
* values.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException if one of the provided parameters is an illegal/invalid value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testTPMInfoInvalidVersionRevMinor() {
|
public final void testTPMInfoInvalidVersionRevMinor() throws IllegalArgumentException {
|
||||||
assertThrows(IllegalArgumentException.class, () ->
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
new TPMInfo(TPM_MAKE, VERSION_MAJOR, VERSION_MINOR, VERSION_REV_MAJOR,
|
new TPMInfo(TPM_MAKE, VERSION_MAJOR, VERSION_MINOR, VERSION_REV_MAJOR,
|
||||||
(short) -1, getTestIdentityCertificate()));
|
(short) -1, getTestIdentityCertificate()));
|
||||||
|
@ -99,70 +99,114 @@ public class SupplyChainCredentialValidatorTest {
|
|||||||
* SecureRandom instance.
|
* SecureRandom instance.
|
||||||
*/
|
*/
|
||||||
static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||||
|
|
||||||
private static final String JSON_FILE = "/config/component-class.json";
|
private static final String JSON_FILE = "/config/component-class.json";
|
||||||
|
|
||||||
private static final String SAMPLE_PACCOR_OUTPUT_TXT = "/hirs/validation/sample_paccor_output.txt";
|
private static final String SAMPLE_PACCOR_OUTPUT_TXT = "/hirs/validation/sample_paccor_output.txt";
|
||||||
|
|
||||||
private static final String SAMPLE_PACCOR_OUTPUT_NOT_SPECIFIED_TXT
|
private static final String SAMPLE_PACCOR_OUTPUT_NOT_SPECIFIED_TXT
|
||||||
= "/hirs/validation/sample_paccor_output_not_specified_values.txt";
|
= "/hirs/validation/sample_paccor_output_not_specified_values.txt";
|
||||||
|
|
||||||
private static final String SAMPLE_TEST_PACCOR_CERT
|
private static final String SAMPLE_TEST_PACCOR_CERT
|
||||||
= "/validation/platform_credentials_2/paccor_platform_cert.crt";
|
= "/validation/platform_credentials_2/paccor_platform_cert.crt";
|
||||||
|
|
||||||
private static final String SAMPLE_PACCOR_OUTPUT_WITH_EXTRA_COMPONENT_TXT
|
private static final String SAMPLE_PACCOR_OUTPUT_WITH_EXTRA_COMPONENT_TXT
|
||||||
= "/hirs/validation/sample_paccor_output_with_extra_component.txt";
|
= "/hirs/validation/sample_paccor_output_with_extra_component.txt";
|
||||||
|
|
||||||
private static final String TEST_SIGNING_KEY = "/validation/platform_credentials/ca.pub";
|
private static final String TEST_SIGNING_KEY = "/validation/platform_credentials/ca.pub";
|
||||||
|
|
||||||
private static final String TEST_PLATFORM_CRED =
|
private static final String TEST_PLATFORM_CRED =
|
||||||
"/validation/platform_credentials/plat_cert1.pem";
|
"/validation/platform_credentials/plat_cert1.pem";
|
||||||
|
|
||||||
private static final String TEST_PLATFORM_CRED2 =
|
private static final String TEST_PLATFORM_CRED2 =
|
||||||
"/validation/platform_credentials/pciids_plat_cert_2-0.pem";
|
"/validation/platform_credentials/pciids_plat_cert_2-0.pem";
|
||||||
|
|
||||||
private static final String TEST_PLATFORM_CRED_BASE_CHASIS_COMBO =
|
private static final String TEST_PLATFORM_CRED_BASE_CHASIS_COMBO =
|
||||||
"/validation/platform_credentials/Intel_pc5.pem";
|
"/validation/platform_credentials/Intel_pc5.pem";
|
||||||
|
|
||||||
private static final String TEST_BOARD_SERIAL_NUMBER = "GETY421001GV";
|
private static final String TEST_BOARD_SERIAL_NUMBER = "GETY421001GV";
|
||||||
|
|
||||||
private static final String TEST_CHASSIS_SERIAL_NUMBER = "G6YK42300C87";
|
private static final String TEST_CHASSIS_SERIAL_NUMBER = "G6YK42300C87";
|
||||||
|
|
||||||
private static final String TEST_EK_CERT = "/certificates/nuc-2/tpmcert.pem";
|
private static final String TEST_EK_CERT = "/certificates/nuc-2/tpmcert.pem";
|
||||||
|
|
||||||
private static final String TEST_EK_CERT_2 = "/certificates/nuc-1/tpmcert.pem";
|
private static final String TEST_EK_CERT_2 = "/certificates/nuc-1/tpmcert.pem";
|
||||||
|
|
||||||
private static final String TEST_COMPONENT_MANUFACTURER = "Intel";
|
private static final String TEST_COMPONENT_MANUFACTURER = "Intel";
|
||||||
|
|
||||||
private static final String TEST_COMPONENT_MODEL = "platform2018";
|
private static final String TEST_COMPONENT_MODEL = "platform2018";
|
||||||
|
|
||||||
private static final String TEST_COMPONENT_REVISION = "1.0";
|
private static final String TEST_COMPONENT_REVISION = "1.0";
|
||||||
|
|
||||||
private static final String BAD_SERIAL = "BAD_SERIAL";
|
private static final String BAD_SERIAL = "BAD_SERIAL";
|
||||||
|
|
||||||
//-------Actual ST Micro Endorsement Credential Certificate Chain!--------------
|
//-------Actual ST Micro Endorsement Credential Certificate Chain!--------------
|
||||||
private static final String EK_CERT = "";
|
private static final String EK_CERT = "";
|
||||||
|
|
||||||
private static final String INT_CA_CERT02 = "/certificates/fakestmtpmekint02.pem";
|
private static final String INT_CA_CERT02 = "/certificates/fakestmtpmekint02.pem";
|
||||||
|
|
||||||
//-------Generated Intel Credential Certificate Chain--------------
|
//-------Generated Intel Credential Certificate Chain--------------
|
||||||
private static final String INTEL_PLATFORM_CERT =
|
private static final String INTEL_PLATFORM_CERT =
|
||||||
"/validation/platform_credentials/plat_cert3.pem";
|
"/validation/platform_credentials/plat_cert3.pem";
|
||||||
|
|
||||||
private static final String INTEL_PLATFORM_CERT_2 =
|
private static final String INTEL_PLATFORM_CERT_2 =
|
||||||
"/validation/platform_credentials/Intel_pc2.pem";
|
"/validation/platform_credentials/Intel_pc2.pem";
|
||||||
|
|
||||||
private static final String INTEL_PLATFORM_CERT_3 =
|
private static final String INTEL_PLATFORM_CERT_3 =
|
||||||
"/validation/platform_credentials/pciids_plat_cert_2-0.pem";
|
"/validation/platform_credentials/pciids_plat_cert_2-0.pem";
|
||||||
|
|
||||||
private static final String INTEL_INT_CA =
|
private static final String INTEL_INT_CA =
|
||||||
"/validation/platform_credentials/intel_chain/root/intermediate1.crt";
|
"/validation/platform_credentials/intel_chain/root/intermediate1.crt";
|
||||||
|
|
||||||
private static final String FAKE_ROOT_CA =
|
private static final String FAKE_ROOT_CA =
|
||||||
"/validation/platform_credentials/intel_chain/root/rootca.crt";
|
"/validation/platform_credentials/intel_chain/root/rootca.crt";
|
||||||
|
|
||||||
private static final String PLATFORM_MANUFACTURER = "Intel";
|
private static final String PLATFORM_MANUFACTURER = "Intel";
|
||||||
|
|
||||||
private static final String PLATFORM_MODEL = "S2600KP";
|
private static final String PLATFORM_MODEL = "S2600KP";
|
||||||
|
|
||||||
private static final String PLATFORM_VERSION = "H76962-350";
|
private static final String PLATFORM_VERSION = "H76962-350";
|
||||||
|
|
||||||
//-------Original Intel Credential Certificate Chain--------------
|
//-------Original Intel Credential Certificate Chain--------------
|
||||||
private static final String INTEL_PLATFORM_CERT_ORIG =
|
private static final String INTEL_PLATFORM_CERT_ORIG =
|
||||||
"/certificates/fakeIntel_S2600KP_F00F00F00F00.pem";
|
"/certificates/fakeIntel_S2600KP_F00F00F00F00.pem";
|
||||||
|
|
||||||
private static final String INTEL_ORIG_INT_CA_ORIG =
|
private static final String INTEL_ORIG_INT_CA_ORIG =
|
||||||
"/certificates/fakeIntelIntermediateCA.pem";
|
"/certificates/fakeIntelIntermediateCA.pem";
|
||||||
|
|
||||||
private static final String FAKE_ROOT_CA_ORIG =
|
private static final String FAKE_ROOT_CA_ORIG =
|
||||||
"/certificates/fakeCA.pem";
|
"/certificates/fakeCA.pem";
|
||||||
|
|
||||||
//-------Fake SGI Credential Certificate Chain--------------
|
//-------Fake SGI Credential Certificate Chain--------------
|
||||||
private static final String SGI_PLATFORM_CERT = "/certificates/fakeSGI_J2_F00F00F0.pem";
|
private static final String SGI_PLATFORM_CERT = "/certificates/fakeSGI_J2_F00F00F0.pem";
|
||||||
|
|
||||||
private static final String SGI_INT_CA = "/certificates/fakeSGIIntermediateCA.pem";
|
private static final String SGI_INT_CA = "/certificates/fakeSGIIntermediateCA.pem";
|
||||||
|
|
||||||
private static final String SGI_CRED_SERIAL_NUMBER = "F00F00F0";
|
private static final String SGI_CRED_SERIAL_NUMBER = "F00F00F0";
|
||||||
|
|
||||||
//-------Actual Intel NUC Platform --------------
|
//-------Actual Intel NUC Platform --------------
|
||||||
|
|
||||||
private static final String NUC_PLATFORM_CERT =
|
private static final String NUC_PLATFORM_CERT =
|
||||||
"/certificates/Intel_nuc_pc.pem";
|
"/certificates/Intel_nuc_pc.pem";
|
||||||
|
|
||||||
private static final String NUC_PLATFORM_CERT_SERIAL_NUMBER = "GETY421001DY";
|
private static final String NUC_PLATFORM_CERT_SERIAL_NUMBER = "GETY421001DY";
|
||||||
|
|
||||||
private static final String NUC_PLATFORM_CERT2 =
|
private static final String NUC_PLATFORM_CERT2 =
|
||||||
"/certificates/Intel_nuc_pc2.pem";
|
"/certificates/Intel_nuc_pc2.pem";
|
||||||
|
|
||||||
private static final String NUC_PLATFORM_CERT_SERIAL_NUMBER2 = "GETY4210001M";
|
private static final String NUC_PLATFORM_CERT_SERIAL_NUMBER2 = "GETY4210001M";
|
||||||
|
|
||||||
private static final String INTEL_SIGNING_KEY = "/certificates/IntelSigningKey_20April2017.pem";
|
private static final String INTEL_SIGNING_KEY = "/certificates/IntelSigningKey_20April2017.pem";
|
||||||
|
|
||||||
private static final String NEW_NUC1 =
|
private static final String NEW_NUC1 =
|
||||||
"/validation/platform_credentials/Intel_pc3.cer";
|
"/validation/platform_credentials/Intel_pc3.cer";
|
||||||
|
|
||||||
private static HardwareInfo hardwareInfo;
|
private static HardwareInfo hardwareInfo;
|
||||||
|
|
||||||
private static KeyStore keyStore;
|
private static KeyStore keyStore;
|
||||||
|
|
||||||
private static KeyStore emptyKeyStore;
|
private static KeyStore emptyKeyStore;
|
||||||
|
|
||||||
private final SupplyChainCredentialValidator supplyChainCredentialValidator =
|
private final SupplyChainCredentialValidator supplyChainCredentialValidator =
|
||||||
new SupplyChainCredentialValidator();
|
new SupplyChainCredentialValidator();
|
||||||
private final CredentialValidator credentialValidator =
|
private final CredentialValidator credentialValidator =
|
||||||
@ -171,11 +215,14 @@ public class SupplyChainCredentialValidatorTest {
|
|||||||
/**
|
/**
|
||||||
* Sets up a KeyStore for testing.
|
* Sets up a KeyStore for testing.
|
||||||
*
|
*
|
||||||
* @throws KeyStoreException if no Provider supports a KeyStoreSpi implementation for the specified type.
|
* @throws KeyStoreException if no Provider supports a KeyStoreSpi implementation for the
|
||||||
* @throws NoSuchAlgorithmException if the algorithm used to check the integrity of the keystore cannot be found
|
* specified type.
|
||||||
|
* @throws NoSuchAlgorithmException if the algorithm used to check the integrity of the keystore
|
||||||
|
* cannot be found
|
||||||
* @throws CertificateException if any of the certificates in the keystore could not be loaded
|
* @throws CertificateException if any of the certificates in the keystore could not be loaded
|
||||||
* @throws IOException if there is an I/O or format problem with the keystore data, if a password is
|
* @throws IOException if there is an I/O or format problem with the keystore data,
|
||||||
* required but not given, or if the given password was incorrect
|
* if a password is required but not given,
|
||||||
|
* or if the given password was incorrect
|
||||||
*/
|
*/
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws KeyStoreException, NoSuchAlgorithmException,
|
public static void setUp() throws KeyStoreException, NoSuchAlgorithmException,
|
||||||
@ -362,7 +409,8 @@ public class SupplyChainCredentialValidatorTest {
|
|||||||
|
|
||||||
private static InetAddress getTestIpAddress() {
|
private static InetAddress getTestIpAddress() {
|
||||||
try {
|
try {
|
||||||
return InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
|
final byte[] byteAddress = new byte[] {127, 0, 0, 1};
|
||||||
|
return InetAddress.getByAddress(byteAddress);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,9 @@
|
|||||||
|
|
||||||
<!-- Checks for Size Violations. -->
|
<!-- Checks for Size Violations. -->
|
||||||
<!-- See https://checkstyle.org/checks/sizes/index.html -->
|
<!-- See https://checkstyle.org/checks/sizes/index.html -->
|
||||||
<module name="FileLength"/>
|
<module name="FileLength">
|
||||||
|
<property name="max" value="3000"/>
|
||||||
|
</module>
|
||||||
<module name="LineLength">
|
<module name="LineLength">
|
||||||
<property name="fileExtensions" value="java"/>
|
<property name="fileExtensions" value="java"/>
|
||||||
<property name="max" value="110"/>
|
<property name="max" value="110"/>
|
||||||
@ -134,7 +136,7 @@
|
|||||||
<!-- Checks for Size Violations. -->
|
<!-- Checks for Size Violations. -->
|
||||||
<!-- See https://checkstyle.org/checks/sizes/index.html -->
|
<!-- See https://checkstyle.org/checks/sizes/index.html -->
|
||||||
<module name="MethodLength">
|
<module name="MethodLength">
|
||||||
<property name="max" value="300"/>
|
<property name="max" value="350"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<!-- Checks for whitespace -->
|
<!-- Checks for whitespace -->
|
||||||
|
Loading…
Reference in New Issue
Block a user