List of usage examples for org.bouncycastle.asn1.pkcs EncryptedPrivateKeyInfo EncryptedPrivateKeyInfo
public EncryptedPrivateKeyInfo(AlgorithmIdentifier algId, byte[] encoding)
From source file:org.xwiki.crypto.password.internal.DefaultPrivateKeyPasswordBasedEncryptor.java
License:Open Source License
@Override public byte[] encrypt(PasswordBasedCipher cipher, PrivateKeyParameters privateKey) throws IOException, GeneralSecurityException { AlgorithmIdentifier algId;//from ww w . ja v a2s .c o m // Optimization if (cipher instanceof AbstractBcPBCipher) { algId = ((AbstractBcPBCipher) cipher).getPBEParameters(); } else { algId = AlgorithmIdentifier.getInstance(cipher.getEncoded()); } return new EncryptedPrivateKeyInfo(algId, cipher.doFinal(privateKey.getEncoded())).getEncoded(); }