final InputDecryptorProvider provider = new JceOpenSSLPKCS8DecryptorProviderBuilder().build( passPhrase.toCharArray() ); final PrivateKeyInfo privateKeyInfo = encryptedInfo.decryptPrivateKeyInfo( provider ); return converter.getPrivateKey( privateKeyInfo );
if (object instanceof PKCS8EncryptedPrivateKeyInfo) { InputDecryptorProvider decProv = new JceOpenSSLPKCS8DecryptorProviderBuilder().build(keyPassword.toCharArray()); privKey = keyConverter.getPrivateKey(((PKCS8EncryptedPrivateKeyInfo) object).decryptPrivateKeyInfo(decProv));
new JceOpenSSLPKCS8DecryptorProviderBuilder().build(keyPassword.toCharArray()); privKey = keyConverter.getPrivateKey(((PKCS8EncryptedPrivateKeyInfo) object).decryptPrivateKeyInfo(decProv));
InputDecryptorProvider decryptionProvider = new JceOpenSSLPKCS8DecryptorProviderBuilder().setProvider(provider).build(password.toCharArray()); PrivateKeyInfo info = ((PKCS8EncryptedPrivateKeyInfo) object).decryptPrivateKeyInfo(decryptionProvider); return converter.getPrivateKey(info);
private static PrivateKeyInfo resolvePK(String type, Object src, PasswordSupplier pf) throws IOException, OperatorCreationException, PKCSException { if (src instanceof PrivateKeyInfo) return (PrivateKeyInfo) src; if (src instanceof PEMKeyPair) return ((PEMKeyPair)src).getPrivateKeyInfo(); if (src instanceof PKCS8EncryptedPrivateKeyInfo) { JceOpenSSLPKCS8DecryptorProviderBuilder provBuilder = new JceOpenSSLPKCS8DecryptorProviderBuilder(); InputDecryptorProvider decProvider = provBuilder.build(pf.getPassword()); return ((PKCS8EncryptedPrivateKeyInfo)src).decryptPrivateKeyInfo(decProvider); } if (src instanceof PEMEncryptedKeyPair) { JcePEMDecryptorProviderBuilder provBuilder = new JcePEMDecryptorProviderBuilder(); PEMDecryptorProvider decProvider = provBuilder.build(pf.getPassword()); PEMKeyPair keyPair = ((PEMEncryptedKeyPair)src).decryptKeyPair(decProvider); return keyPair.getPrivateKeyInfo(); } throw new IOException("The " + type + " input does not contain a private key, " + "it was parsed as " + src.getClass().getName()); }
InputDecryptorProvider decryptor = new JceOpenSSLPKCS8DecryptorProviderBuilder() .setProvider("BC") .build(password.toCharArray()); pkInfo = epkInfo.decryptPrivateKeyInfo(decryptor); } else {
final InputDecryptorProvider provider = new JceOpenSSLPKCS8DecryptorProviderBuilder().build( passPhrase.toCharArray() ); final PrivateKeyInfo privateKeyInfo = encryptedInfo.decryptPrivateKeyInfo( provider ); return converter.getPrivateKey( privateKeyInfo );
InputDecryptorProvider dp = new JceOpenSSLPKCS8DecryptorProviderBuilder().build(passphrase); PKCS8EncryptedPrivateKeyInfo epk = (PKCS8EncryptedPrivateKeyInfo) object; return new PEMEncodable(kConv.getPrivateKey(epk.decryptPrivateKeyInfo(dp)));
InputDecryptorProvider decProv = new JceOpenSSLPKCS8DecryptorProviderBuilder() .setProvider("BC") .build(password.toCharArray()); PrivateKeyInfo privateKeyInfo = encryptedPrivateKeyInfo.decryptPrivateKeyInfo(decProv);
} else if (keyPair instanceof PKCS8EncryptedPrivateKeyInfo) { InputDecryptorProvider pkcs8Prov = new JceOpenSSLPKCS8DecryptorProviderBuilder().setProvider("BC") .build(this.privateKeyPassword.toCharArray()); PrivateKeyInfo keyInfo = ((PKCS8EncryptedPrivateKeyInfo) keyPair).decryptPrivateKeyInfo(pkcs8Prov); decryptedPrivateKey = (new JcaPEMKeyConverter()).getPrivateKey(keyInfo);