Removed double-encryption of shared secrets.

This commit is contained in:
akwizgran
2011-11-15 14:09:28 +00:00
parent 6cdf68d6cb
commit 23be7fd876
8 changed files with 42 additions and 123 deletions

View File

@@ -97,9 +97,9 @@ public class ProtocolIntegrationTest extends TestCase {
assertEquals(crypto.getMessageDigest().getDigestLength(),
UniqueId.LENGTH);
// Create matching secrets: one for Alice, one for Bob
aliceSecret = new byte[45];
aliceSecret[16] = (byte) 1;
bobSecret = new byte[45];
aliceSecret = new byte[123];
aliceSecret[0] = (byte) 1;
bobSecret = new byte[123];
// Create two groups: one restricted, one unrestricted
GroupFactory groupFactory = i.getInstance(GroupFactory.class);
group = groupFactory.createGroup("Unrestricted group", null);

View File

@@ -22,7 +22,7 @@ public class CryptoComponentTest extends TestCase {
public void testKeyDerivation() {
// Create matching secrets: one for Alice, one for Bob
byte[] aliceSecret = new byte[123];
aliceSecret[SharedSecret.IV_BYTES] = (byte) 1;
aliceSecret[0] = (byte) 1;
byte[] bobSecret = new byte[123];
// Check that Alice's incoming keys match Bob's outgoing keys
assertEquals(crypto.deriveIncomingMacKey(aliceSecret),

View File

@@ -15,22 +15,22 @@ public class SharedSecretTest extends TestCase {
Random random = new Random();
byte[] secret = new byte[40];
random.nextBytes(secret);
secret[SharedSecret.IV_BYTES] = (byte) 0;
secret[0] = (byte) 0;
SharedSecret s = new SharedSecret(secret);
assertArrayEquals(secret, s.getBytes());
secret[SharedSecret.IV_BYTES] = (byte) 1;
secret[0] = (byte) 1;
s = new SharedSecret(secret);
assertArrayEquals(secret, s.getBytes());
// The Alice flag must be either 0 or 1
secret[SharedSecret.IV_BYTES] = (byte) 2;
secret[0] = (byte) 2;
try {
s = new SharedSecret(secret);
fail();
} catch(IllegalArgumentException expected) {}
// The ciphertext must be at least 1 byte long
secret = new byte[SharedSecret.IV_BYTES + 1];
// The secret must be at least 1 byte long
secret = new byte[1];
random.nextBytes(secret);
secret[SharedSecret.IV_BYTES] = (byte) 0;
secret[0] = (byte) 0;
try {
s = new SharedSecret(secret);
fail();

View File

@@ -63,9 +63,9 @@ public class BatchConnectionReadWriteTest extends TestCase {
transportId = new TransportId(TestUtils.getRandomId());
transportIndex = new TransportIndex(1);
// Create matching secrets for Alice and Bob
aliceSecret = new byte[100];
aliceSecret[16] = (byte) 1;
bobSecret = new byte[100];
aliceSecret = new byte[123];
aliceSecret[0] = (byte) 1;
bobSecret = new byte[123];
}
@Before