Updated Branches:
  refs/heads/master a5e32ddae -> 03aa3979d

More checks for ciphers before actually executing the test

Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/1d800d37
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/1d800d37
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/1d800d37

Branch: refs/heads/master
Commit: 1d800d37ab473ec3704ee879d05033375f2ec88c
Parents: a5e32dd
Author: Guillaume Nodet <[email protected]>
Authored: Wed Jan 29 10:14:09 2014 +0100
Committer: Guillaume Nodet <[email protected]>
Committed: Wed Jan 29 10:14:09 2014 +0100

----------------------------------------------------------------------
 .../src/test/java/org/apache/sshd/CipherTest.java | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1d800d37/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/CipherTest.java 
b/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
index c992ff5..0b7e2d1 100644
--- a/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
@@ -61,7 +61,7 @@ public class CipherTest {
 
     @Test
     public void testAES192CBC() throws Exception {
-        if (SecurityUtils.isBouncyCastleRegistered()) {
+        if (SecurityUtils.isBouncyCastleRegistered() && 
checkCipher(com.jcraft.jsch.jce.AES192CBC.class.getName())) {
             setUp(new AES192CBC.Factory());
             runTest();
         }
@@ -69,7 +69,7 @@ public class CipherTest {
 
     @Test
     public void testAES256CBC() throws Exception {
-        if (SecurityUtils.isBouncyCastleRegistered()) {
+        if (SecurityUtils.isBouncyCastleRegistered() && 
checkCipher(com.jcraft.jsch.jce.AES256CBC.class.getName())) {
             setUp(new AES256CBC.Factory());
             runTest();
         }
@@ -156,4 +156,18 @@ public class CipherTest {
         c.disconnect();
         s.disconnect();
     }
+
+    static boolean checkCipher(String cipher){
+        try{
+            Class c=Class.forName(cipher);
+            com.jcraft.jsch.Cipher _c = 
(com.jcraft.jsch.Cipher)(c.newInstance());
+            _c.init(com.jcraft.jsch.Cipher.ENCRYPT_MODE,
+                    new byte[_c.getBlockSize()],
+                    new byte[_c.getIVSize()]);
+            return true;
+        }
+        catch(Exception e){
+            return false;
+        }
+    }
 }

Reply via email to