@Test public void scryptSerializationDeserializationTest() throws Exception { byte[] password = PasswordToByteConverter.convert("password"); KeyDerivationFunction kdf = getKDFInstance(new ScryptParameters(64, 512, 8)); KeyWithIVParameters params = kdf.derive(password, 8); KeyDerivationFunction kdf2 = factory.getInstance(kdf.getEncoded()); KeyWithIVParameters params2 = kdf2.derive(password, 8); assertThat(params.getKey(), equalTo(params2.getKey())); assertThat(params2.getIV(), equalTo(params2.getIV())); }
@Override public KeyDerivationFunction getInstance(KeyDerivationFunctionParameters params) { if (!(params instanceof ScryptParameters)) { throw new IllegalArgumentException("Invalid parameter used for Scrypt function: " + params.getClass().getName()); } return new BcScryptKDF((ScryptParameters) params); }
BcScryptKeyDerivationFunctionFactory extends AbstractBcKDFFactory { @Override public KeyDerivationFunction getInstance(KeyDerivationFunctionParameters params) { if (!(params instanceof ScryptParameters)) { throw new IllegalArgumentException("Invalid parameter used for Scrypt function: " + params.getClass().getName()); } return new BcScryptKDF((ScryptParameters) params); } }
BcScryptKeyDerivationFunctionFactory extends AbstractBcKDFFactory { @Override public KeyDerivationFunction getInstance(KeyDerivationFunctionParameters params) { if (!(params instanceof ScryptParameters)) { throw new IllegalArgumentException("Invalid parameter used for Scrypt function: " + params.getClass().getName()); } return new BcScryptKDF((ScryptParameters) params); }  }
BcScryptKeyDerivationFunctionFactory extends AbstractBcKDFFactory { @Override public KeyDerivationFunction getInstance(KeyDerivationFunctionParameters params) { if (!(params instanceof ScryptParameters)) { throw new IllegalArgumentException("Invalid parameter used for Scrypt function: " + params.getClass().getName()); } return new BcScryptKDF((ScryptParameters) params); }  @Override KeyDerivationFunction getInstance(KeyDerivationFunctionParameters params); @Override KeyDerivationFunction getInstance(ASN1Encodable parameters); }
BcScryptKeyDerivationFunctionFactory extends AbstractBcKDFFactory { @Override public KeyDerivationFunction getInstance(KeyDerivationFunctionParameters params) { if (!(params instanceof ScryptParameters)) { throw new IllegalArgumentException("Invalid parameter used for Scrypt function: " + params.getClass().getName()); } return new BcScryptKDF((ScryptParameters) params); }  @Override KeyDerivationFunction getInstance(KeyDerivationFunctionParameters params); @Override KeyDerivationFunction getInstance(ASN1Encodable parameters);  }