Unit test for key derivation.

This commit is contained in:
akwizgran
2011-11-16 15:56:54 +00:00
parent a13a1769e5
commit ece03038f4

View File

@@ -42,6 +42,24 @@ public class KeyDerivationTest extends TestCase {
}
}
@Test
public void testSecretAffectsDerivation() {
Random r = new Random();
List<byte[]> secrets = new ArrayList<byte[]>();
for(int i = 0; i < 20; i++) {
byte[] b = new byte[32];
r.nextBytes(b);
secrets.add(crypto.deriveNextSecret(b, 0, 0));
}
for(int i = 0; i < 20; i++) {
byte[] secretI = secrets.get(i);
for(int j = 0; j < 20; j++) {
byte[] secretJ = secrets.get(j);
assertEquals(i == j, Arrays.equals(secretI, secretJ));
}
}
}
@Test
public void testTransportIndexAffectsDerivation() {
List<byte[]> secrets = new ArrayList<byte[]>();