use of org.xwiki.crypto.password.PasswordBasedCipherFactory in project xwiki-commons by xwiki.
the class DefaultPrivateKeyPasswordBasedEncryptor method encrypt.
@Override
public byte[] encrypt(String algHint, byte[] password, KeyDerivationFunctionParameters kdfParameters, PrivateKeyParameters privateKey) throws GeneralSecurityException, IOException {
PasswordBasedCipherFactory factory = getPBEFactory(algHint);
PasswordBasedCipher cipher = factory.getInstance(true, new KeyWithIVParameters(password, factory.getIVSize(), this.randomProvider.get()), kdfParameters);
return encrypt(cipher, privateKey);
}
use of org.xwiki.crypto.password.PasswordBasedCipherFactory in project xwiki-commons by xwiki.
the class DefaultPrivateKeyPasswordBasedEncryptor method encrypt.
@Override
public byte[] encrypt(byte[] password, PrivateKeyParameters privateKey) throws GeneralSecurityException, IOException {
PasswordBasedCipherFactory factory = getPBEFactory("PBES2-AES-CBC-Pad");
PasswordBasedCipher cipher = factory.getInstance(true, new KeyWithIVParameters(password, factory.getIVSize(), this.randomProvider.get()), new PBKDF2Parameters(this.randomProvider.get()));
return encrypt(cipher, privateKey);
}
use of org.xwiki.crypto.password.PasswordBasedCipherFactory in project xwiki-commons by xwiki.
the class BcPBES2CipherFactory method getInstance.
@Override
public PasswordBasedCipher getInstance(boolean forEncryption, byte[] password, byte[] encoded) {
ASN1Sequence seq = ASN1Sequence.getInstance(encoded);
AlgorithmIdentifier alg = getPBES2AlgorithmIdentifier(seq);
PBES2Parameters params = PBES2Parameters.getInstance(alg.getParameters());
PasswordBasedCipherFactory pbecf = getPBES2CipherFactory(params.getEncryptionScheme());
PasswordBasedCipher cipher = getBcPBES2PasswordBasedCipher(pbecf, forEncryption, password, seq);
if (cipher != null) {
return cipher;
}
return pbecf.getInstance(forEncryption, password, encoded);
}
Aggregations