use of org.xwiki.crypto.password.internal.kdf.PBES2Parameters in project xwiki-commons by xwiki.
the class AbstractBcPBES2Cipher method getPBEParameters.
@Override
public AlgorithmIdentifier getPBEParameters() throws IOException {
KeyDerivationFunc kdfParams;
if (getKeyDerivationFunction() instanceof AbstractBcKDF) {
kdfParams = ((AbstractBcKDF) getKeyDerivationFunction()).getKeyDerivationFunction();
} else {
kdfParams = KeyDerivationFunc.getInstance(getKeyDerivationFunction().getEncoded());
}
EncryptionScheme scheme = getScheme(getParameters());
return new AlgorithmIdentifier(PKCSObjectIdentifiers.id_PBES2, new PBES2Parameters(kdfParams, scheme));
}
use of org.xwiki.crypto.password.internal.kdf.PBES2Parameters in project xwiki-commons by xwiki.
the class AbstractBcPBES2CipherFactory method getInstance.
@Override
public PasswordBasedCipher getInstance(boolean forEncryption, byte[] password, ASN1Encodable parameters) {
AlgorithmIdentifier alg = AlgorithmIdentifier.getInstance(parameters);
if (!alg.getAlgorithm().equals(PKCSObjectIdentifiers.id_PBES2)) {
throw new IllegalArgumentException("Illegal algorithm identifier for PBES2: " + alg.getAlgorithm().getId());
}
PBES2Parameters params = PBES2Parameters.getInstance(alg.getParameters());
return getInstance(forEncryption, password, params.getKeyDerivationFunc(), params.getEncryptionScheme());
}
use of org.xwiki.crypto.password.internal.kdf.PBES2Parameters 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