List of usage examples for org.bouncycastle.asn1.pkcs KeyDerivationFunc getParameters
public ASN1Encodable getParameters()
From source file:org.xwiki.crypto.password.internal.kdf.factory.BcPKCS5S2KeyDerivationFunctionFactory.java
License:Open Source License
@Override public KeyDerivationFunction getInstance(ASN1Encodable parameters) { KeyDerivationFunc kdf = KeyDerivationFunc.getInstance(parameters); if (!kdf.getAlgorithm().equals(PKCSObjectIdentifiers.id_PBKDF2)) { throw new IllegalArgumentException( "Illegal algorithm identifier for PBKDF2: " + kdf.getAlgorithm().getId()); }//w w w. java 2s . c o m PBKDF2Params params = PBKDF2Params.getInstance(kdf.getParameters()); return getInstance( new PBKDF2Parameters((params.getKeyLength() != null) ? params.getKeyLength().intValue() : -1, params.getIterationCount().intValue(), params.getSalt(), toDigestHint(params.getPseudoRandomFunctionIdentifier()))); }
From source file:org.xwiki.crypto.password.internal.kdf.factory.BcScryptKeyDerivationFunctionFactory.java
License:Open Source License
@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()); }//from w w w . j a v a 2s . c o m 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())); }