Question

How can i create a new instance of org.bouncycastle.asn1.x509.AlgorithmIdentifier of RSA OAEP? in order to be able to use it here:

JceKeyTransRecipientInfoGenerator(java.security.cert.X509Certificate recipientCert, org.bouncycastle.asn1.x509.AlgorithmIdentifier algorithmIdentifier)
Was it helpful?

Solution

with current BouncyCastleVersions you can use a constant from org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers

AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSAES_OAEP);

OTHER TIPS

It is as simple as creating object from string representation of RSA with OAEP oid

AlgorithmIdentifier id = AlgorithmIdentifier.getInstance("1.2.840.113549.1.1.7");

in recent versions of BouncyCastle >1.50 this API has been removed and getInstance takes only ASN1Sequence and AlgorithmIdentifier. So there is no option, but to use constructor:

AlgorithmIdentifier id = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSAES_OAEP);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top