Hello,
We have a problem with validation of some signatures and timestamps after the commit 3790993, in particular after introduction of the !ASN1RelativeOID.isValidContents condition in the ASN1ObjectIdentifier.createPrimitive method:
static ASN1ObjectIdentifier createPrimitive(byte[] contents, boolean clone)
{
checkContentsLength(contents.length);
final OidHandle hdl = new OidHandle(contents);
ASN1ObjectIdentifier oid = pool.get(hdl);
if (oid != null)
{
return oid;
}
if (!ASN1RelativeOID.isValidContents(contents))
{
throw new IllegalArgumentException("invalid OID contents");
}
return new ASN1ObjectIdentifier(clone ? Arrays.clone(contents) : contents, null);
}
The problem is BouncyCastle not being able to build a CMSSignedData when having a signature or a timestamp with an invalid ASN1ObjectIdentifier's content.
This is critical for us, as it blocks validation of some legacy signatures, as well as failure on new CMSSignedData(InputStream) call makes it impossible to provide any relevant data about nature of the issue to the end-user:
Caused by: org.bouncycastle.cms.CMSException: IOException reading content.
at org.bouncycastle.cms.CMSUtils.readContentInfo(Unknown Source)
at org.bouncycastle.cms.CMSUtils.readContentInfo(Unknown Source)
at org.bouncycastle.cms.CMSSignedData.<init>(Unknown Source)
... 61 more
Caused by: org.bouncycastle.asn1.ASN1Exception: invalid OID contents
at org.bouncycastle.asn1.ASN1InputStream.createPrimitiveDERObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.parseImplicitPrimitive(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.implParseObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.DLSequenceParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.DLSetParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.DLSequenceParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.loadTaggedDL(Unknown Source)
at org.bouncycastle.asn1.DLTaggedObjectParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.DLSequenceParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.DLSetParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.BERSequenceParser.parse(Unknown Source)
at org.bouncycastle.asn1.BERSequenceParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.loadTaggedIL(Unknown Source)
at org.bouncycastle.asn1.BERTaggedObjectParser.getLoadedObject(Unknown Source)
at org.bouncycastle.asn1.ASN1StreamParser.readVector(Unknown Source)
at org.bouncycastle.asn1.BERSequenceParser.parse(Unknown Source)
at org.bouncycastle.asn1.ASN1InputStream.readObject(Unknown Source)
... 65 more
Caused by: java.lang.IllegalArgumentException: invalid OID contents
at org.bouncycastle.asn1.ASN1ObjectIdentifier.createPrimitive(Unknown Source)
... 90 more
We would prefer to have an exception on extraction of particular data, but failure on CMSSignedData instantiation is a breaking change for us.
Thank you.
Hello,
We have a problem with validation of some signatures and timestamps after the commit 3790993, in particular after introduction of the !ASN1RelativeOID.isValidContents condition in the ASN1ObjectIdentifier.createPrimitive method:
The problem is BouncyCastle not being able to build a CMSSignedData when having a signature or a timestamp with an invalid ASN1ObjectIdentifier's content.
This is critical for us, as it blocks validation of some legacy signatures, as well as failure on new CMSSignedData(InputStream) call makes it impossible to provide any relevant data about nature of the issue to the end-user:
We would prefer to have an exception on extraction of particular data, but failure on CMSSignedData instantiation is a breaking change for us.
Thank you.