Specifically for signature algorithms, you can use the class org.bouncycastle.operator.DefaultAlgorithmNameFinder
. But - if I'm not wrong - this was introduced only in newer versions (I'm using Bouncy Castle 1.57 - I also checked in 1.46 and it doesn't have this class).
The use is straighforward:
DefaultAlgorithmNameFinder algFinder = new DefaultAlgorithmNameFinder();
System.out.println(algFinder.getAlgorithmName(new ASN1ObjectIdentifier("1.2.840.113549.1.1.11")));
The output is:
SHA256WITHRSA
According to javadoc, if it can't find a human-friendly name, it returns the same OID used in the input.
Also note that (as stated in @pepo's answer) the human-friendly names might not be the same among different tools. While BouncyCastle returns SHA256WITHRSA
, the OID repository website uses sha256WithRSAEncryption
.
For other OIDs (such as extensions and other fields), I couldn't find anything in the API, so the only alternative seems to be the big lookup table.