You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2020/06/11 10:54:53 UTC
[kylin] branch master updated (7322b5f -> 0884c27)
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git.
from 7322b5f Minor, refactor
new ecc39ef KYLIN-4477 Resolve Issue: Use secure TLSv1.3 instead of insecure TLS
new dadc1dd KYLIN-4478 Resolve Issue: Use secure AES/CFB/PKCS5Padding instead of insecure AES/ECB/PKCS5Padding
new 0884c27 KYLIN-4478 fix unit test
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/kylin/common/util/EncryptUtil.java | 24 ++++++++++++++++------
.../apache/kylin/common/util/EncryptUtilTest.java | 16 +++++++++++++--
.../mr/common/DefaultSslProtocolSocketFactory.java | 2 +-
3 files changed, 33 insertions(+), 9 deletions(-)
[kylin] 03/03: KYLIN-4478 fix unit test
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 0884c2759dbcf88f11fe089fbe9a8b57d9c9b5df
Author: shaofengshi <sh...@apache.org>
AuthorDate: Tue Jun 9 21:54:40 2020 +0800
KYLIN-4478 fix unit test
---
.../org/apache/kylin/common/util/EncryptUtil.java | 24 ++++++++++++++++------
.../apache/kylin/common/util/EncryptUtilTest.java | 16 +++++++++++++--
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java b/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
index d5b486a..b9b4ddb 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
@@ -18,10 +18,17 @@
package org.apache.kylin.common.util;
+import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class EncryptUtil {
@@ -31,14 +38,21 @@ public class EncryptUtil {
private static byte[] key = { 0x74, 0x68, 0x69, 0x73, 0x49, 0x73, 0x41, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b,
0x65, 0x79 };
+ private static final Cipher getCipher(int cipherMode) throws InvalidAlgorithmParameterException,
+ InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, UnsupportedEncodingException {
+ Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
+ final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
+ IvParameterSpec ivSpec = new IvParameterSpec("AAAAAAAAAAAAAAAA".getBytes("UTF-8"));
+ cipher.init(cipherMode, secretKey, ivSpec);
+ return cipher;
+ }
+
public static String encrypt(String strToEncrypt) {
if (strToEncrypt == null) {
return null;
}
try {
- Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
- final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
- cipher.init(Cipher.ENCRYPT_MODE, secretKey);
+ Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
final String encryptedString = Base64.encodeBase64String(cipher.doFinal(strToEncrypt.getBytes(
StandardCharsets.UTF_8)));
return encryptedString;
@@ -52,9 +66,7 @@ public class EncryptUtil {
return null;
}
try {
- Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
- final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
- cipher.init(Cipher.DECRYPT_MODE, secretKey);
+ Cipher cipher = getCipher(Cipher.DECRYPT_MODE);
final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt)), StandardCharsets.UTF_8);
return decryptedString;
} catch (Exception e) {
diff --git a/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java b/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java
index f559229..da985ca 100644
--- a/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java
+++ b/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java
@@ -26,8 +26,20 @@ public class EncryptUtilTest {
@Test
public void testAESEncrypt(){
String input = "hello world";
- String result = EncryptUtil.encrypt(input);
- Assert.assertEquals("4stv/RRleOtvie/8SLHmXA==", result);
+ String result1 = EncryptUtil.encrypt(input);
+ String decrypt1 = EncryptUtil.decrypt(result1);
+ Assert.assertEquals(input, decrypt1);
+ String result2 = EncryptUtil.encrypt(input);
+ Assert.assertEquals(result2, result1);
+
+ input = "this is a long string #&$";
+ result1 = EncryptUtil.encrypt(input);
+ decrypt1 = EncryptUtil.decrypt(result1);
+ Assert.assertEquals(input, decrypt1);
+ result2 = EncryptUtil.encrypt(input);
+ Assert.assertEquals(result2, result1);
+
+
}
@Test
[kylin] 02/03: KYLIN-4478 Resolve Issue: Use secure
AES/CFB/PKCS5Padding instead of insecure AES/ECB/PKCS5Padding
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit dadc1dd6716f7075bfcd6171d3358333475b4ecd
Author: Mahir92 <as...@gmail.com>
AuthorDate: Mon May 4 03:16:37 2020 -0400
KYLIN-4478 Resolve Issue: Use secure AES/CFB/PKCS5Padding instead of insecure AES/ECB/PKCS5Padding
Signed-off-by: shaofengshi <sh...@apache.org>
---
.../src/main/java/org/apache/kylin/common/util/EncryptUtil.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java b/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
index c714eb2..d5b486a 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
@@ -36,7 +36,7 @@ public class EncryptUtil {
return null;
}
try {
- Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
+ Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
final String encryptedString = Base64.encodeBase64String(cipher.doFinal(strToEncrypt.getBytes(
@@ -52,7 +52,7 @@ public class EncryptUtil {
return null;
}
try {
- Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
+ Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt)), StandardCharsets.UTF_8);
[kylin] 01/03: KYLIN-4477 Resolve Issue: Use secure TLSv1.3 instead
of insecure TLS
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git
commit ecc39ef9624e2aed6787ffe40390a7264310735f
Author: Mahir92 <as...@gmail.com>
AuthorDate: Mon May 4 02:06:42 2020 -0400
KYLIN-4477 Resolve Issue: Use secure TLSv1.3 instead of insecure TLS
Signed-off-by: shaofengshi <sh...@apache.org>
---
.../apache/kylin/engine/mr/common/DefaultSslProtocolSocketFactory.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/DefaultSslProtocolSocketFactory.java b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/DefaultSslProtocolSocketFactory.java
index d66e4eb..77c4bee 100644
--- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/DefaultSslProtocolSocketFactory.java
+++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/common/DefaultSslProtocolSocketFactory.java
@@ -130,7 +130,7 @@ public class DefaultSslProtocolSocketFactory implements SecureProtocolSocketFact
private static SSLContext createEasySSLContext() {
try {
- SSLContext context = SSLContext.getInstance("TLS");
+ SSLContext context = SSLContext.getInstance("TLSv1.3");
context.init(null, new TrustManager[] { new DefaultX509TrustManager(null) }, null);
return context;