|
From: <pe...@us...> - 2003-11-20 23:41:39
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto
In directory sc8-pr-cvs1:/tmp/cvs-serv31139/src/java/org/neuclear/commons/crypto
Modified Files:
CryptoTools.java
Log Message:
Getting all the tests to work in id
Removing usage of BC in CryptoTools as it was causing issues.
First version of EntityLedger that will use OFB's EntityEngine. This will allow us to support a vast amount databases without
writing SQL. (Yipee)
Index: CryptoTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/CryptoTools.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CryptoTools.java 19 Nov 2003 23:32:50 -0000 1.3
--- CryptoTools.java 20 Nov 2003 23:41:36 -0000 1.4
***************
*** 2,5 ****
--- 2,11 ----
* $Id$
* $Log$
+ * Revision 1.4 2003/11/20 23:41:36 pelle
+ * Getting all the tests to work in id
+ * Removing usage of BC in CryptoTools as it was causing issues.
+ * First version of EntityLedger that will use OFB's EntityEngine. This will allow us to support a vast amount databases without
+ * writing SQL. (Yipee)
+ *
* Revision 1.3 2003/11/19 23:32:50 pelle
* Signers now can generatekeys via the generateKey() method.
***************
*** 362,368 ****
public static Cipher getCipher(byte key[], boolean doencrypt) throws CryptoException {
try {
! Cipher cipher = Cipher.getInstance("AES", "BC");
KeySpec keyspec = new SecretKeySpec(key, "AES");
! SecretKeyFactory kf = SecretKeyFactory.getInstance("AES", "BC");
Key skey = kf.generateSecret(keyspec);
cipher.init(doencrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, skey);
--- 368,374 ----
public static Cipher getCipher(byte key[], boolean doencrypt) throws CryptoException {
try {
! Cipher cipher = Cipher.getInstance("AES");
KeySpec keyspec = new SecretKeySpec(key, "AES");
! SecretKeyFactory kf = SecretKeyFactory.getInstance("AES");
Key skey = kf.generateSecret(keyspec);
cipher.init(doencrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, skey);
***************
*** 376,381 ****
} catch (InvalidKeyException e) {
rethrowException(e);
- } catch (NoSuchProviderException e) {
- rethrowException(e);
}
return null;
--- 382,385 ----
***************
*** 406,414 ****
Signature sig = null;
if (key instanceof RSAPrivateKey)
! sig = Signature.getInstance("SHA1withRSA", "BC"); // Set up signature object.
else if (key instanceof DSAPrivateKey)
! sig = Signature.getInstance("SHA1withDSA", "BC");
else if (key instanceof ECPrivateKey)
! sig = Signature.getInstance("SHA1withECDSA", "BC");
sig.initSign(key); // Initialize with my private signing key.
--- 410,418 ----
Signature sig = null;
if (key instanceof RSAPrivateKey)
! sig = Signature.getInstance("SHA1withRSA"); // Set up signature object.
else if (key instanceof DSAPrivateKey)
! sig = Signature.getInstance("SHA1withDSA");
else if (key instanceof ECPrivateKey)
! sig = Signature.getInstance("SHA1withECDSA");
sig.initSign(key); // Initialize with my private signing key.
***************
*** 420,427 ****
Signature sig = null;
if (pk instanceof DSAPublicKey) {
! sig = Signature.getInstance("SHA1withDSA", "BC"); // Set up signature object.
sigvalue = convertXMLDSIGtoASN1(sigvalue);
} else if (pk instanceof RSAPublicKey) {
! sig = Signature.getInstance("SHA1withRSA", "BC");
}
sig.initVerify(pk); // Initialize with my private signing key.
--- 424,431 ----
Signature sig = null;
if (pk instanceof DSAPublicKey) {
! sig = Signature.getInstance("SHA1withDSA"); // Set up signature object.
sigvalue = convertXMLDSIGtoASN1(sigvalue);
} else if (pk instanceof RSAPublicKey) {
! sig = Signature.getInstance("SHA1withRSA");
}
sig.initVerify(pk); // Initialize with my private signing key.
***************
*** 585,589 ****
public static PublicKey createPK(String mod, String exp) throws CryptoException {
try {
! KeyFactory rsaFactory = KeyFactory.getInstance("RSA", "BC");
RSAPublicKeySpec rsaKeyspec = new RSAPublicKeySpec(new BigInteger(Base64.decode(mod)), new BigInteger(Base64.decode(exp)));
return rsaFactory.generatePublic(rsaKeyspec);
--- 589,593 ----
public static PublicKey createPK(String mod, String exp) throws CryptoException {
try {
! KeyFactory rsaFactory = KeyFactory.getInstance("RSA");
RSAPublicKeySpec rsaKeyspec = new RSAPublicKeySpec(new BigInteger(Base64.decode(mod)), new BigInteger(Base64.decode(exp)));
return rsaFactory.generatePublic(rsaKeyspec);
***************
*** 592,598 ****
throw new CryptoException(e);
} catch (InvalidKeySpecException e) {
- e.printStackTrace(System.err);
- throw new CryptoException(e);
- } catch (NoSuchProviderException e) {
e.printStackTrace(System.err);
throw new CryptoException(e);
--- 596,599 ----
|