Search in sources :

Example 1 with PBES2Parameters

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));
}
Also used : PBES2Parameters(org.xwiki.crypto.password.internal.kdf.PBES2Parameters) EncryptionScheme(org.bouncycastle.asn1.pkcs.EncryptionScheme) KeyDerivationFunc(org.bouncycastle.asn1.pkcs.KeyDerivationFunc) AbstractBcKDF(org.xwiki.crypto.password.internal.kdf.AbstractBcKDF) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier)

Example 2 with PBES2Parameters

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());
}
Also used : PBES2Parameters(org.xwiki.crypto.password.internal.kdf.PBES2Parameters) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier)

Example 3 with PBES2Parameters

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);
}
Also used : PasswordBasedCipherFactory(org.xwiki.crypto.password.PasswordBasedCipherFactory) PBES2Parameters(org.xwiki.crypto.password.internal.kdf.PBES2Parameters) ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) PasswordBasedCipher(org.xwiki.crypto.password.PasswordBasedCipher) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier)

Aggregations

AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)3 PBES2Parameters (org.xwiki.crypto.password.internal.kdf.PBES2Parameters)3 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)1 EncryptionScheme (org.bouncycastle.asn1.pkcs.EncryptionScheme)1 KeyDerivationFunc (org.bouncycastle.asn1.pkcs.KeyDerivationFunc)1 PasswordBasedCipher (org.xwiki.crypto.password.PasswordBasedCipher)1 PasswordBasedCipherFactory (org.xwiki.crypto.password.PasswordBasedCipherFactory)1 AbstractBcKDF (org.xwiki.crypto.password.internal.kdf.AbstractBcKDF)1