While expecting a StackOverFlow error from uploading an EK certificate,

this is not occurring.  A unit test had to be updated because the
previous BouncyCastle X500Compare.equals() method returned false for 2
empty string compares.  Now it returns true.
This commit is contained in:
Cyrus 2024-01-24 09:48:44 -05:00
parent ab4c608d8d
commit 1d0a71a1a2
2 changed files with 2 additions and 9 deletions

View File

@ -13,7 +13,6 @@ import lombok.NoArgsConstructor;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.asn1.ASN1ApplicationSpecific;
import org.bouncycastle.asn1.ASN1BitString; import org.bouncycastle.asn1.ASN1BitString;
import org.bouncycastle.asn1.ASN1Boolean; import org.bouncycastle.asn1.ASN1Boolean;
import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1Encodable;
@ -55,7 +54,7 @@ import java.util.Set;
/** /**
* *
* This class persists Certificate Authority credentials by extending the base Certificate * This class persists an Endorsement Credential by extending the base Certificate
* class with fields unique to Endorsement credentials, as defined in the Trusted * class with fields unique to Endorsement credentials, as defined in the Trusted
* Computing Group Credential Profiles, specification v.1.2. * Computing Group Credential Profiles, specification v.1.2.
* *
@ -529,10 +528,6 @@ public class EndorsementCredential extends DeviceAssociatedCertificate {
e.printStackTrace(); e.printStackTrace();
} }
} }
} else if (component instanceof ASN1ApplicationSpecific) {
parseSingle(((ASN1ApplicationSpecific) component).getObject(), addToMapping, key);
} else if (component instanceof DERBMPString) { } else if (component instanceof DERBMPString) {
if (addToMapping) { if (addToMapping) {
String bmpStr = ((DERBMPString) component).getString(); String bmpStr = ((DERBMPString) component).getString();

View File

@ -1,6 +1,5 @@
package hirs.utils; package hirs.utils;
import lombok.extern.log4j.Log4j2;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -9,7 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
/** /**
* Tests methods in the (@link BouncyCastleUtils) utility class. * Tests methods in the (@link BouncyCastleUtils) utility class.
*/ */
@Log4j2
public class BouncyCastleUtilsTest { public class BouncyCastleUtilsTest {
private static final String VALID_RDN_STRING = "OU=PCTest,O=example.com,C=US"; private static final String VALID_RDN_STRING = "OU=PCTest,O=example.com,C=US";
@ -28,6 +26,7 @@ public class BouncyCastleUtilsTest {
VALID_RDN_STRING, VALID_RDN_STRING_SWITCHED)); VALID_RDN_STRING, VALID_RDN_STRING_SWITCHED));
assertTrue(BouncyCastleUtils.x500NameCompare( assertTrue(BouncyCastleUtils.x500NameCompare(
VALID_RDN_STRING, VALID_RDN_STRING_UPPERCASE)); VALID_RDN_STRING, VALID_RDN_STRING_UPPERCASE));
assertTrue(BouncyCastleUtils.x500NameCompare(Strings.EMPTY, Strings.EMPTY));
} }
/** /**
@ -40,7 +39,6 @@ public class BouncyCastleUtilsTest {
// Error that aren't thrown but logged // Error that aren't thrown but logged
assertFalse(BouncyCastleUtils.x500NameCompare(VALID_RDN_STRING, Strings.EMPTY)); assertFalse(BouncyCastleUtils.x500NameCompare(VALID_RDN_STRING, Strings.EMPTY));
assertFalse(BouncyCastleUtils.x500NameCompare(Strings.EMPTY, VALID_RDN_STRING)); assertFalse(BouncyCastleUtils.x500NameCompare(Strings.EMPTY, VALID_RDN_STRING));
assertFalse(BouncyCastleUtils.x500NameCompare(Strings.EMPTY, Strings.EMPTY));
assertFalse(BouncyCastleUtils.x500NameCompare( assertFalse(BouncyCastleUtils.x500NameCompare(
VALID_RDN_STRING, MALFORMED_RDN_STRING)); VALID_RDN_STRING, MALFORMED_RDN_STRING));
assertFalse(BouncyCastleUtils.x500NameCompare( assertFalse(BouncyCastleUtils.x500NameCompare(