/hg/release/icedtea7-forest-2.2/jdk: Normalise whitespace follow...
andrew at icedtea.classpath.org
andrew at icedtea.classpath.org
Wed May 23 10:34:12 PDT 2012
changeset ca871dbdbd7b in /hg/release/icedtea7-forest-2.2/jdk
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.2/jdk?cmd=changeset;node=ca871dbdbd7b
author: andrew
date: Wed May 23 18:33:36 2012 +0100
Normalise whitespace following test changes.
diffstat:
test/com/oracle/security/ucrypto/TestAES.java | 34 +-
test/com/oracle/security/ucrypto/TestDigest.java | 2 +-
test/com/oracle/security/ucrypto/TestRSA.java | 282 +++++++++++-----------
test/com/oracle/security/ucrypto/UcryptoTest.java | 28 +-
4 files changed, 173 insertions(+), 173 deletions(-)
diffs (truncated from 612 to 500 lines):
diff -r 8e7653eb3797 -r ca871dbdbd7b test/com/oracle/security/ucrypto/TestAES.java
--- a/test/com/oracle/security/ucrypto/TestAES.java Fri May 04 01:36:23 2012 +0100
+++ b/test/com/oracle/security/ucrypto/TestAES.java Wed May 23 18:33:36 2012 +0100
@@ -55,7 +55,7 @@
main(new TestAES(), null);
}
- public boolean doTest(Provider prov)
+ public boolean doTest(Provider prov)
throws NoSuchAlgorithmException {
// Provider for testing Interoperability
Provider sunJCEProv = Security.getProvider("SunJCE");
@@ -69,7 +69,7 @@
boolean result5 = testCipherKeyWrapping(PADDEDCIPHER_ALGOS, CIPHER_KEY, prov, sunJCEProv);
boolean result6 = testCipherGCM(CIPHER_KEY, prov);
- return result1 && result2 && result3 && result4 && result5 && result6;
+ return result1 && result2 && result3 && result4 && result5 && result6;
}
private static boolean testCipherInterop(String[] algos, SecretKey key,
@@ -128,12 +128,12 @@
} else {
System.err.println("One or more CIPHER Interop tests failed!");
}
-
- return testPassed;
+
+ return testPassed;
}
private static boolean testCipherOffset(String[] algos, SecretKey key,
- Provider p) {
+ Provider p) {
boolean testPassed = true;
byte[] in = new byte[16];
(new SecureRandom()).nextBytes(in);
@@ -189,12 +189,12 @@
} else {
System.err.println("One or more CIPHER offset tests failed!");
}
-
- return testPassed;
+
+ return testPassed;
}
private static boolean testCipherKeyWrapping(String[] algos, SecretKey key,
- Provider p, Provider interopP)
+ Provider p, Provider interopP)
throws NoSuchAlgorithmException {
boolean testPassed = true;
@@ -219,12 +219,12 @@
System.err.println("Skipping Unsupported CIP algo: " + algos[i]);
continue;
}
- try {
- c1.init(Cipher.WRAP_MODE, key, (AlgorithmParameters)null, null);
- } catch (InvalidAlgorithmParameterException e) {
- System.err.println("Skipping due to lack of WRAP_MODE support.");
- continue;
- }
+ try {
+ c1.init(Cipher.WRAP_MODE, key, (AlgorithmParameters)null, null);
+ } catch (InvalidAlgorithmParameterException e) {
+ System.err.println("Skipping due to lack of WRAP_MODE support.");
+ continue;
+ }
AlgorithmParameters params = c1.getParameters();
Cipher c2 = Cipher.getInstance(algos[i], interopP);
c2.init(Cipher.UNWRAP_MODE, key, params, null);
@@ -262,12 +262,12 @@
System.err.println("One or more CIPHER keywrapping tests failed!");
}
- return testPassed;
+ return testPassed;
}
private static boolean testCipherGCM(SecretKey key,
- Provider p) {
+ Provider p) {
boolean testPassed = true;
byte[] in = new byte[16];
(new SecureRandom()).nextBytes(in);
@@ -318,7 +318,7 @@
System.err.println("One or more CIPHER GCM tests failed!");
}
- return testPassed;
+ return testPassed;
}
private static boolean checkArrays(byte[] a1, int a1Len, byte[] a2, int a2Len) {
diff -r 8e7653eb3797 -r ca871dbdbd7b test/com/oracle/security/ucrypto/TestDigest.java
--- a/test/com/oracle/security/ucrypto/TestDigest.java Fri May 04 01:36:23 2012 +0100
+++ b/test/com/oracle/security/ucrypto/TestDigest.java Wed May 23 18:33:36 2012 +0100
@@ -124,6 +124,6 @@
System.err.println("One or more MD test failed!");
}
- return testPassed;
+ return testPassed;
}
}
diff -r 8e7653eb3797 -r ca871dbdbd7b test/com/oracle/security/ucrypto/TestRSA.java
--- a/test/com/oracle/security/ucrypto/TestRSA.java Fri May 04 01:36:23 2012 +0100
+++ b/test/com/oracle/security/ucrypto/TestRSA.java Wed May 23 18:33:36 2012 +0100
@@ -165,34 +165,34 @@
};
private static KeyPair genRSAKey(int keyLength) {
- try {
- KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
- kpg.initialize(keyLength);
- return kpg.generateKeyPair();
- } catch (NoSuchAlgorithmException e) {
- System.err.println("Couldn't generate key: " + e);
- return null;
- }
+ try {
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
+ kpg.initialize(keyLength);
+ return kpg.generateKeyPair();
+ } catch (NoSuchAlgorithmException e) {
+ System.err.println("Couldn't generate key: " + e);
+ return null;
+ }
}
private static KeyPair genPredefinedRSAKeyPair() {
- try {
- KeyFactory kf = KeyFactory.getInstance("RSA");
- BigInteger mod = new BigInteger(MOD);
- BigInteger pub = new BigInteger(PUB_EXP);
-
- PrivateKey privKey = kf.generatePrivate
- (new RSAPrivateCrtKeySpec
- (mod, pub, new BigInteger(PRIV_EXP),
- new BigInteger(PRIME_P), new BigInteger(PRIME_Q),
- new BigInteger(EXP_P), new BigInteger(EXP_Q),
- new BigInteger(CRT_COEFF)));
- PublicKey pubKey = kf.generatePublic(new RSAPublicKeySpec(mod, pub));
- return new KeyPair(pubKey, privKey);
- } catch (NoSuchAlgorithmException|InvalidKeySpecException ex) {
- System.err.println("Couldn't generate predefined key pair: " + ex);
- return null;
- }
+ try {
+ KeyFactory kf = KeyFactory.getInstance("RSA");
+ BigInteger mod = new BigInteger(MOD);
+ BigInteger pub = new BigInteger(PUB_EXP);
+
+ PrivateKey privKey = kf.generatePrivate
+ (new RSAPrivateCrtKeySpec
+ (mod, pub, new BigInteger(PRIV_EXP),
+ new BigInteger(PRIME_P), new BigInteger(PRIME_Q),
+ new BigInteger(EXP_P), new BigInteger(EXP_Q),
+ new BigInteger(CRT_COEFF)));
+ PublicKey pubKey = kf.generatePublic(new RSAPublicKeySpec(mod, pub));
+ return new KeyPair(pubKey, privKey);
+ } catch (NoSuchAlgorithmException|InvalidKeySpecException ex) {
+ System.err.println("Couldn't generate predefined key pair: " + ex);
+ return null;
+ }
}
private static final String CIP_ALGOS[] = {
@@ -220,14 +220,14 @@
public boolean doTest(Provider prov) {
// first test w/ predefine KeyPair
KeyPair pkp = genPredefinedRSAKeyPair();
- if (pkp == null)
- return true;
+ if (pkp == null)
+ return true;
System.err.println("Test against Predefined RSA Key Pair");
boolean result1 = testCipher(pkp, 128, true, prov);
boolean result2 = testSignature(pkp, true, prov);
- boolean[] cResults = new boolean[10];
- boolean[] sResults = new boolean[10];
+ boolean[] cResults = new boolean[10];
+ boolean[] sResults = new boolean[10];
for (int i = 0; i < 10; i++) {
// then test w/ various key lengths
int keyLens[] = { 1024, 2048 };
@@ -236,41 +236,41 @@
cResults[i] = testCipher(keyLens, false, prov);
sResults[i] = testSignature(keyLens, false, prov);
}
- boolean result3 = true;
- boolean result4 = true;
- for (int i = 0; i < 10; i++) {
- if (!cResults[i])
- result3 = false;
- if (!sResults[i])
- result4 = false;
- }
- return result1 && result2 && result3 && result4;
+ boolean result3 = true;
+ boolean result4 = true;
+ for (int i = 0; i < 10; i++) {
+ if (!cResults[i])
+ result3 = false;
+ if (!sResults[i])
+ result4 = false;
+ }
+ return result1 && result2 && result3 && result4;
}
private static boolean testCipher(KeyPair kp, int inputSizeInBytes,
- boolean checkInterop, Provider prov) {
+ boolean checkInterop, Provider prov) {
Cipher c1, c2;
- boolean[] results = new boolean[CIP_ALGOS.length];
+ boolean[] results = new boolean[CIP_ALGOS.length];
for (int i = 0; i < CIP_ALGOS.length; i++) {
String algo = CIP_ALGOS[i];
try {
c1 = Cipher.getInstance(algo, prov);
} catch (NoSuchAlgorithmException|NoSuchPaddingException nsae) {
System.err.println("Skip unsupported Cipher algo: " + algo);
- results[i] = true;
+ results[i] = true;
continue;
}
- try {
- if (checkInterop) {
- c2 = Cipher.getInstance(algo, "SunJCE");
- } else {
- c2 = Cipher.getInstance(algo, prov);
- }
+ try {
+ if (checkInterop) {
+ c2 = Cipher.getInstance(algo, "SunJCE");
+ } else {
+ c2 = Cipher.getInstance(algo, prov);
+ }
} catch (NoSuchAlgorithmException|NoSuchPaddingException|NoSuchProviderException nsae) {
System.err.println("Skip unsupported Cipher algo: " + algo);
- results[i] = true;
+ results[i] = true;
continue;
}
@@ -279,24 +279,24 @@
results[i] = testEncryption(c1, c2, kp, data);
}
- for (int i = 0; i < CIP_ALGOS.length; i++)
- if (!results[i])
- return false;
- return true;
+ for (int i = 0; i < CIP_ALGOS.length; i++)
+ if (!results[i])
+ return false;
+ return true;
}
private static boolean testCipher(int keyLens[], boolean checkInterop,
- Provider prov) {
+ Provider prov) {
// RSA CipherText will always differ due to the random nonce in padding
// so we check whether both
// 1) Java Encrypt/C Decrypt
// 2) C Encrypt/Java Decrypt
// works
Cipher c1, c2;
- boolean[] results = new boolean[CIP_ALGOS.length];
+ boolean[] results = new boolean[CIP_ALGOS.length];
for (int i = 0; i < CIP_ALGOS.length; i++) {
String algo = CIP_ALGOS[i];
- results[i] = true;
+ results[i] = true;
try {
c1 = Cipher.getInstance(algo, prov);
} catch (NoSuchAlgorithmException|NoSuchPaddingException nsae) {
@@ -304,47 +304,47 @@
continue;
}
- try {
- if (checkInterop) {
- c2 = Cipher.getInstance(algo, "SunJCE");
- } else {
- c2 = Cipher.getInstance(algo, prov);
- }
+ try {
+ if (checkInterop) {
+ c2 = Cipher.getInstance(algo, "SunJCE");
+ } else {
+ c2 = Cipher.getInstance(algo, prov);
+ }
} catch (NoSuchAlgorithmException|NoSuchPaddingException|NoSuchProviderException nsae) {
System.err.println("Skip unsupported Cipher algo: " + algo);
continue;
}
- boolean[] encResults = new boolean[keyLens.length];
+ boolean[] encResults = new boolean[keyLens.length];
for (int h = 0; h < keyLens.length; h++) {
// Defer key pair generation until now when it'll soon be used.
if (kp[h] == null) {
kp[h] = genRSAKey(keyLens[h]);
- if (kp[h] == null) {
- encResults[h] = true;
- continue;
- }
+ if (kp[h] == null) {
+ encResults[h] = true;
+ continue;
+ }
}
System.err.println("Testing Cipher " + algo + " w/ KeySize " + keyLens[h]);
byte[] data = Arrays.copyOf
(PLAINTEXT, keyLens[h]/8 - INPUT_SIZE_REDUCTION[i]);
encResults[h] = testEncryption(c1, c2, kp[h], data);
}
- for (int h = 0; h < keyLens.length; h++)
- if (!encResults[h])
- results[i] = false;
+ for (int h = 0; h < keyLens.length; h++)
+ if (!encResults[h])
+ results[i] = false;
}
- for (int i = 0; i < CIP_ALGOS.length; i++)
- if (!results[i])
- return false;
- return true;
+ for (int i = 0; i < CIP_ALGOS.length; i++)
+ if (!results[i])
+ return false;
+ return true;
}
private static boolean testEncryption(Cipher c1, Cipher c2, KeyPair kp, byte[] data) {
// C1 Encrypt + C2 Decrypt
byte[] out1 = null;
byte[] recoveredText = null;
- boolean result1 = true;
+ boolean result1 = true;
try {
c1.init(Cipher.ENCRYPT_MODE, kp.getPublic());
out1 = c1.doFinal(data);
@@ -355,14 +355,14 @@
ex.printStackTrace();
result1 = false;
}
- boolean result2 = true;
+ boolean result2 = true;
if(!Arrays.equals(recoveredText, data)) {
System.err.println("DEC ERROR: different PT bytes");
- result2 = false;
+ result2 = false;
}
// C2 Encrypt + C1 Decrypt
byte[] cipherText = null;
- boolean result3 = true;
+ boolean result3 = true;
try {
c2.init(Cipher.ENCRYPT_MODE, kp.getPublic());
cipherText = c2.doFinal(data);
@@ -379,59 +379,59 @@
ex.printStackTrace();
result3 = false;
}
- boolean result4 = Arrays.equals(out1, data);
+ boolean result4 = Arrays.equals(out1, data);
if (!result4) {
System.err.println("ENC ERROR: Decrypted result DIFF");
}
- if (result1 && result2 && result3 && result4) {
- System.err.println("=> PASS");
- return true;
- }
- return false;
+ if (result1 && result2 && result3 && result4) {
+ System.err.println("=> PASS");
+ return true;
+ }
+ return false;
}
private static boolean testSignature(KeyPair kp, boolean checkInterop,
- Provider prov) {
+ Provider prov) {
byte[] data = PLAINTEXT;
Signature sig1, sig2;
- boolean[] results = new boolean[SIG_ALGOS.length];
+ boolean[] results = new boolean[SIG_ALGOS.length];
for (int i = 0; i < SIG_ALGOS.length; i++) {
String algo = SIG_ALGOS[i];
try {
sig1 = Signature.getInstance(algo, prov);
} catch (NoSuchAlgorithmException nsae) {
System.err.println("Skip unsupported Signature algo: " + algo);
- results[i] = true;
+ results[i] = true;
continue;
}
- try {
- if (checkInterop) {
- sig2 = Signature.getInstance(algo, "SunRsaSign");
- } else {
- sig2 = Signature.getInstance(algo, prov);
- }
- } catch (NoSuchAlgorithmException|NoSuchProviderException nsae) {
- System.err.println("Skip unsupported interop Signature algo: " + algo);
- results[i] = true;
- continue;
+ try {
+ if (checkInterop) {
+ sig2 = Signature.getInstance(algo, "SunRsaSign");
+ } else {
+ sig2 = Signature.getInstance(algo, prov);
+ }
+ } catch (NoSuchAlgorithmException|NoSuchProviderException nsae) {
+ System.err.println("Skip unsupported interop Signature algo: " + algo);
+ results[i] = true;
+ continue;
}
results[i] = testSigning(sig1, sig2, kp, data);
}
- for (int i = 0; i < SIG_ALGOS.length; i++)
- if (!results[i])
- return false;
- return true;
+ for (int i = 0; i < SIG_ALGOS.length; i++)
+ if (!results[i])
+ return false;
+ return true;
}
private static boolean testSignature(int keyLens[], boolean checkInterop,
- Provider prov) {
+ Provider prov) {
byte[] data = PLAINTEXT;
Signature sig1, sig2;
- boolean[] results = new boolean[SIG_ALGOS.length];
+ boolean[] results = new boolean[SIG_ALGOS.length];
for (int i = 0; i < SIG_ALGOS.length; i++) {
String algo = SIG_ALGOS[i];
- results[i] = true;
+ results[i] = true;
try {
sig1 = Signature.getInstance(algo, prov);
} catch (NoSuchAlgorithmException nsae) {
@@ -439,45 +439,45 @@
continue;
}
- try {
- if (checkInterop) {
- sig2 = Signature.getInstance(algo, "SunRsaSign");
- } else {
- sig2 = Signature.getInstance(algo, prov);
- }
+ try {
+ if (checkInterop) {
+ sig2 = Signature.getInstance(algo, "SunRsaSign");
+ } else {
+ sig2 = Signature.getInstance(algo, prov);
+ }
} catch (NoSuchAlgorithmException|NoSuchProviderException nsae) {
System.err.println("Skip unsupported Signature algo: " + algo);
continue;
}
- boolean[] subResults = new boolean[keyLens.length];
+ boolean[] subResults = new boolean[keyLens.length];
for (int h = 0; h < keyLens.length; h++) {
// Defer key pair generation until now when it'll soon be used.
if (kp[h] == null) {
kp[h] = genRSAKey(keyLens[h]);
- if (kp[h] == null) {
- subResults[h] = true;
- continue;
- }
+ if (kp[h] == null) {
+ subResults[h] = true;
+ continue;
+ }
}
System.err.println("Testing Signature " + algo + " w/ KeySize " + keyLens[h]);
subResults[h] = testSigning(sig1, sig2, kp[h], data);
}
- for (int h = 0; h < keyLens.length; h++)
- if (!subResults[h])
- results[i] = false;
+ for (int h = 0; h < keyLens.length; h++)
+ if (!subResults[h])
+ results[i] = false;
}
More information about the distro-pkg-dev
mailing list