You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/01/31 15:08:34 UTC
[cxf] 01/02: Hack to fix CryptoUtils test on 1.8.0_161 or later
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 0faf006f90aea704c27e4db0ed276d1d307de2cb
Author: Sergey Beryozkin <sb...@gmail.com>
AuthorDate: Thu Jan 25 18:05:51 2018 +0000
Hack to fix CryptoUtils test on 1.8.0_161 or later
(cherry picked from commit 1236b09b624194304071063670580f14e49b6cc3)
# Conflicts:
# rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
---
.../org/apache/cxf/rt/security/crypto/CryptoUtils.java | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java b/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
index 19fd66f..64cbb11 100644
--- a/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
+++ b/rt/security/src/main/java/org/apache/cxf/rt/security/crypto/CryptoUtils.java
@@ -545,7 +545,14 @@ public final class CryptoUtils {
result = c.doFinal(bytes);
} else {
if (blockSize == -1) {
- blockSize = secretKey instanceof PublicKey ? 117 : 128;
+ String javaVersion = System.getProperty("java.version");
+ if (javaVersion.startsWith("9") || isJava8Release161OrLater(javaVersion)) {
+ //the default block size is 256 when use private key under java9
+ blockSize = secretKey instanceof PublicKey ? 117 : 256;
+ } else {
+
+ blockSize = secretKey instanceof PublicKey ? 117 : 128;
+ }
}
boolean updateRequired = keyProps != null && keyProps.getAdditionalData() != null;
int offset = 0;
@@ -568,7 +575,11 @@ public final class CryptoUtils {
throw new SecurityException(ex);
}
}
-
+
+ private static boolean isJava8Release161OrLater(String javaVersion) {
+ return javaVersion.startsWith("1.8.0_") && Integer.valueOf(javaVersion.substring(6)) >= 161;
+ }
+
public static Cipher initCipher(Key secretKey, KeyProperties keyProps, int mode) throws SecurityException {
try {
String algorithm = keyProps != null && keyProps.getKeyAlgo() != null
--
To stop receiving notification emails like this one, please contact
coheigea@apache.org.