Example usage for org.bouncycastle.asn1.pkcs KeyDerivationFunc toASN1Primitive

List of usage examples for org.bouncycastle.asn1.pkcs KeyDerivationFunc toASN1Primitive

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.pkcs KeyDerivationFunc toASN1Primitive.

Prototype

public ASN1Primitive toASN1Primitive() 

Source Link

Usage

From source file:org.xwiki.crypto.password.internal.pbe.factory.AbstractBcPBES2CipherFactory.java

License:Open Source License

protected KeyDerivationFunction getKeyDerivationFunction(KeyDerivationFunc func) {
    KeyDerivationFunctionFactory kdfFactory = safeGetKDFFactory();

    // Optimization
    if (kdfFactory instanceof AbstractBcKDFFactory) {
        return ((AbstractBcKDFFactory) kdfFactory).getInstance(func);
    }//from   www . j av  a2s  .  c  o m

    // Generic fallback
    try {
        return kdfFactory.getInstance(func.toASN1Primitive().getEncoded());
    } catch (IOException e) {
        // Very unlikely to happen
        throw new RuntimeException("Unexpected exception during parameter encoding");
    }
}