Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultDigestAlgorithmIdentifierFinder throws NPE for Composite Sigs #1767

Open
Akretsch opened this issue Aug 6, 2024 · 4 comments
Open

Comments

@Akretsch
Copy link

Akretsch commented Aug 6, 2024

org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder.find(MiscObjectIdentifiers.id_MLDSA44_RSA2048_PSS_SHA256) triggers NullPointerException("digest OID is null") in
org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder.find(ASN1ObjectIdentifier).

I would expect org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder.find(MiscObjectIdentifiers.id_MLDSA44_RSA2048_PSS_SHA256) returning null in such case.

@roy-basmacier
Copy link

Hello @Akretsch,
I tried reproducing the error, but

org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder.find(MiscObjectIdentifiers.id_MLDSA44_RSA2048_PSS_SHA256)

is returning the corresponding AlgorithmIdentifier.

Can you provide more information on how you are producing the NPE

@Akretsch
Copy link
Author

Akretsch commented Aug 7, 2024

Sorry, my code was not complete. This snippet triggers the NPE:

package com.siemens.pki.bctest;

import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;

public class FinderTest {

	private static final DigestAlgorithmIdentifierFinder DIG_ALG_FINDER = new DefaultDigestAlgorithmIdentifierFinder();

	public static void main(String[] args) {
		try {
			System.out.println(DIG_ALG_FINDER
					.find(new AlgorithmIdentifier(
							org.bouncycastle.asn1.misc.MiscObjectIdentifiers.id_MLDSA44_RSA2048_PSS_SHA256))
					.getAlgorithm());
		} catch (NullPointerException ex) {
			ex.printStackTrace();
		}
	}
}

I use the 1.79-SNAPSHOT version.

@roy-basmacier
Copy link

Hello @Akretsch,
Thanks for sharing the code snippet. I was able to recreate it.

I would expect org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder.find(MiscObjectIdentifiers.id_MLDSA44_RSA2048_PSS_SHA256) returning null in such case.

Should the expected value be the Digest Algorithm Identifier used by the CMS signer?
Or would it be more reasonable to return null?

@Akretsch
Copy link
Author

Akretsch commented Aug 8, 2024

Hello @roy-basmacier,

I have to deal with certHash generation in CMP cert confirmations, see
https://www.ietf.org/archive/id/draft-ietf-lamps-rfc4210bis-12.html#section-5.3.18 . So if a certificate signature algorithm does not specify or enforce a specific hash algorithm, the DefaultDigestAlgorithmIdentifierFinder shall return null.

But maybe CMS needs it in another way?

Thanks for testing!

Andreas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants