Whitespace-only code formatting changes.

This commit is contained in:
akwizgran
2015-11-30 09:38:25 +00:00
parent 1950c13ffb
commit 027ae8340f
202 changed files with 2993 additions and 2993 deletions

View File

@@ -40,13 +40,13 @@ public class EllipticCurvePerformanceTest {
"brainpoolp256r1", "brainpoolp384r1", "brainpoolp512r1");
public static void main(String[] args) {
for(String name : SEC_NAMES) {
for (String name : SEC_NAMES) {
ECDomainParameters params =
convertParams(SECNamedCurves.getByName(name));
runTest(name + " default", params);
runTest(name + " constant", constantTime(params));
}
for(String name : BRAINPOOL_NAMES) {
for (String name : BRAINPOOL_NAMES) {
ECDomainParameters params =
convertParams(TeleTrusTNamedCurves.getByName(name));
runTest(name + " default", params);
@@ -71,7 +71,7 @@ public class EllipticCurvePerformanceTest {
(ECPublicKeyParameters) keyPair2.getPublic();
// Time some ECDH key agreements
List<Long> samples = new ArrayList<Long>();
for(int i = 0; i < SAMPLES; i++) {
for (int i = 0; i < SAMPLES; i++) {
ECDHCBasicAgreement agreement = new ECDHCBasicAgreement();
long start = System.nanoTime();
agreement.init(private1);
@@ -82,7 +82,7 @@ public class EllipticCurvePerformanceTest {
// Time some signatures
List<byte[]> signatures = new ArrayList<byte[]>();
samples.clear();
for(int i = 0; i < SAMPLES; i++) {
for (int i = 0; i < SAMPLES; i++) {
Digest digest = new SHA256Digest();
DSAKCalculator calculator = new HMacDSAKCalculator(digest);
DSADigestSigner signer = new DSADigestSigner(new ECDSASigner(
@@ -96,7 +96,7 @@ public class EllipticCurvePerformanceTest {
long signatureMedian = median(samples);
// Time some signature verifications
samples.clear();
for(int i = 0; i < SAMPLES; i++) {
for (int i = 0; i < SAMPLES; i++) {
Digest digest = new SHA256Digest();
DSAKCalculator calculator = new HMacDSAKCalculator(digest);
DSADigestSigner signer = new DSADigestSigner(new ECDSASigner(
@@ -104,7 +104,7 @@ public class EllipticCurvePerformanceTest {
long start = System.nanoTime();
signer.init(false, public1);
signer.update(new byte[BYTES_TO_SIGN], 0, BYTES_TO_SIGN);
if(!signer.verifySignature(signatures.get(i)))
if (!signer.verifySignature(signatures.get(i)))
throw new AssertionError();
samples.add(System.nanoTime() - start);
}
@@ -117,9 +117,9 @@ public class EllipticCurvePerformanceTest {
private static long median(List<Long> list) {
int size = list.size();
if(size == 0) throw new IllegalArgumentException();
if (size == 0) throw new IllegalArgumentException();
Collections.sort(list);
if(size % 2 == 1) return list.get(size / 2);
if (size % 2 == 1) return list.get(size / 2);
return list.get(size / 2 - 1) + list.get(size / 2) / 2;
}

View File

@@ -23,7 +23,7 @@ public class FortunaGeneratorTest extends BriarTestCase {
public void testIncrementCounter() {
FortunaGenerator f = new FortunaGenerator(new byte[32]);
// Increment the counter until it reaches 255
for(int i = 1; i < 255; i++) f.incrementCounter();
for (int i = 1; i < 255; i++) f.incrementCounter();
byte[] expected = new byte[16];
expected[0] = (byte) 255;
assertArrayEquals(expected, f.getCounter());
@@ -33,7 +33,7 @@ public class FortunaGeneratorTest extends BriarTestCase {
expected[1] = 1;
assertArrayEquals(expected, f.getCounter());
// Increment the counter until it carries into the next byte
for(int i = 256; i < 65536; i++) f.incrementCounter();
for (int i = 256; i < 65536; i++) f.incrementCounter();
expected[0] = 0;
expected[1] = 0;
expected[2] = 1;
@@ -49,15 +49,15 @@ public class FortunaGeneratorTest extends BriarTestCase {
// One byte longer than a block, with an offset of one
byte[] out2 = new byte[49];
new FortunaGenerator(seed).nextBytes(out2, 1, 48);
for(int i = 0; i < 48; i++) assertEquals(out1[i], out2[i + 1]);
for (int i = 0; i < 48; i++) assertEquals(out1[i], out2[i + 1]);
// One byte shorter than a block
byte[] out3 = new byte[47];
new FortunaGenerator(seed).nextBytes(out3, 0, 47);
for(int i = 0; i < 47; i++) assertEquals(out1[i], out3[i]);
for (int i = 0; i < 47; i++) assertEquals(out1[i], out3[i]);
// Less than a block, with an offset greater than a block
byte[] out4 = new byte[32];
new FortunaGenerator(seed).nextBytes(out4, 17, 15);
for(int i = 0; i < 15; i++) assertEquals(out1[i], out4[i + 17]);
for (int i = 0; i < 15; i++) assertEquals(out1[i], out4[i + 17]);
}
@Test

View File

@@ -29,9 +29,9 @@ public class KeyDerivationTest extends BriarTestCase {
keys.add(crypto.deriveFrameKey(secret, 0, false));
keys.add(crypto.deriveTagKey(secret, true));
keys.add(crypto.deriveTagKey(secret, false));
for(int i = 0; i < 4; i++) {
for (int i = 0; i < 4; i++) {
byte[] keyI = keys.get(i).getBytes();
for(int j = 0; j < 4; j++) {
for (int j = 0; j < 4; j++) {
byte[] keyJ = keys.get(j).getBytes();
assertEquals(i == j, Arrays.equals(keyI, keyJ));
}
@@ -42,14 +42,14 @@ public class KeyDerivationTest extends BriarTestCase {
public void testSecretAffectsDerivation() {
Random r = new Random();
List<byte[]> secrets = new ArrayList<byte[]>();
for(int i = 0; i < 20; i++) {
for (int i = 0; i < 20; i++) {
byte[] b = new byte[32];
r.nextBytes(b);
secrets.add(crypto.deriveNextSecret(b, 0));
}
for(int i = 0; i < 20; i++) {
for (int i = 0; i < 20; i++) {
byte[] secretI = secrets.get(i);
for(int j = 0; j < 20; j++) {
for (int j = 0; j < 20; j++) {
byte[] secretJ = secrets.get(j);
assertEquals(i == j, Arrays.equals(secretI, secretJ));
}
@@ -59,11 +59,11 @@ public class KeyDerivationTest extends BriarTestCase {
@Test
public void testStreamNumberAffectsDerivation() {
List<byte[]> secrets = new ArrayList<byte[]>();
for(int i = 0; i < 20; i++)
for (int i = 0; i < 20; i++)
secrets.add(crypto.deriveNextSecret(secret, i));
for(int i = 0; i < 20; i++) {
for (int i = 0; i < 20; i++) {
byte[] secretI = secrets.get(i);
for(int j = 0; j < 20; j++) {
for (int j = 0; j < 20; j++) {
byte[] secretJ = secrets.get(j);
assertEquals(i == j, Arrays.equals(secretI, secretJ));
}

View File

@@ -63,19 +63,19 @@ public class KeyEncodingAndParsingTest extends BriarTestCase {
Random random = new Random();
byte[] pubFuzz = new byte[pubLength];
byte[] privFuzz = new byte[privLength];
for(int i = 0; i < 1000; i++) {
for (int i = 0; i < 1000; i++) {
random.nextBytes(pubFuzz);
try {
parser.parsePublicKey(pubFuzz);
} catch(GeneralSecurityException expected) {
} catch(Exception e) {
} catch (GeneralSecurityException expected) {
} catch (Exception e) {
fail();
}
random.nextBytes(privFuzz);
try {
parser.parsePrivateKey(privFuzz);
} catch(GeneralSecurityException expected) {
} catch(Exception e) {
} catch (GeneralSecurityException expected) {
} catch (Exception e) {
fail();
}
}
@@ -126,19 +126,19 @@ public class KeyEncodingAndParsingTest extends BriarTestCase {
Random random = new Random();
byte[] pubFuzz = new byte[pubLength];
byte[] privFuzz = new byte[privLength];
for(int i = 0; i < 1000; i++) {
for (int i = 0; i < 1000; i++) {
random.nextBytes(pubFuzz);
try {
parser.parsePublicKey(pubFuzz);
} catch(GeneralSecurityException expected) {
} catch(Exception e) {
} catch (GeneralSecurityException expected) {
} catch (Exception e) {
fail();
}
random.nextBytes(privFuzz);
try {
parser.parsePrivateKey(privFuzz);
} catch(GeneralSecurityException expected) {
} catch(Exception e) {
} catch (GeneralSecurityException expected) {
} catch (Exception e) {
fail();
}
}

View File

@@ -17,14 +17,14 @@ class TestAuthenticatedCipher implements AuthenticatedCipher {
public int process(byte[] input, int inputOff, int len, byte[] output,
int outputOff) throws GeneralSecurityException {
if(encrypt) {
if (encrypt) {
System.arraycopy(input, inputOff, output, outputOff, len);
for(int i = 0; i < MAC_LENGTH; i++)
for (int i = 0; i < MAC_LENGTH; i++)
output[outputOff + len + i] = 0;
return len + MAC_LENGTH;
} else {
for(int i = 0; i < MAC_LENGTH; i++)
if(input[inputOff + len - MAC_LENGTH + i] != 0)
for (int i = 0; i < MAC_LENGTH; i++)
if (input[inputOff + len - MAC_LENGTH + i] != 0)
throw new GeneralSecurityException();
System.arraycopy(input, inputOff, output, outputOff,
len - MAC_LENGTH);