From e1326af693b43c92ca9963ff68a1da43cda7cc5c Mon Sep 17 00:00:00 2001 From: Mitchell Wills Date: Fri, 1 Nov 2024 10:34:11 +1100 Subject: [PATCH] INS-494: Updated bouncy castle version to match libjitsi dependencies. --- build.gradle | 2 +- .../asanti/reader/AsnBerDataReader.java | 53 +++++++------------ 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/build.gradle b/build.gradle index 80105eb0..1245322c 100644 --- a/build.gradle +++ b/build.gradle @@ -76,7 +76,7 @@ dependencies { implementation( "com.google.guava:guava:33.3.1-jre", // Do not upgrade the following package unless you are updating the relevant Asanti parser classes. - "org.bouncycastle:bcprov-jdk15on:1.70", + "org.bouncycastle:bcprov-jdk18on:1.75", "org.slf4j:slf4j-api:${versions.slf4j}", "joda-time:joda-time:2.13.0", "commons-cli:commons-cli:1.9.0", diff --git a/src/main/java/com/brightsparklabs/asanti/reader/AsnBerDataReader.java b/src/main/java/com/brightsparklabs/asanti/reader/AsnBerDataReader.java index f7f141eb..68f9ef10 100644 --- a/src/main/java/com/brightsparklabs/asanti/reader/AsnBerDataReader.java +++ b/src/main/java/com/brightsparklabs/asanti/reader/AsnBerDataReader.java @@ -107,15 +107,12 @@ public static ImmutableList read(ByteSource source, int maxPDUs) private static void processDerObject( ASN1Primitive derObject, String prefix, Map tagsToData, int index) throws IOException { - if (derObject instanceof ASN1Sequence) { - processSequence((ASN1Sequence) derObject, prefix, tagsToData); - } else if (derObject instanceof ASN1Set) { - processSet((ASN1Set) derObject, prefix, tagsToData); - } else if (derObject instanceof ASN1TaggedObject) { - processTaggedObject((ASN1TaggedObject) derObject, prefix, tagsToData, index); - } else if (derObject instanceof DERApplicationSpecific) { - processApplicationSpecific( - (DERApplicationSpecific) derObject, prefix, tagsToData, index); + if (derObject instanceof ASN1Sequence sequence) { + processSequence(sequence, prefix, tagsToData); + } else if (derObject instanceof ASN1Set asn1Set) { + processSet(asn1Set, prefix, tagsToData); + } else if (derObject instanceof ASN1TaggedObject asn1TaggedObject) { + processTaggedObject(asn1TaggedObject, prefix, tagsToData, index); } else { processPrimitiveDerObject(derObject, prefix, tagsToData); } @@ -206,13 +203,18 @@ private static void processTaggedObject( int index) throws IOException { - ASN1Primitive obj = asnTaggedObject.getObject(); + ASN1Primitive obj = asnTaggedObject.getBaseObject().toASN1Primitive(); - prefix = - prefix - + "/" - + AsnSchemaTag.createRawTag( - index, String.valueOf(asnTaggedObject.getTagNo())); + if (asnTaggedObject.getTagClass() == BERTags.APPLICATION) { + // Process ASN.1 application objects. + prefix = prefix + "/" + asnTaggedObject.getTagNo(); + } else { + prefix = + prefix + + "/" + + AsnSchemaTag.createRawTag( + index, String.valueOf(asnTaggedObject.getTagNo())); + } int containingType = getType(asnTaggedObject); if (isConstructedType(containingType)) { @@ -233,25 +235,8 @@ private static void processTaggedObject( prefix = prefix + "/" + AsnSchemaTag.createRawTagUniversal(index, number); } - processDerObject(asnTaggedObject.getObject(), prefix, tagsToData, index); - } - - /** - * Processes an ASN.1 'ApplicationSpecific' object and stores the tags/data found in it - * - * @param asnApplicationSpecific object to process - * @param prefix prefix to prepend to any tags found - * @param tagsToData storage for the tags/data found - * @throws IOException if any errors occur reading from the file - */ - private static void processApplicationSpecific( - DERApplicationSpecific asnApplicationSpecific, - String prefix, - Map tagsToData, - int index) - throws IOException { - prefix = prefix + "/" + asnApplicationSpecific.getApplicationTag(); - processDerObject(asnApplicationSpecific.getObject(), prefix, tagsToData, index); + processDerObject( + asnTaggedObject.getBaseObject().toASN1Primitive(), prefix, tagsToData, index); } /**