|
From: <pe...@us...> - 2003-12-06 00:16:37
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto
In directory sc8-pr-cvs1:/tmp/cvs-serv4564/src/java/org/neuclear/commons/crypto
Modified Files:
CryptoTools.java RawCertificate.java
Log Message:
Updated various areas in NSTools.
Updated URI Validation in particular to support new expanded format
Updated createUniqueID and friends to be a lot more unique and more efficient.
In CryptoTools updated getRandom() to finally use a SecureRandom.
Changed CryptoTools.getFormatURLSafe to getBase36 because that is what it really is.
Index: CryptoTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/CryptoTools.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CryptoTools.java 21 Nov 2003 04:43:41 -0000 1.5
--- CryptoTools.java 6 Dec 2003 00:16:35 -0000 1.6
***************
*** 2,5 ****
--- 2,12 ----
* $Id$
* $Log$
+ * Revision 1.6 2003/12/06 00:16:35 pelle
+ * Updated various areas in NSTools.
+ * Updated URI Validation in particular to support new expanded format
+ * Updated createUniqueID and friends to be a lot more unique and more efficient.
+ * In CryptoTools updated getRandom() to finally use a SecureRandom.
+ * Changed CryptoTools.getFormatURLSafe to getBase36 because that is what it really is.
+ *
* Revision 1.5 2003/11/21 04:43:41 pelle
* EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 484,488 ****
}
! public static String formatAsURLSafe(final byte[] val) {
final BigInteger big = new BigInteger(val);
return big.toString(36);
--- 491,495 ----
}
! public static String formatAsBase36(final byte[] val) {
final BigInteger big = new BigInteger(val);
return big.toString(36);
***************
*** 490,494 ****
public static String createRandomID() {
! final BigInteger big = new BigInteger(4096, getRandomInstance());
return big.toString(36);
}
--- 497,506 ----
public static String createRandomID() {
! return createRandomID(RAND_BIT_LENGTH);
!
! }
!
! public static String createRandomID(int length) {
! final BigInteger big = new BigInteger(length, getRandomInstance());
return big.toString(36);
}
***************
*** 496,500 ****
private static synchronized Random getRandomInstance() {
if (randSource == null)
! randSource = new Random();
return randSource;
}
--- 508,516 ----
private static synchronized Random getRandomInstance() {
if (randSource == null)
! try {
! randSource = SecureRandom.getInstance("SHA1PRNG");
! } catch (NoSuchAlgorithmException e) {
! throw new RuntimeException(e);
! }
return randSource;
}
***************
*** 737,743 ****
public static final byte[] hexTable = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
! private static Random randSource;
public final static String DEFAULT_KEYSTORE = System.getProperty("user.home") + "/.keystore";
}
--- 753,760 ----
public static final byte[] hexTable = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
! private static SecureRandom randSource;
public final static String DEFAULT_KEYSTORE = System.getProperty("user.home") + "/.keystore";
+ public static final int RAND_BIT_LENGTH = 128;
}
Index: RawCertificate.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/RawCertificate.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RawCertificate.java 21 Nov 2003 04:43:41 -0000 1.2
--- RawCertificate.java 6 Dec 2003 00:16:35 -0000 1.3
***************
*** 26,29 ****
--- 26,36 ----
$Id$
$Log$
+ Revision 1.3 2003/12/06 00:16:35 pelle
+ Updated various areas in NSTools.
+ Updated URI Validation in particular to support new expanded format
+ Updated createUniqueID and friends to be a lot more unique and more efficient.
+ In CryptoTools updated getRandom() to finally use a SecureRandom.
+ Changed CryptoTools.getFormatURLSafe to getBase36 because that is what it really is.
+
Revision 1.2 2003/11/21 04:43:41 pelle
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
***************
*** 89,93 ****
public final String toString() {
try {
! return CryptoTools.formatAsURLSafe(CryptoTools.digest(getEncoded()));
} catch (Exception e) {
return "error";
--- 96,100 ----
public final String toString() {
try {
! return CryptoTools.formatAsBase36(CryptoTools.digest(getEncoded()));
} catch (Exception e) {
return "error";
|