directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yan...@apache.org
Subject directory-kerby git commit: YanYan fixed DIRKRB-512, Java building error: Illegal key size
Date Tue, 29 Dec 2015 03:40:33 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master a604932d0 -> 9a740c7d2


YanYan fixed DIRKRB-512, Java building error: Illegal key size


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/9a740c7d
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/9a740c7d
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/9a740c7d

Branch: refs/heads/master
Commit: 9a740c7d216a04c8f4ce221bb9b8ec86dc256ca9
Parents: a604932
Author: YaningX <yaning0123@gmail.com>
Authored: Tue Dec 29 11:40:04 2015 +0800
Committer: YaningX <yaning0123@gmail.com>
Committed: Tue Dec 29 11:40:04 2015 +0800

----------------------------------------------------------------------
 .../kerberos/kerb/crypto/EncryptionHandler.java | 19 --------
 .../kerberos/kerb/crypto/CheckSumsTest.java     |  3 +-
 .../kerberos/kerb/crypto/DecryptionTest.java    | 11 ++---
 .../kerberos/kerb/crypto/FastUtilTest.java      |  3 +-
 .../kerberos/kerb/crypto/KeyDeriveTest.java     |  7 +--
 .../kerby/kerberos/kerb/crypto/PrfTest.java     |  3 +-
 .../kerberos/kerb/crypto/String2keyTest.java    | 17 ++++----
 .../kerberos/kerb/util/EncryptionTest.java      |  3 +-
 .../kerberos/kerb/util/NewEncryptionTest.java   |  3 +-
 .../org/apache/commons/ssl/TestKeyMaterial.java |  5 +++
 .../org/apache/commons/ssl/TestOpenSSL.java     |  3 ++
 .../org/apache/commons/ssl/TestPKCS8Key.java    |  3 ++
 .../apache/kerby/util/ByteArrayReadLine.java    | 20 +++++++++
 .../org/apache/kerby/util/EncryptoUtil.java     | 46 ++++++++++++++++++++
 .../java/org/apache/kerby/util/ReadLine.java    | 19 ++++++++
 15 files changed, 125 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
index 91d7e34..0e6344b 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/EncryptionHandler.java
@@ -38,8 +38,6 @@ import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
 import org.apache.kerby.kerberos.kerb.type.base.KeyUsage;
 import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
 
-import javax.crypto.Cipher;
-
 /**
  * Encryption handler as the highest level API for encryption stuffs defined in
  * Kerberos RFC3961. It supports all the encryption types. New encryption type
@@ -47,23 +45,6 @@ import javax.crypto.Cipher;
  */
 public class EncryptionHandler {
 
-    private static boolean isAES256Enabled = false;
-
-    static {
-        try {
-            isAES256Enabled = Cipher.getMaxAllowedKeyLength("AES") >= 256;
-        } catch (Exception e) {
-            System.err.println(e);
-        }
-    }
-
-    /**
-     * @return true if aes256 is enabled
-     */
-    public static boolean isAES256Enabled() {
-        return isAES256Enabled;
-    }
-
     /**
      * Get the encryption type.
      * @param eType The encryption type string.

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumsTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumsTest.java
b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumsTest.java
index 9220f94..fc23f77 100644
--- a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumsTest.java
+++ b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumsTest.java
@@ -23,6 +23,7 @@ import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
 import org.apache.kerby.kerberos.kerb.type.base.CheckSumType;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
 import org.apache.kerby.kerberos.kerb.type.base.KeyUsage;
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.HexUtil;
 import org.junit.Test;
 
@@ -112,7 +113,7 @@ public class CheckSumsTest {
 
     @Test
     public void testCheckSums_HMAC_SHA1_96_AES256() throws Exception {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new CksumTest(
             "fourteen",

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/DecryptionTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/DecryptionTest.java
b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/DecryptionTest.java
index c0c938d..cf0bda2 100644
--- a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/DecryptionTest.java
+++ b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/DecryptionTest.java
@@ -22,6 +22,7 @@ package org.apache.kerby.kerberos.kerb.crypto;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
 import org.apache.kerby.kerberos.kerb.type.base.KeyUsage;
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.HexUtil;
 import org.junit.Test;
 
@@ -695,7 +696,7 @@ public class DecryptionTest {
      */
     @Test
     public void testDecryptAES256_CTS_HMAC_SHA1_96_0() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         TestCase testCase = new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -715,7 +716,7 @@ public class DecryptionTest {
      */
     @Test
     public void testDecryptAES256_CTS_HMAC_SHA1_96_1() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         TestCase testCase = new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -735,7 +736,7 @@ public class DecryptionTest {
      */
     @Test
     public void testDecryptAES256_CTS_HMAC_SHA1_96_9() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         TestCase testCase = new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -756,7 +757,7 @@ public class DecryptionTest {
      */
     @Test
     public void testDecryptAES256_CTS_HMAC_SHA1_96_13() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         TestCase testCase = new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -777,7 +778,7 @@ public class DecryptionTest {
      */
     @Test
     public void testDecryptAES256_CTS_HMAC_SHA1_96_30() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         TestCase testCase = new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/FastUtilTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/FastUtilTest.java
b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/FastUtilTest.java
index a08f01f..5130ed5 100644
--- a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/FastUtilTest.java
+++ b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/FastUtilTest.java
@@ -22,6 +22,7 @@ package org.apache.kerby.kerberos.kerb.crypto;
 import org.apache.kerby.kerberos.kerb.crypto.fast.FastUtil;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.HexUtil;
 import org.junit.Test;
 
@@ -125,7 +126,7 @@ public class FastUtilTest {
 
     @Test
     public void testFastUtil_AES256_CTS_HMAC_SHA1() throws Exception {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/KeyDeriveTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/KeyDeriveTest.java
b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/KeyDeriveTest.java
index 7b44da0..3d9ee9a 100644
--- a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/KeyDeriveTest.java
+++ b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/KeyDeriveTest.java
@@ -29,6 +29,7 @@ import org.apache.kerby.kerberos.kerb.crypto.key.CamelliaKeyMaker;
 import org.apache.kerby.kerberos.kerb.crypto.key.Des3KeyMaker;
 import org.apache.kerby.kerberos.kerb.crypto.key.DkKeyMaker;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.HexUtil;
 import org.junit.Test;
 
@@ -126,7 +127,7 @@ public class KeyDeriveTest {
     
     @Test
     public void testKeyDerive_AES256_CTS_HMAC_SHA1_96_299() throws Exception {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -140,7 +141,7 @@ public class KeyDeriveTest {
     
     @Test
     public void testKeyDerive_AES256_CTS_HMAC_SHA1_96_2AA() throws Exception {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -154,7 +155,7 @@ public class KeyDeriveTest {
     
     @Test
     public void testKeyDerive_AES256_CTS_HMAC_SHA1_96_255() throws Exception {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/PrfTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/PrfTest.java
b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/PrfTest.java
index c5dcac6..b87ba9b 100644
--- a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/PrfTest.java
+++ b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/PrfTest.java
@@ -20,6 +20,7 @@
 package org.apache.kerby.kerberos.kerb.crypto;
 
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.HexUtil;
 import org.junit.Test;
 
@@ -86,7 +87,7 @@ public class PrfTest {
 
     @Test
     public void testPrf_AES256_CTS_HMAC_SHA1() throws Exception {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/String2keyTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/String2keyTest.java
b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/String2keyTest.java
index abbbbfb..042b42a 100644
--- a/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/String2keyTest.java
+++ b/kerby-kerb/kerb-crypto/src/test/java/org/apache/kerby/kerberos/kerb/crypto/String2keyTest.java
@@ -21,6 +21,7 @@ package org.apache.kerby.kerberos.kerb.crypto;
 
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.HexUtil;
 import org.junit.Test;
 
@@ -270,7 +271,7 @@ public class String2keyTest {
 
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_0() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -284,7 +285,7 @@ public class String2keyTest {
 
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_1() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -298,7 +299,7 @@ public class String2keyTest {
 
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_2() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -312,7 +313,7 @@ public class String2keyTest {
 
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_3() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -326,7 +327,7 @@ public class String2keyTest {
 
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_4() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -342,7 +343,7 @@ public class String2keyTest {
 
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_5() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -356,7 +357,7 @@ public class String2keyTest {
 
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_6() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,
@@ -371,7 +372,7 @@ public class String2keyTest {
     // Check for KRB5_ERR_BAD_S2K_PARAMS return when weak iteration counts are forbidden
     @Test
     public void test_AES256_CTS_HMAC_SHA1_96_7() {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         performTest(new TestCase(
                 EncryptionType.AES256_CTS_HMAC_SHA1_96,

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
index a00667a..2ae0baa 100644
--- a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
+++ b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
@@ -31,6 +31,7 @@ import org.apache.kerby.kerberos.kerb.type.base.KeyUsage;
 import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
 import org.apache.kerby.kerberos.kerb.type.ticket.EncTicketPart;
 import org.apache.kerby.kerberos.kerb.type.ticket.Ticket;
+import org.apache.kerby.util.EncryptoUtil;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -74,7 +75,7 @@ public class EncryptionTest {
 
     @Test
     public void testAes256() throws IOException, KrbException {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         testEncWith("aes256-cts-hmac-sha1-96.cc");
     }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/NewEncryptionTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/NewEncryptionTest.java
b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/NewEncryptionTest.java
index 5790bda..8ccbb03 100644
--- a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/NewEncryptionTest.java
+++ b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/NewEncryptionTest.java
@@ -25,6 +25,7 @@ import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
 import org.apache.kerby.kerberos.kerb.type.base.EncryptionType;
 import org.apache.kerby.kerberos.kerb.type.base.KeyUsage;
+import org.apache.kerby.util.EncryptoUtil;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -67,7 +68,7 @@ public class NewEncryptionTest {
 
     @Test
     public void testAes256CtsHmacSha1() throws IOException, KrbException {
-        assumeTrue(EncryptionHandler.isAES256Enabled());
+        assumeTrue(EncryptoUtil.isAES256Enabled());
 
         testEncWith(EncryptionType.AES256_CTS_HMAC_SHA1_96);
     }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-pkix/src/test/java/org/apache/commons/ssl/TestKeyMaterial.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/commons/ssl/TestKeyMaterial.java b/kerby-pkix/src/test/java/org/apache/commons/ssl/TestKeyMaterial.java
index 2b9329e..99a98e1 100644
--- a/kerby-pkix/src/test/java/org/apache/commons/ssl/TestKeyMaterial.java
+++ b/kerby-pkix/src/test/java/org/apache/commons/ssl/TestKeyMaterial.java
@@ -1,5 +1,6 @@
 package org.apache.commons.ssl;
 
+import org.apache.kerby.util.EncryptoUtil;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.junit.Test;
 
@@ -14,6 +15,7 @@ import java.util.Locale;
 import static org.apache.commons.ssl.JUnitConfig.TEST_HOME;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
 
 public class TestKeyMaterial {
     public static final char[] PASSWORD1 = "changeit".toCharArray();
@@ -54,7 +56,10 @@ public class TestKeyMaterial {
 
         Date today = new Date();
         KeyMaterial km;
+
+
         try {
+            assumeTrue(EncryptoUtil.isAES256Enabled());
             km = new KeyMaterial(dir + "/" + fileName, file2, pass1, pass2);
         } catch (ProbablyBadPasswordException pbpe) {
             System.out.println("  WARN:  " + pbpe);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-pkix/src/test/java/org/apache/commons/ssl/TestOpenSSL.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/commons/ssl/TestOpenSSL.java b/kerby-pkix/src/test/java/org/apache/commons/ssl/TestOpenSSL.java
index b4f26de..df6837f 100644
--- a/kerby-pkix/src/test/java/org/apache/commons/ssl/TestOpenSSL.java
+++ b/kerby-pkix/src/test/java/org/apache/commons/ssl/TestOpenSSL.java
@@ -1,5 +1,6 @@
 package org.apache.commons.ssl;
 
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.Util;
 import org.junit.Test;
 
@@ -12,6 +13,7 @@ import java.util.Random;
 import static org.apache.commons.ssl.JUnitConfig.TEST_HOME;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
 public class TestOpenSSL {
 
@@ -130,6 +132,7 @@ public class TestOpenSSL {
                     byte[] encrypted = Util.streamToBytes(in);
                     char[] pwd = "changeit".toCharArray();
                     try {
+                        assumeTrue(EncryptoUtil.isAES256Enabled());
                         byte[] result = OpenSSL.decrypt(cipher, pwd, encrypted);
                         String s = new String(result, "ISO-8859-1");
                         if (!"Hello World!".equals(s)) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-pkix/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java b/kerby-pkix/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
index c166f42..59127da 100644
--- a/kerby-pkix/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
+++ b/kerby-pkix/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
@@ -1,5 +1,6 @@
 package org.apache.commons.ssl;
 
+import org.apache.kerby.util.EncryptoUtil;
 import org.apache.kerby.util.Util;
 import org.junit.Test;
 
@@ -11,6 +12,7 @@ import java.util.Locale;
 import static org.apache.commons.ssl.JUnitConfig.TEST_HOME;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
 public class TestPKCS8Key {
 
@@ -44,6 +46,7 @@ public class TestPKCS8Key {
             System.out.println("Checking PKCS file:" + filename);
             FileInputStream in = new FileInputStream(f);
             byte[] bytes = Util.streamToBytes(in);
+            assumeTrue(EncryptoUtil.isAES256Enabled());
             PKCS8Key key = new PKCS8Key(bytes, password.toCharArray());
             byte[] decrypted = key.getDecryptedBytes();
             if (original == null) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-util/src/main/java/org/apache/kerby/util/ByteArrayReadLine.java
----------------------------------------------------------------------
diff --git a/kerby-util/src/main/java/org/apache/kerby/util/ByteArrayReadLine.java b/kerby-util/src/main/java/org/apache/kerby/util/ByteArrayReadLine.java
index 557181e..c0323d1 100644
--- a/kerby-util/src/main/java/org/apache/kerby/util/ByteArrayReadLine.java
+++ b/kerby-util/src/main/java/org/apache/kerby/util/ByteArrayReadLine.java
@@ -1,3 +1,23 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+
 package org.apache.kerby.util;
 
 import java.io.ByteArrayInputStream;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-util/src/main/java/org/apache/kerby/util/EncryptoUtil.java
----------------------------------------------------------------------
diff --git a/kerby-util/src/main/java/org/apache/kerby/util/EncryptoUtil.java b/kerby-util/src/main/java/org/apache/kerby/util/EncryptoUtil.java
new file mode 100644
index 0000000..a9e4b7a
--- /dev/null
+++ b/kerby-util/src/main/java/org/apache/kerby/util/EncryptoUtil.java
@@ -0,0 +1,46 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+
+package org.apache.kerby.util;
+
+import javax.crypto.Cipher;
+
+/**
+ * This class gives a method to detect if system support AES256 or above.
+ */
+public class EncryptoUtil {
+    private static boolean isAES256Enabled = false;
+
+    static {
+        try {
+            isAES256Enabled = Cipher.getMaxAllowedKeyLength("AES") >= 256;
+        } catch (Exception e) {
+            System.err.println(e);
+        }
+    }
+
+    /**
+     * @return true if aes256 is enabled
+     */
+    public static boolean isAES256Enabled() {
+        return isAES256Enabled;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9a740c7d/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java
----------------------------------------------------------------------
diff --git a/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java b/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java
index 9d30095..f7a1db0 100644
--- a/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java
+++ b/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java
@@ -1,3 +1,22 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
 package org.apache.kerby.util;
 
 import java.io.IOException;


Mime
View raw message