How to decrypt pkcs8 encrypted private key using bouncy castle?

I am trying to decrypt the pkcs8 encrypted secret key using a bouncy castle library. I analyzed the file containing the private key using the PEMParserprovided PEMParsercastle. I got the object PKCS8EncryptedPrivateKeyInfo. I cannot get an object PrivateKeyInfofrom this. I get the following exception when trying to decrypt.

org.bouncycastle.pkcs.PKCSException: unable to read encrypted data: 1.2.840.113549.1.5.13 not available: no such provider: 1.2.840.113549.1.5.13

here is the code i used

PEMParser parser = new PEMParser(br);
PKCS8EncryptedPrivateKeyInfo pair =       (PKCS8EncryptedPrivateKeyInfo)parser.readObject();
JceOpenSSLPKCS8DecryptorProviderBuilder jce = new JceOpenSSLPKCS8DecryptorProviderBuilder();
                jce.setProvider("1.2.840.113549.1.5.13");
                InputDecryptorProvider decProv = jce.build(password.toCharArray());
                PrivateKeyInfo info = pair.decryptPrivateKeyInfo(decProv);
+5
source share
1 answer

jce.setProvider("BC"); jce.setProvider("1.2.840.113549.1.5.13");

, , @PeterDettman:

jce.setProvider("BC"); BC bouncycastle.org/wiki/display/JA1/Provider+Installation

+5

All Articles