|
From: <pe...@us...> - 2003-11-21 04:43:46
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto
In directory sc8-pr-cvs1:/tmp/cvs-serv10533/src/test/org/neuclear/commons/crypto
Modified Files:
CryptoToolsTest.java SigningBenchmark.java
Log Message:
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
Otherwise You will Finaliate.
Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
This should hopefully make everything more stable (and secure).
Index: CryptoToolsTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/CryptoToolsTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CryptoToolsTest.java 11 Nov 2003 21:17:52 -0000 1.1
--- CryptoToolsTest.java 21 Nov 2003 04:43:42 -0000 1.2
***************
*** 2,5 ****
--- 2,11 ----
$Id$
$Log$
+ Revision 1.2 2003/11/21 04:43:42 pelle
+ EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
+ Otherwise You will Finaliate.
+ Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
+ This should hopefully make everything more stable (and secure).
+
Revision 1.1 2003/11/11 21:17:52 pelle
Further vital reshuffling.
***************
*** 92,96 ****
* @author Pelle Braendgaard
*/
! public class CryptoToolsTest extends TestCase {
public CryptoToolsTest() {
super("CryptoToolsTest");
--- 98,102 ----
* @author Pelle Braendgaard
*/
! public final class CryptoToolsTest extends TestCase {
public CryptoToolsTest() {
super("CryptoToolsTest");
***************
*** 98,102 ****
}
! public CryptoToolsTest(String name) {
super(name);
}
--- 104,108 ----
}
! public CryptoToolsTest(final String name) {
super(name);
}
***************
*** 104,111 ****
/**
*/
! protected void setUp() {
}
! protected void tearDown() {
}
--- 110,117 ----
/**
*/
! protected final void setUp() {
}
! protected final void tearDown() {
}
***************
*** 116,139 ****
}
! public void testPadding() {
! byte src[] = new byte[20];
for (int i = 0; i < src.length; i++)
src[i] = (byte) ("a".getBytes()[0] + i);
System.out.println("Source array='" + new String(src));
! byte padded[] = CryptoTools.pad(src, 14);
System.out.println("Dest array='" + new String(padded));
assertEquals(padded.length % 14, 0);
}
! public void testSymmetricKeyEncryption() throws CryptoException {
! String contentString = "<xml>Hello</xml>";
! byte password[] = "Three Brown Geese sledded down the hill".getBytes();
! byte contents[] = contentString.getBytes();
! byte encrypted[] = CryptoTools.encrypt(password, contents);
! String encryptString = new String(encrypted);
! byte decrypted[] = CryptoTools.decrypt(password, encrypted);
! byte depadded[] = new byte[contents.length];
System.arraycopy(decrypted, 0, depadded, 0, depadded.length);
! String decryptString = new String(depadded);
System.out.println("Original: " + contentString);
System.out.println("Encrypted: " + encryptString);
--- 122,145 ----
}
! public final void testPadding() {
! final byte[] src = new byte[20];
for (int i = 0; i < src.length; i++)
src[i] = (byte) ("a".getBytes()[0] + i);
System.out.println("Source array='" + new String(src));
! final byte[] padded = CryptoTools.pad(src, 14);
System.out.println("Dest array='" + new String(padded));
assertEquals(padded.length % 14, 0);
}
! public final void testSymmetricKeyEncryption() throws CryptoException {
! final String contentString = "<xml>Hello</xml>";
! final byte[] password = "Three Brown Geese sledded down the hill".getBytes();
! final byte[] contents = contentString.getBytes();
! final byte[] encrypted = CryptoTools.encrypt(password, contents);
! final String encryptString = new String(encrypted);
! final byte[] decrypted = CryptoTools.decrypt(password, encrypted);
! final byte[] depadded = new byte[contents.length];
System.arraycopy(decrypted, 0, depadded, 0, depadded.length);
! final String decryptString = new String(depadded);
System.out.println("Original: " + contentString);
System.out.println("Encrypted: " + encryptString);
Index: SigningBenchmark.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/crypto/SigningBenchmark.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SigningBenchmark.java 12 Nov 2003 23:47:50 -0000 1.2
--- SigningBenchmark.java 21 Nov 2003 04:43:42 -0000 1.3
***************
*** 26,29 ****
--- 26,35 ----
$Id$
$Log$
+ Revision 1.3 2003/11/21 04:43:42 pelle
+ EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
+ Otherwise You will Finaliate.
+ Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
+ This should hopefully make everything more stable (and secure).
+
Revision 1.2 2003/11/12 23:47:50 pelle
Much work done in creating good test environment.
***************
*** 40,45 ****
* signing and verification.
*/
! public class SigningBenchmark {
! public SigningBenchmark(String algorithm, int size) throws NoSuchAlgorithmException {
kpg = KeyPairGenerator.getInstance(algorithm);
kpg.initialize(size);
--- 46,51 ----
* signing and verification.
*/
! public final class SigningBenchmark {
! public SigningBenchmark(final String algorithm, final int size) throws NoSuchAlgorithmException {
kpg = KeyPairGenerator.getInstance(algorithm);
kpg.initialize(size);
***************
*** 51,67 ****
! public void generateKeys() {
kp = kpg.generateKeyPair();
}
! public void sign() throws CryptoException {
testsig = CryptoTools.sign(kp, testdata);
}
! public void verify() throws CryptoException {
CryptoTools.verify(kp.getPublic(), testdata, testsig);
}
! public void benchmark() throws CryptoException {
Date start = new Date();
--- 57,73 ----
! public final void generateKeys() {
kp = kpg.generateKeyPair();
}
! public final void sign() throws CryptoException {
testsig = CryptoTools.sign(kp, testdata);
}
! public final void verify() throws CryptoException {
CryptoTools.verify(kp.getPublic(), testdata, testsig);
}
! public final void benchmark() throws CryptoException {
Date start = new Date();
***************
*** 85,98 ****
}
! public void printResults() {
System.out.println(algorithm + "\t" + size + "\t" + results[0] + "\t" + results[1] + "\t" + results[2]);
}
! public static void main(String args[]) {
System.out.println("Performance Analysis of key sizes and algorithms");
! String algorithms[] = new String[]{"RSA", "DSA"};
! int keysizes[] = new int[]{512, 1024};
try {
for (int a = 0; a < algorithms.length; a++)
--- 91,104 ----
}
! public final void printResults() {
System.out.println(algorithm + "\t" + size + "\t" + results[0] + "\t" + results[1] + "\t" + results[2]);
}
! public static void main(final String[] args) {
System.out.println("Performance Analysis of key sizes and algorithms");
! final String[] algorithms = new String[]{"RSA", "DSA"};
! final int[] keysizes = new int[]{512, 1024};
try {
for (int a = 0; a < algorithms.length; a++)
***************
*** 107,120 ****
}
! private static int ITERATIONS = 100;
! private KeyPairGenerator kpg;
private KeyPair kp;
! private String algorithm;
! private int size;
! private long[] results;
! private static String TESTSTRING = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
--- 113,126 ----
}
! private static final int ITERATIONS = 100;
! private final KeyPairGenerator kpg;
private KeyPair kp;
! private final String algorithm;
! private final int size;
! private final long[] results;
! private static final String TESTSTRING = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
***************
*** 133,137 ****
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private byte[] testsig;
! private byte[] testdata;
}
--- 139,143 ----
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private byte[] testsig;
! private final byte[] testdata;
}
|