@Test public void testCalibrationChoosesMinCost() throws Exception { Clock clock = new ArrayClock( 0, 2000 ); PasswordBasedKdf kdf = new ScryptKdf(clock); assertEquals(256, kdf.chooseCostParameter()); }
@Override public int chooseCostParameter() { int cost = MIN_COST; while (cost * 2 <= MAX_COST && measureDuration(cost) * 2 <= TARGET_MS) cost *= 2; if (LOG.isLoggable(INFO)) LOG.info("KDF cost parameter " + cost); return cost; }
ScryptKdf implements PasswordBasedKdf { @Override public int chooseCostParameter() { int cost = MIN_COST; while (cost * 2 <= MAX_COST && measureDuration(cost) * 2 <= TARGET_MS) cost *= 2; if (LOG.isLoggable(INFO)) LOG.info("KDF cost parameter " + cost); return cost; } }
ScryptKdf implements PasswordBasedKdf { @Override public int chooseCostParameter() { int cost = MIN_COST; while (cost * 2 <= MAX_COST && measureDuration(cost) * 2 <= TARGET_MS) cost *= 2; if (LOG.isLoggable(INFO)) LOG.info("KDF cost parameter " + cost); return cost; } @Inject  ScryptKdf(Clock clock); }
ScryptKdf implements PasswordBasedKdf { @Override public int chooseCostParameter() { int cost = MIN_COST; while (cost * 2 <= MAX_COST && measureDuration(cost) * 2 <= TARGET_MS) cost *= 2; if (LOG.isLoggable(INFO)) LOG.info("KDF cost parameter " + cost); return cost; } @Inject  ScryptKdf(Clock clock); @Override int chooseCostParameter(); @Override SecretKey deriveKey(String password, byte[] salt, int cost); }
ScryptKdf implements PasswordBasedKdf { @Override public int chooseCostParameter() { int cost = MIN_COST; while (cost * 2 <= MAX_COST && measureDuration(cost) * 2 <= TARGET_MS) cost *= 2; if (LOG.isLoggable(INFO)) LOG.info("KDF cost parameter " + cost); return cost; } @Inject  ScryptKdf(Clock clock); @Override int chooseCostParameter(); @Override SecretKey deriveKey(String password, byte[] salt, int cost);  }