I have to perform conversions between cryptography algorithms names and their object identifiers (OIDs). I use Java Cryptography Architecture (JCA) and Bouncy Castle as a security provider. Converting OIDs to textual names is fairly easy with JCA itself.
String oid = "2.16.840.1.101.3.4.2.4";
MessageDigest md = MessageDigest.getInstance(oid);
String digestAlgorithmName = md.getAlgorithm();
But how do I perform backward conversion from textual names to OIDs? There seems to be no way how to get aliases for algorithm name in JCA. Bouncy Castle 1.50 has maps, which connect algorithm names to OIDs, but all of them have restricted access.
There are a few helper classes in the PKIX distribution which are specifically for dealing with this.
Have a look in org.bouncycastle.operator - DefaultDigestAlgorithmIdentifierFinder and DefaultSignatureAlgorithmIdentifierFinder. There's also a few others in different places through the rest of the distribution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With