Search in sources :

Example 1 with ScryptKDFParams

use of org.xwiki.crypto.password.internal.kdf.ScryptKDFParams in project xwiki-commons by xwiki.

the class BcScryptKeyDerivationFunctionFactory method getInstance.

@Override
public KeyDerivationFunction getInstance(ASN1Encodable parameters) {
    KeyDerivationFunc kdf = KeyDerivationFunc.getInstance(parameters);
    if (!kdf.getAlgorithm().equals(ALG_ID)) {
        throw new IllegalArgumentException("Illegal algorithm identifier for Scrypt: " + kdf.getAlgorithm().getId());
    }
    ScryptKDFParams params = ScryptKDFParams.getInstance(kdf.getParameters());
    return getInstance(new ScryptParameters((params.getKeyLength() != null) ? params.getKeyLength().intValue() : -1, params.getCostParameter().intValue(), params.getParallelizationParameter().intValue(), params.getBlockSize().intValue(), params.getSalt()));
}
Also used : ScryptKDFParams(org.xwiki.crypto.password.internal.kdf.ScryptKDFParams) KeyDerivationFunc(org.bouncycastle.asn1.pkcs.KeyDerivationFunc) ScryptParameters(org.xwiki.crypto.password.params.ScryptParameters)

Aggregations

KeyDerivationFunc (org.bouncycastle.asn1.pkcs.KeyDerivationFunc)1 ScryptKDFParams (org.xwiki.crypto.password.internal.kdf.ScryptKDFParams)1 ScryptParameters (org.xwiki.crypto.password.params.ScryptParameters)1