mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
Reduce minimum scrypt cost for low-end devices.
This commit is contained in:
@@ -16,7 +16,7 @@ class ScryptKdf implements PasswordBasedKdf {
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(ScryptKdf.class.getName());
|
Logger.getLogger(ScryptKdf.class.getName());
|
||||||
|
|
||||||
private static final int MIN_COST = 512; // Min parameter N
|
private static final int MIN_COST = 256; // Min parameter N
|
||||||
private static final int MAX_COST = 1024 * 1024; // Max parameter N
|
private static final int MAX_COST = 1024 * 1024; // Max parameter N
|
||||||
private static final int BLOCK_SIZE = 8; // Parameter r
|
private static final int BLOCK_SIZE = 8; // Parameter r
|
||||||
private static final int PARALLELIZATION = 1; // Parameter p
|
private static final int PARALLELIZATION = 1; // Parameter p
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class ScryptKdfTest extends BrambleTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testCalibration() throws Exception {
|
public void testCalibration() throws Exception {
|
||||||
Clock clock = new ArrayClock(
|
Clock clock = new ArrayClock(
|
||||||
|
0, 50, // Duration for cost 256
|
||||||
0, 100, // Duration for cost 512
|
0, 100, // Duration for cost 512
|
||||||
0, 200, // Duration for cost 1024
|
0, 200, // Duration for cost 1024
|
||||||
0, 400, // Duration for cost 2048
|
0, 400, // Duration for cost 2048
|
||||||
@@ -65,6 +66,15 @@ public class ScryptKdfTest extends BrambleTestCase {
|
|||||||
assertEquals(4096, kdf.chooseCostParameter());
|
assertEquals(4096, kdf.chooseCostParameter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalibrationChoosesMinCost() throws Exception {
|
||||||
|
Clock clock = new ArrayClock(
|
||||||
|
0, 2000 // Duration for cost 256 is already too high
|
||||||
|
);
|
||||||
|
PasswordBasedKdf kdf = new ScryptKdf(clock);
|
||||||
|
assertEquals(256, kdf.chooseCostParameter());
|
||||||
|
}
|
||||||
|
|
||||||
private static class ArrayClock implements Clock {
|
private static class ArrayClock implements Clock {
|
||||||
|
|
||||||
private final long[] times;
|
private final long[] times;
|
||||||
|
|||||||
Reference in New Issue
Block a user