Skip to content

Commit bbe2228

Browse files
issue_896: deleted abstract plat form config class, replaced it with plat config v1 (which already exists), moved attribuutes associated with v2 to the v2 class, when validating the aca will now verify if the platform config associated with the cert is v1 or v2. Made corrections to attributes names to better align with tcg docs.
1 parent 2f96fb0 commit bbe2228

File tree

20 files changed

+370
-344
lines changed

20 files changed

+370
-344
lines changed

Diff for: HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public class ComponentResult extends ArchivableEntity {
9898
*
9999
* @param boardSerialNumber associated platform certificate serial number.
100100
* @param certificateSerialNumber unique number associated with header info.
101-
* @param certificateType parameter holds version 1.2 or 2.0.
101+
* @param certificateType type of certificate. parameter holds version 1.2 or 2.0.
102102
* @param componentIdentifier object with information from the platform certificate components.
103103
*/
104104
public ComponentResult(final String boardSerialNumber, final String certificateSerialNumber,
@@ -116,18 +116,18 @@ public ComponentResult(final String boardSerialNumber, final String certificateS
116116
}
117117

118118
StringBuilder sb = new StringBuilder();
119-
for (ComponentAddress element : componentIdentifier.getComponentAddress()) {
119+
for (ComponentAddress element : componentIdentifier.getComponentAddresses()) {
120120
sb.append(String.format("%s:%s;", element.getAddressTypeValue(),
121121
element.getAddressValue().toString()));
122122
}
123123
componentAddress = sb.toString();
124124
}
125125

126126
/**
127-
* @param boardSerialNumber
128-
* @param certificateSerialNumber
129-
* @param certificateType
130-
* @param componentIdentifierV2
127+
* @param boardSerialNumber associated platform certificate serial number
128+
* @param certificateSerialNumber unique number associated with header info
129+
* @param certificateType type of certificate. Parameter holds version 1.2 or 2.0.
130+
* @param componentIdentifierV2 version 2 component identifier
131131
*/
132132
public ComponentResult(final String boardSerialNumber, final String certificateSerialNumber,
133133
final String certificateType,
@@ -145,7 +145,7 @@ public ComponentResult(final String boardSerialNumber, final String certificateS
145145
}
146146

147147
StringBuilder sb = new StringBuilder();
148-
for (ComponentAddress element : componentIdentifierV2.getComponentAddress()) {
148+
for (ComponentAddress element : componentIdentifierV2.getComponentAddresses()) {
149149
sb.append(String.format("%s:%s;", element.getAddressTypeValue(),
150150
element.getAddressValue().toString()));
151151
}
@@ -156,10 +156,10 @@ public ComponentResult(final String boardSerialNumber, final String certificateS
156156
this.componentClassType = componentIdentifierV2.getComponentClass().getRegistryType();
157157
this.attributeStatus = componentIdentifierV2.getAttributeStatus();
158158
this.version2 = true;
159-
if (componentIdentifierV2.getCertificateIdentifier() != null) {
160-
this.issuerDN = componentIdentifierV2.getCertificateIdentifier().getIssuerDN().toString();
161-
if (componentIdentifierV2.getComponentPlatformUri() != null) {
162-
this.uniformResourceIdentifier = componentIdentifierV2.getComponentPlatformUri()
159+
if (componentIdentifierV2.getComponentPlatformCert() != null) {
160+
this.issuerDN = componentIdentifierV2.getComponentPlatformCert().getIssuerDN().toString();
161+
if (componentIdentifierV2.getComponentPlatformCertUri() != null) {
162+
this.uniformResourceIdentifier = componentIdentifierV2.getComponentPlatformCertUri()
163163
.getUniformResourceIdentifier().toString();
164164
}
165165
}

Diff for: HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredential.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.google.common.base.Preconditions;
44
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentIdentifier;
5-
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.PlatformConfiguration;
65
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.PlatformConfigurationV1;
76
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.TBBSecurityAssertion;
87
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.URIReference;
@@ -261,8 +260,8 @@ public static PlatformCredential parseWithPossibleHeader(final byte[] certificat
261260
/**
262261
* Verify if the AlgorithmIdentifiers are equal.
263262
*
264-
* @param id1 AlgorithIdentifier one
265-
* @param id2 AlgorithIdentifier two
263+
* @param id1 Algorithm Identifier one
264+
* @param id2 Algorithm Identifier two
266265
* @return True if are the same, False if not
267266
*/
268267
public static boolean isAlgIdEqual(final AlgorithmIdentifier id1,
@@ -356,7 +355,7 @@ public boolean isSignatureValid(final ContentVerifierProvider verifierProvider)
356355
}
357356

358357
/**
359-
* @throws IOException
358+
* Parses the Platform Certificate fields.
360359
*/
361360
private void parseFields() throws IOException {
362361
AttributeCertificateInfo certificate = getAttributeCertificate().getAcinfo();
@@ -412,7 +411,7 @@ private void parseFields() throws IOException {
412411
}
413412

414413
/**
415-
* Parse a 1.2 Platform Certificate (Attribute Certificate).
414+
* Parses a 1.2 Platform Certificate (Attribute Certificate).
416415
*
417416
* @param certificate Attribute Certificate
418417
*/
@@ -465,7 +464,7 @@ private void parseAttributeCert(final AttributeCertificateInfo certificate) {
465464
}
466465

467466
/**
468-
* Parse a 2.0 Platform Certificate (Attribute Certificate).
467+
* Parses a 2.0 Platform Certificate (Attribute Certificate).
469468
*
470469
* @param certificate Attribute Certificate
471470
*/
@@ -514,7 +513,7 @@ private void parseAttributeCert2(final AttributeCertificateInfo certificate)
514513
}
515514

516515
/**
517-
* Get the x509 Platform Certificate version.
516+
* Retrieves the x509 Platform Certificate version.
518517
*
519518
* @return a big integer representing the certificate version.
520519
*/
@@ -533,7 +532,7 @@ public int getX509CredentialVersion() {
533532
}
534533

535534
/**
536-
* Get the cPSuri from the Certificate Policies.
535+
* Retrieves the cPSuri from the Certificate Policies.
537536
*
538537
* @return cPSuri from the CertificatePolicies.
539538
* @throws IOException when reading the certificate.
@@ -549,7 +548,7 @@ public String getCPSuri() throws IOException {
549548
}
550549

551550
/**
552-
* Get the Platform Configuration Attribute from the Platform Certificate.
551+
* Retrieves the Platform Configuration Attribute from the Platform Certificate.
553552
*
554553
* @return a map with all the attributes
555554
* @throws IllegalArgumentException when there is a parsing error
@@ -618,12 +617,12 @@ public Object getAttribute(final String attributeName)
618617
* @throws IllegalArgumentException when there is a parsing error
619618
* @throws IOException when reading the certificate.
620619
*/
621-
public PlatformConfiguration getPlatformConfiguration()
620+
public PlatformConfigurationV1 getPlatformConfigurationV1()
622621
throws IllegalArgumentException, IOException {
623622

624623
if (getAttribute("platformConfiguration") != null
625-
&& getAttribute("platformConfiguration") instanceof PlatformConfiguration) {
626-
return (PlatformConfiguration) getAttribute("platformConfiguration");
624+
&& getAttribute("platformConfiguration") instanceof PlatformConfigurationV1) {
625+
return (PlatformConfigurationV1) getAttribute("platformConfiguration");
627626
}
628627

629628
return null;
@@ -710,15 +709,15 @@ private void getTCGCredentialSpecification(final ASN1Sequence attributeSequence)
710709
}
711710

712711
/**
713-
* Get the list of component identifiers if there are any.
712+
* Retrieves the list of component identifiers if there are any.
714713
*
715714
* @return the list of component identifiers if there are any
716715
*/
717716
public List<ComponentIdentifier> getComponentIdentifiers() {
718717
try {
719-
PlatformConfiguration platformConfig = getPlatformConfiguration();
718+
PlatformConfigurationV1 platformConfig = getPlatformConfigurationV1();
720719
if (platformConfig != null) {
721-
return platformConfig.getComponentIdentifier();
720+
return platformConfig.getComponentIdentifiers();
722721
}
723722
} catch (IOException e) {
724723
log.error("Unable to parse Platform Configuration from Platform Credential or find"
@@ -728,15 +727,16 @@ public List<ComponentIdentifier> getComponentIdentifiers() {
728727
}
729728

730729
/**
731-
* Get the list of version 2 component identifiers if there are any.
730+
* Retrieves the list of version 2 component identifiers if there are any.
732731
*
733732
* @return the list of version 2 component identifiers if there are any
734733
*/
735734
public List<ComponentIdentifierV2> getComponentIdentifiersV2() {
736735
try {
737736
PlatformConfigurationV2 platformConfigV2 = getPlatformConfigurationV2();
737+
738738
if (platformConfigV2 != null) {
739-
return platformConfigV2.getComponentIdentifierV2();
739+
return platformConfigV2.getComponentIdentifiers();
740740
}
741741
} catch (IOException e) {
742742
log.error("Unable to parse Platform Configuration Version 2 from Platform Credential or find"

Diff for: HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAddress.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import org.bouncycastle.asn1.ASN1UTF8String;
99

1010
/**
11-
* Basic class that handle component addresses from the component identifier.
11+
* Basic class that represents the component addresses from the component identifier object.
1212
* <pre>
13-
* componentAddress ::= SEQUENCE {
13+
* componentAddresses ::= SEQUENCE {
1414
* addressType AddressType,
1515
* addressValue UTF8String (SIZE (1..STRMAX)) }
1616
* where STRMAX is 256

Diff for: HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentIdentifier.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import java.util.stream.Collectors;
1717

1818
/**
19-
* Basic class that handle component identifiers from the Platform Configuration
20-
* Attribute.
19+
* Basic class that represents version 1 of the component identifiers from the Version 1
20+
* Platform Configuration Attribute.
2121
* <pre>
2222
* ComponentIdentifier ::= SEQUENCE {
2323
* componentManufacturer UTF8String (SIZE (1..STRMAX)),
@@ -26,7 +26,7 @@
2626
* componentRevision [1] IMPLICIT UTF8String (SIZE (1..STRMAX)) OPTIONAL,
2727
* componentManufacturerId [2] IMPLICIT PrivateEnterpriseNumber OPTIONAL,
2828
* fieldReplaceable [3] IMPLICIT BOOLEAN OPTIONAL,
29-
* componentAddress [4] IMPLICIT
29+
* componentAddresses [4] IMPLICIT
3030
* SEQUENCE(SIZE(1..CONFIGMAX)) OF ComponentAddress OPTIONAL}
3131
* where STRMAX is 256, CONFIGMAX is 32
3232
* </pre>
@@ -80,7 +80,7 @@ public class ComponentIdentifier {
8080

8181
private ASN1Boolean fieldReplaceable;
8282

83-
private List<ComponentAddress> componentAddress;
83+
private List<ComponentAddress> componentAddresses;
8484

8585
private boolean validationResult = true;
8686

@@ -94,7 +94,7 @@ public ComponentIdentifier() {
9494
componentRevision = new DERUTF8String(NOT_SPECIFIED_COMPONENT);
9595
componentManufacturerId = null;
9696
fieldReplaceable = null;
97-
componentAddress = new ArrayList<>();
97+
componentAddresses = new ArrayList<>();
9898
}
9999

100100
/**
@@ -121,7 +121,7 @@ public ComponentIdentifier(final DERUTF8String componentManufacturer,
121121
this.componentRevision = componentRevision;
122122
this.componentManufacturerId = componentManufacturerId;
123123
this.fieldReplaceable = fieldReplaceable;
124-
this.componentAddress = componentAddress.stream().toList();
124+
this.componentAddresses = componentAddress.stream().toList();
125125
}
126126

127127
/**
@@ -160,7 +160,7 @@ public ComponentIdentifier(final ASN1Sequence sequence) throws IllegalArgumentEx
160160
break;
161161
case COMPONENT_ADDRESS:
162162
ASN1Sequence addressesSequence = ASN1Sequence.getInstance(taggedObj, false);
163-
componentAddress = retrieveComponentAddress(addressesSequence);
163+
componentAddresses = retrieveComponentAddress(addressesSequence);
164164
break;
165165
default:
166166
throw new IllegalArgumentException("Component identifier contains "
@@ -229,14 +229,14 @@ public String toString() {
229229
if (fieldReplaceable != null) {
230230
sb.append(fieldReplaceable);
231231
}
232-
sb.append(", componentAddress=");
233-
if (!componentAddress.isEmpty()) {
234-
sb.append(componentAddress
232+
sb.append(", componentAddresses=");
233+
if (!componentAddresses.isEmpty()) {
234+
sb.append(componentAddresses
235235
.stream()
236236
.map(Object::toString)
237237
.collect(Collectors.joining(",")));
238238
}
239-
sb.append(", certificateIdentifier=");
239+
sb.append(", componentPlatformCert=");
240240
sb.append("}");
241241

242242
return sb.toString();

Diff for: HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/PlatformConfiguration.java

-112
This file was deleted.

0 commit comments

Comments
 (0)