public PrivateKeyInfo decryptPrivateKeyInfo(InputDecryptorProvider inputDecryptorProvider) throws PKCSException { try { InputDecryptor decrytor = inputDecryptorProvider.get(encryptedPrivateKeyInfo.getEncryptionAlgorithm()); ByteArrayInputStream encIn = new ByteArrayInputStream(encryptedPrivateKeyInfo.getEncryptedData()); return PrivateKeyInfo.getInstance(Streams.readAll(decrytor.getInputStream(encIn))); } catch (Exception e) { throw new PKCSException("unable to read encrypted data: " + e.getMessage(), e); } }