Permalink
Browse files

[JGRP-1269] ciphers are created using providers, symProvider can be c…

…onfigured
  • Loading branch information...
1 parent 66c6ee5 commit 2e82eaf07da424dbc5465665218287a8c5e35d52 @dereed dereed committed Feb 2, 2011
Showing with 30 additions and 5 deletions.
  1. +30 −5 src/org/jgroups/protocols/ENCRYPT.java
@@ -98,7 +98,9 @@
// encryption properties in no supplied key mode
String asymProvider = null;
- final String symProvider = null;
+
+ String symProvider = null;
+
String asymAlgorithm = "RSA";
String symAlgorithm = DEFAULT_SYM_ALGO;
int asymInit = 512; // initial public/private key length
@@ -235,6 +237,16 @@ public boolean setProperties(Properties props)
log.info("asymProvider used is " + asymProvider);
}
+ str = props.getProperty("sym_provider");
+ if (str != null)
+ {
+ symProvider = str;
+ props.remove("sym_provider");
+
+ if (log.isInfoEnabled())
+ log.info("symProvider used is " + symProvider);
+ }
+
//symmetric algorithm name
str = props.getProperty("key_store_name");
if (str != null)
@@ -431,8 +443,17 @@ private void initSymCiphers(String algorithm, SecretKey secret) throws Exception
if (log.isInfoEnabled())
log.info(" Initializing symmetric ciphers");
- symEncodingCipher = Cipher.getInstance(algorithm);
- symDecodingCipher = Cipher.getInstance(algorithm);
+ if (symProvider != null && symProvider.trim().length() > 0) {
+ symEncodingCipher = Cipher.getInstance(algorithm, symProvider);
+ symDecodingCipher = Cipher.getInstance(algorithm, symProvider);
+ }
+ else {
+ symEncodingCipher = Cipher.getInstance(algorithm);
+ symDecodingCipher = Cipher.getInstance(algorithm);
+ }
+
+
+
symEncodingCipher.init(Cipher.ENCRYPT_MODE, secret);
symDecodingCipher.init(Cipher.DECRYPT_MODE, secret);
@@ -479,7 +500,11 @@ public void initKeyPair() throws Exception
// set up the Cipher to decrypt secret key responses encrypted with our key
- asymCipher = Cipher.getInstance(asymAlgorithm);
+ if (asymProvider != null && asymProvider.trim().length() > 0)
+ asymCipher = Cipher.getInstance(asymAlgorithm, asymProvider);
+ else
+ asymCipher = Cipher.getInstance(asymAlgorithm);
+
asymCipher.init(Cipher.DECRYPT_MODE,Kpair.getPrivate());
if (log.isInfoEnabled())
@@ -1402,4 +1427,4 @@ protected String getVersion()
return version;
}
}
-}
+}

0 comments on commit 2e82eaf

Please sign in to comment.