You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2023/09/26 00:39:46 UTC
[shardingsphere] branch master updated: Remove like and rc4 in ShardingSphere encrypt and move to ShardingSphere plugin repository (#28580)
This is an automated email from the ASF dual-hosted git repository.
chengzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 3b220d7e8bf Remove like and rc4 in ShardingSphere encrypt and move to ShardingSphere plugin repository (#28580)
3b220d7e8bf is described below
commit 3b220d7e8bf8f31f24c16a7bfa176bbe45e43fa0
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Tue Sep 26 08:39:40 2023 +0800
Remove like and rc4 in ShardingSphere encrypt and move to ShardingSphere plugin repository (#28580)
* Remove like and rc4 in ShardingSphere encrypt and move to ShardingSphere plugin repository
* fix unit test
---
docs/document/content/dev-manual/encrypt.cn.md | 2 -
docs/document/content/dev-manual/encrypt.en.md | 2 -
.../common-config/builtin-algorithm/encrypt.cn.md | 25 -----
.../common-config/builtin-algorithm/encrypt.en.md | 25 -----
.../algorithm/standard/RC4EncryptAlgorithm.java | 110 ---------------------
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 2 -
.../like/CharDigestLikeEncryptAlgorithmTest.java | 71 -------------
.../standard/RC4EncryptAlgorithmTest.java | 79 ---------------
.../core/src/test/resources/yaml/encrypt-rule.yaml | 5 -
.../src/main/antlr4/imports/encrypt/BaseRule.g4 | 11 +--
.../src/main/antlr4/imports/encrypt/Keyword.g4 | 16 ---
.../resources/conf/convert/config-encrypt.yaml | 2 +-
.../test/resources/conf/import/config-encrypt.yaml | 6 +-
.../test/resources/expected/convert-encrypt.yaml | 2 +-
.../e2e/fixture/ITEncryptLikeAlgorithmFixture.java | 11 +--
...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 5 +-
.../algorithm/like/common_chinese_character.dict | 0
.../rql/dataset/encrypt/show_encrypt_rule.xml | 4 +-
.../rql/dataset/encrypt/show_encrypt_rules.xml | 8 +-
.../encrypt/proxy/conf/mysql/config-encrypt.yaml | 2 +-
.../proxy/conf/opengauss/config-encrypt.yaml | 2 +-
.../proxy/conf/postgresql/config-encrypt.yaml | 2 +-
.../test/resources/env/scenario/encrypt/rules.yaml | 2 +-
23 files changed, 18 insertions(+), 376 deletions(-)
diff --git a/docs/document/content/dev-manual/encrypt.cn.md b/docs/document/content/dev-manual/encrypt.cn.md
index 1fd403d0f80..9ffedbd2cfc 100644
--- a/docs/document/content/dev-manual/encrypt.cn.md
+++ b/docs/document/content/dev-manual/encrypt.cn.md
@@ -20,6 +20,4 @@ chapter = true
| *配置标识* | *详细说明* | *全限定类名* |
|------------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| AES | 基于 AES 的数据加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java) |
-| RC4 | 基于 RC4 的数据加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.RC4EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java) |
| MD5 | 基于 MD5 的辅助查询加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.MD5EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java) |
-| CHAR_DIGEST_LIKE | 用于模糊查询的数据加密算法 | [`org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java) |
diff --git a/docs/document/content/dev-manual/encrypt.en.md b/docs/document/content/dev-manual/encrypt.en.md
index a81d2acd3da..caeada00380 100644
--- a/docs/document/content/dev-manual/encrypt.en.md
+++ b/docs/document/content/dev-manual/encrypt.en.md
@@ -20,6 +20,4 @@ Data encrypt algorithm definition
| *Configuration Type* | *Description* | *Fully-qualified class name* |
|----------------------|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| AES | AES data encrypt algorithm | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/AESEncryptAlgorithm.java) |
-| RC4 | RC4 data encrypt algorithm | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.RC4EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java) |
| MD5 | MD5 assisted query encrypt algorithm | [`org.apache.shardingsphere.encrypt.algorithm.encrypt.MD5EncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java) |
-| CHAR_DIGEST_LIKE | Data encryption algorithms for like queries | [`org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm`](https://github.com/apache/shardingsphere/blob/master/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java) |
diff --git a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md
index 62931407f69..68b5f19d7df 100644
--- a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md
+++ b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.cn.md
@@ -22,31 +22,6 @@ weight = 5
| aes-key-value | String | AES 使用的 KEY |
| digest-algorithm-name | String | AES KEY 的摘要算法 (可选,默认值:SHA-1) |
-#### RC4 加密算法
-
-类型:RC4
-
-可配置属性:
-
-| *名称* | *数据类型* | *说明* |
-|---------------|--------|-------------|
-| rc4-key-value | String | RC4 使用的 KEY |
-
-### 模糊加密算法
-
-#### 单字符摘要模糊加密算法
-
-类型:CHAR_DIGEST_LIKE
-
-可配置属性:
-
-| *名称* | *数据类型* | *说明* |
-|-------|--------|--------------------|
-| delta | int | 字符Unicode码偏移量(十进制) |
-| mask | int | 字符加密掩码(十进制) |
-| start | int | 密文Unicode初始码(十进制) |
-| dict | String | 常见字 |
-
### 辅助查询加密算法
#### MD5 辅助查询加密算法
diff --git a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md
index 58cad71e6f7..ac09a77ccf4 100644
--- a/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md
+++ b/docs/document/content/user-manual/common-config/builtin-algorithm/encrypt.en.md
@@ -22,31 +22,6 @@ Attributes:
| aes-key-value | String | AES KEY |
| digest-algorithm-name | String | AES KEY DIGEST ALGORITHM (optional, default: SHA-1) |
-#### RC4 Encrypt Algorithm
-
-Type: RC4
-
-Attributes:
-
-| *Name* | *DataType* | *Description* |
-|---------------|------------|---------------|
-| rc4-key-value | String | RC4 KEY |
-
-### Like Encrypt Algorithm
-
-#### CharDigestLike Encrypt Algorithm
-
-Type:CHAR_DIGEST_LIKE
-
-Attributes:
-
-| *Name* | *DataType* | *Description* |
-|--------|------------|-------------------------------------------------|
-| delta | int | Character Unicode offset(decimal number) |
-| mask | int | Character encryption mask(decimal number) |
-| start | int | Ciphertext Unicode initial code(decimal number) |
-| dict | String | Common words |
-
### Assisted Encrypt Algorithm
#### MD5 Assisted Encrypt Algorithm
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java
deleted file mode 100644
index 1bc3e2169e5..00000000000
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithm.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.shardingsphere.encrypt.algorithm.standard;
-
-import lombok.EqualsAndHashCode;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Properties;
-
-/**
- * RC4 encrypt algorithm.
- */
-@EqualsAndHashCode
-public final class RC4EncryptAlgorithm implements StandardEncryptAlgorithm {
-
- private static final String RC4_KEY = "rc4-key-value";
-
- private static final int KEY_MIN_LENGTH = 5;
-
- private static final int SBOX_LENGTH = 256;
-
- private byte[] key;
-
- @Override
- public void init(final Properties props) {
- key = getKey(props);
- }
-
- private byte[] getKey(final Properties props) {
- byte[] result = props.getProperty(RC4_KEY, "").getBytes(StandardCharsets.UTF_8);
- ShardingSpherePreconditions.checkState(KEY_MIN_LENGTH <= result.length && SBOX_LENGTH > result.length,
- () -> new EncryptAlgorithmInitializationException(getType(), "Key length has to be between " + KEY_MIN_LENGTH + " and " + (SBOX_LENGTH - 1)));
- return result;
- }
-
- @Override
- public String encrypt(final Object plainValue, final EncryptContext encryptContext) {
- return null == plainValue ? null : Base64.encodeBase64String(crypt(String.valueOf(plainValue).getBytes(StandardCharsets.UTF_8)));
- }
-
- @Override
- public Object decrypt(final Object cipherValue, final EncryptContext encryptContext) {
- return null == cipherValue ? null : new String(crypt(Base64.decodeBase64(cipherValue.toString())), StandardCharsets.UTF_8);
- }
-
- /*
- * @see <a href="http://en.wikipedia.org/wiki/RC4#Pseudo-random_generation_algorithm_.28PRGA.29">Pseudo-random generation algorithm</a>
- */
- private byte[] crypt(final byte[] message) {
- int[] sBox = getSBox();
- byte[] result = new byte[message.length];
- int i = 0;
- int j = 0;
- for (int n = 0; n < message.length; n++) {
- i = (i + 1) % SBOX_LENGTH;
- j = (j + sBox[i]) % SBOX_LENGTH;
- swap(i, j, sBox);
- int rand = sBox[(sBox[i] + sBox[j]) % SBOX_LENGTH];
- result[n] = (byte) (rand ^ message[n]);
- }
- return result;
- }
-
- /*
- * @see <a href="http://en.wikipedia.org/wiki/RC4#Key-scheduling_algorithm_.28KSA.29">Wikipedia. Init sBox</a>
- */
- private int[] getSBox() {
- int[] result = new int[SBOX_LENGTH];
- int j = 0;
- for (int i = 0; i < SBOX_LENGTH; i++) {
- result[i] = i;
- }
- for (int i = 0; i < SBOX_LENGTH; i++) {
- j = (j + result[i] + (key[i % key.length]) & 0xFF) % SBOX_LENGTH;
- swap(i, j, result);
- }
- return result;
- }
-
- private void swap(final int i, final int j, final int[] sBox) {
- int temp = sBox[i];
- sBox[i] = sBox[j];
- sBox[j] = temp;
- }
-
- @Override
- public String getType() {
- return "RC4";
- }
-}
diff --git a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index 9f336b16809..8cb0319280d 100644
--- a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++ b/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -16,6 +16,4 @@
#
org.apache.shardingsphere.encrypt.algorithm.standard.AESEncryptAlgorithm
-org.apache.shardingsphere.encrypt.algorithm.standard.RC4EncryptAlgorithm
-org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm
org.apache.shardingsphere.encrypt.algorithm.assisted.MD5AssistedEncryptAlgorithm
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java
deleted file mode 100644
index 63e3b8f4b09..00000000000
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithmTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.shardingsphere.encrypt.algorithm.like;
-
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.test.util.PropertiesBuilder;
-import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.mockito.Mockito.mock;
-
-class CharDigestLikeEncryptAlgorithmTest {
-
- private LikeEncryptAlgorithm englishLikeEncryptAlgorithm;
-
- private LikeEncryptAlgorithm chineseLikeEncryptAlgorithm;
-
- private LikeEncryptAlgorithm koreanLikeEncryptAlgorithm;
-
- @BeforeEach
- void setUp() {
- englishLikeEncryptAlgorithm = (LikeEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class, "CHAR_DIGEST_LIKE");
- chineseLikeEncryptAlgorithm = (LikeEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class, "CHAR_DIGEST_LIKE");
- koreanLikeEncryptAlgorithm = (LikeEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class,
- "CHAR_DIGEST_LIKE", PropertiesBuilder.build(new Property("dict", "한국어시험"), new Property("start", "44032")));
- }
-
- @Test
- void assertEncrypt() {
- assertThat(englishLikeEncryptAlgorithm.encrypt("1234567890%abcdefghijklmnopqrstuvwxyz%ABCDEFGHIJKLMNOPQRSTUVWXYZ",
- mock(EncryptContext.class)), is("0145458981%`adedehihilmlmpqpqtutuxyxy%@ADEDEHIHILMLMPQPQTUTUXYXY"));
- assertThat(englishLikeEncryptAlgorithm.encrypt("_1234__5678__", mock(EncryptContext.class)), is("_0145__4589__"));
- }
-
- @Test
- void assertEncryptWithChineseChar() {
- assertThat(chineseLikeEncryptAlgorithm.encrypt("中国", mock(EncryptContext.class)), is("婝估"));
- }
-
- @Test
- void assertEncryptWithKoreanChar() {
- assertThat(koreanLikeEncryptAlgorithm.encrypt("한국", mock(EncryptContext.class)), is("각가"));
- }
-
- @Test
- void assertEncryptWithNullPlaintext() {
- assertNull(englishLikeEncryptAlgorithm.encrypt(null, mock(EncryptContext.class)));
- }
-}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithmTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithmTest.java
deleted file mode 100644
index a87b3591f29..00000000000
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/standard/RC4EncryptAlgorithmTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.shardingsphere.encrypt.algorithm.standard;
-
-import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
-import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
-import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.test.util.PropertiesBuilder;
-import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-
-class RC4EncryptAlgorithmTest {
-
- private StandardEncryptAlgorithm encryptAlgorithm;
-
- @BeforeEach
- void setUp() {
- encryptAlgorithm = (StandardEncryptAlgorithm) TypedSPILoader.getService(EncryptAlgorithm.class, "RC4", PropertiesBuilder.build(new Property("rc4-key-value", "test-sharding")));
- }
-
- @Test
- void assertEncode() {
- assertThat(encryptAlgorithm.encrypt("test", mock(EncryptContext.class)), is("4Tn7lQ=="));
- }
-
- @Test
- void assertEncryptNullValue() {
- assertNull(encryptAlgorithm.encrypt(null, mock(EncryptContext.class)));
- }
-
- @Test
- void assertKeyIsTooLong() {
- assertThrows(EncryptAlgorithmInitializationException.class,
- () -> encryptAlgorithm.init(PropertiesBuilder.build(new Property("rc4-key-value", IntStream.range(0, 100).mapToObj(each -> "test").collect(Collectors.joining())))));
- }
-
- @Test
- void assertKeyIsTooShort() {
- assertThrows(EncryptAlgorithmInitializationException.class,
- () -> encryptAlgorithm.init(PropertiesBuilder.build(new Property("rc4-key-value", "test"))));
- }
-
- @Test
- void assertDecode() {
- assertThat(encryptAlgorithm.decrypt("4Tn7lQ==", mock(EncryptContext.class)).toString(), is("test"));
- }
-
- @Test
- void assertDecryptNullValue() {
- assertNull(encryptAlgorithm.decrypt(null, mock(EncryptContext.class)));
- }
-}
diff --git a/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml b/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml
index 27939450a09..e8b9f209e6a 100644
--- a/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml
+++ b/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml
@@ -27,9 +27,6 @@ rules:
assistedQuery:
name: assisted_query_username
encryptorName: assisted_encryptor
- likeQuery:
- name: like_query_username
- encryptorName: like_encryptor
encryptors:
aes_encryptor:
type: AES
@@ -39,5 +36,3 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- like_encryptor:
- type: CHAR_DIGEST_LIKE
diff --git a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4 b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
index a8e8c47f9cb..6cb605cd6b5 100644
--- a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
+++ b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/BaseRule.g4
@@ -34,25 +34,16 @@ algorithmTypeName
buildInEncryptAlgorithmType
: standardEncryptAlgorithm
| assistedEncryptAlgorithm
- | likeEncryptAlgorithm
;
standardEncryptAlgorithm
- : MD5
- | AES
- | RC4
- | SM3
- | SM4
+ : AES
;
assistedEncryptAlgorithm
: MD5
;
-likeEncryptAlgorithm
- : CHAR_DIGEST_LIKE
- ;
-
propertiesDefinition
: PROPERTIES LP_ properties? RP_
;
diff --git a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4 b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4
index be4b1ca11cb..8137363e587 100644
--- a/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4
+++ b/features/encrypt/distsql/parser/src/main/antlr4/imports/encrypt/Keyword.g4
@@ -143,22 +143,6 @@ AES
: A E S
;
-RC4
- : R C [4]
- ;
-
-SM3
- : S M [3]
- ;
-
-SM4
- : S M [4]
- ;
-
-CHAR_DIGEST_LIKE
- : C H A R UL_ D I G E S T UL_ L I K E
- ;
-
NOT
: N O T
;
diff --git a/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml b/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml
index 6fa6138f3b0..ab59b37693a 100644
--- a/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml
+++ b/proxy/backend/core/src/test/resources/conf/convert/config-encrypt.yaml
@@ -49,7 +49,7 @@ rules:
props:
rc4-key-value: 123456abc
like_encryptor:
- type: CHAR_DIGEST_LIKE
+ type: CORE.QUERY_LIKE.FIXTURE
tables:
t_encrypt:
columns:
diff --git a/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml b/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml
index aef5444ece5..167fea16568 100644
--- a/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml
+++ b/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml
@@ -44,10 +44,6 @@ rules:
type: AES
props:
aes-key-value: 123456abc
- rc4_encryptor:
- type: RC4
- props:
- rc4-key-value: 123456abc
tables:
t_encrypt:
columns:
@@ -58,4 +54,4 @@ rules:
order_id:
cipher:
name: order_cipher
- encryptorName: rc4_encryptor
+ encryptorName: aes_encryptor
diff --git a/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml b/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml
index 8882645ae93..54ea9b0474e 100644
--- a/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml
+++ b/proxy/backend/core/src/test/resources/expected/convert-encrypt.yaml
@@ -31,6 +31,6 @@ PROPERTIES('minPoolSize'='1', 'connectionTimeoutMilliseconds'='30000', 'maxLifet
CREATE ENCRYPT RULE t_encrypt (
COLUMNS(
-(NAME=user_id, CIPHER=user_cipher, ASSISTED_QUERY_COLUMN=user_assisted, LIKE_QUERY_COLUMN=user_like, ENCRYPT_ALGORITHM(TYPE(NAME='aes', PROPERTIES('aes-key-value'='123456abc'))), ASSISTED_QUERY_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc'))), LIKE_QUERY_ALGORITHM(TYPE(NAME='char_digest_like'))),
+(NAME=user_id, CIPHER=user_cipher, ASSISTED_QUERY_COLUMN=user_assisted, LIKE_QUERY_COLUMN=user_like, ENCRYPT_ALGORITHM(TYPE(NAME='aes', PROPERTIES('aes-key-value'='123456abc'))), ASSISTED_QUERY_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc'))), LIKE_QUERY_ALGORITHM(TYPE(NAME='core.query_like.fixture'))),
(NAME=order_id, CIPHER=order_cipher, ENCRYPT_ALGORITHM(TYPE(NAME='rc4', PROPERTIES('rc4-key-value'='123456abc'))))
));
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java b/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java
similarity index 95%
rename from features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
rename to test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java
index 4b64d855695..42acf4f43ee 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
+++ b/test/e2e/fixture/src/test/java/org/apache/shardingsphere/test/e2e/fixture/ITEncryptLikeAlgorithmFixture.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.encrypt.algorithm.like;
+package org.apache.shardingsphere.test.e2e.fixture;
import com.google.common.base.Strings;
-import lombok.EqualsAndHashCode;
import lombok.SneakyThrows;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
import org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
@@ -33,11 +32,7 @@ import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-/**
- * Char digest like encrypt algorithm.
- */
-@EqualsAndHashCode
-public final class CharDigestLikeEncryptAlgorithm implements LikeEncryptAlgorithm {
+public final class ITEncryptLikeAlgorithmFixture implements LikeEncryptAlgorithm {
private static final String DELTA_KEY = "delta";
@@ -158,6 +153,6 @@ public final class CharDigestLikeEncryptAlgorithm implements LikeEncryptAlgorith
@Override
public String getType() {
- return "CHAR_DIGEST_LIKE";
+ return "IT.ENCRYPT.LIKE.FIXTURE";
}
}
diff --git a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/test/e2e/fixture/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
similarity index 71%
copy from features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
copy to test/e2e/fixture/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
index 9f336b16809..f6c7dada3ea 100644
--- a/features/encrypt/core/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
+++ b/test/e2e/fixture/src/test/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
@@ -15,7 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.encrypt.algorithm.standard.AESEncryptAlgorithm
-org.apache.shardingsphere.encrypt.algorithm.standard.RC4EncryptAlgorithm
-org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm
-org.apache.shardingsphere.encrypt.algorithm.assisted.MD5AssistedEncryptAlgorithm
+org.apache.shardingsphere.test.e2e.fixture.ITEncryptLikeAlgorithmFixture
diff --git a/features/encrypt/core/src/main/resources/algorithm/like/common_chinese_character.dict b/test/e2e/fixture/src/test/resources/algorithm/like/common_chinese_character.dict
similarity index 100%
rename from features/encrypt/core/src/main/resources/algorithm/like/common_chinese_character.dict
rename to test/e2e/fixture/src/test/resources/algorithm/like/common_chinese_character.dict
diff --git a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml
index b1b7460494b..d94f7c2cc56 100644
--- a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml
+++ b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rule.xml
@@ -29,8 +29,8 @@
<column name="like_query_type" />
<column name="like_query_props" />
</metadata>
- <row values="t_user| user_name| user_name_cipher| | user_name_like| AES| aes-key-value=123456abc| | | CHAR_DIGEST_LIKE| mask=4093" />
+ <row values="t_user| user_name| user_name_cipher| | user_name_like| AES| aes-key-value=123456abc| | | IT.ENCRYPT.LIKE.FIXTURE| mask=4093" />
<row values="t_user| password| password_cipher| | | AES| aes-key-value=123456abc| | | | " />
<row values="t_user| email| email_cipher| | | AES| aes-key-value=123456abc| | | | " />
- <row values="t_user| telephone| user_telephone_cipher| | user_telephone_like| AES| aes-key-value=123456abc| | | CHAR_DIGEST_LIKE| mask=4093" />
+ <row values="t_user| telephone| user_telephone_cipher| | user_telephone_like| AES| aes-key-value=123456abc| | | IT.ENCRYPT.LIKE.FIXTURE| mask=4093" />
</dataset>
diff --git a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml
index 488e8d0e859..1bbed24a732 100644
--- a/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml
+++ b/test/e2e/sql/src/test/resources/cases/rql/dataset/encrypt/show_encrypt_rules.xml
@@ -29,12 +29,12 @@
<column name="like_query_type" />
<column name="like_query_props" />
</metadata>
- <row values="t_user| user_name| user_name_cipher| | user_name_like| AES| aes-key-value=123456abc| | | CHAR_DIGEST_LIKE| mask=4093" />
+ <row values="t_user| user_name| user_name_cipher| | user_name_like| AES| aes-key-value=123456abc| | | IT.ENCRYPT.LIKE.FIXTURE| mask=4093" />
<row values="t_user| password| password_cipher| | | AES| aes-key-value=123456abc| | | | " />
<row values="t_user| email| email_cipher| | | AES| aes-key-value=123456abc| | | | " />
- <row values="t_user| telephone| user_telephone_cipher| | user_telephone_like| AES| aes-key-value=123456abc| | | CHAR_DIGEST_LIKE| mask=4093" />
+ <row values="t_user| telephone| user_telephone_cipher| | user_telephone_like| AES| aes-key-value=123456abc| | | IT.ENCRYPT.LIKE.FIXTURE| mask=4093" />
<row values="t_user_details| number| number_cipher| | | AES| aes-key-value=123456abc| | | | " />
<row values="t_user_details| number_new| number_new_cipher| | | AES| aes-key-value=123456abc| | | | " />
- <row values="t_merchant| business_code| business_code_cipher| | business_code_like| AES| aes-key-value=123456abc| | | CHAR_DIGEST_LIKE | mask=4093 " />
- <row values="t_merchant| telephone| merchant_telephone_cipher| | merchant_telephone_like| AES| aes-key-value=123456abc| | | CHAR_DIGEST_LIKE | mask=4093 " />
+ <row values="t_merchant| business_code| business_code_cipher| | business_code_like| AES| aes-key-value=123456abc| | | IT.ENCRYPT.LIKE.FIXTURE | mask=4093 " />
+ <row values="t_merchant| telephone| merchant_telephone_cipher| | merchant_telephone_like| AES| aes-key-value=123456abc| | | IT.ENCRYPT.LIKE.FIXTURE | mask=4093 " />
</dataset>
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml
index 1a6b944972f..52e62adb616 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/mysql/config-encrypt.yaml
@@ -39,7 +39,7 @@ rules:
props:
aes-key-value: 123456abc
like_encryptor:
- type: CHAR_DIGEST_LIKE
+ type: IT.ENCRYPT.LIKE.FIXTURE
props:
mask: 4093
tables:
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml
index 89a633b9d4e..ed3a7d99c7c 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/opengauss/config-encrypt.yaml
@@ -39,7 +39,7 @@ rules:
props:
aes-key-value: 123456abc
like_encryptor:
- type: CHAR_DIGEST_LIKE
+ type: IT.ENCRYPT.LIKE.FIXTURE
props:
mask: 4093
tables:
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml
index 9cc2b3d5382..a5030de3a71 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/proxy/conf/postgresql/config-encrypt.yaml
@@ -39,7 +39,7 @@ rules:
props:
aes-key-value: 123456abc
like_encryptor:
- type: CHAR_DIGEST_LIKE
+ type: IT.ENCRYPT.LIKE.FIXTURE
props:
mask: 4093
tables:
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml
index 69a2ac6a6d9..a4c0b5294e4 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt/rules.yaml
@@ -26,7 +26,7 @@ rules:
props:
aes-key-value: 123456abc
like_encryptor:
- type: CHAR_DIGEST_LIKE
+ type: IT.ENCRYPT.LIKE.FIXTURE
props:
mask: 4093
tables: