Skip to content

Possible bug in org.bouncycastle.cms.CMSSignedData when byte array is padded with zeros in version 1.85 #2360

Description

@dagframstad

org.bouncycastle.cms.CMSSignedData(contents) fails with:

IOException reading content.
org.bouncycastle.cms.CMSException: IOException reading content.
	at org.bouncycastle.cms.CMSUtils.readContentInfo(Unknown Source)
	at org.bouncycastle.cms.CMSSignedData.<init>(Unknown Source)
	at BouncyCastle185RegressionTest.PDF signature contains padded CMS(BouncyCastle185RegressionTest.kt:33)
Caused by: java.io.IOException: Extra data detected in stream
	at org.bouncycastle.asn1.ASN1Primitive.fromByteArray(Unknown Source)
	... 3 more

in BouncyCastle 1.85 if contents is padded with extra data (zeros). This worked in BouncyCastle 1.84
I'm not sure if this was intentional or not.
Code attached.

CMSSignedDataIssue.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    support requestCommunity assistance requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions