tristaZero commented on a change in pull request #11440:
URL: https://github.com/apache/shardingsphere/pull/11440#discussion_r675986178



##########
File path: 
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/security/AesAlgorithmSecure.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.infra.security;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.List;
+
+/**
+ * this is Aes Security Utils for encrypt or decrypt password
+ * NOTICE:
+ * in encrypt, we random get iv and key in 16-bytes to encrypt password, but 
in return value, we combain
+ * iv + key + encrypt(passwd) as a string, this is not SAFE!!! iv and key must 
save other security file or database!
+ * if you need more security, please implements AlgorithmSecure youself.
+ * in decrypt, we first extract iv and key in 16 bytes, then use it to decrypt 
password.
+ */
+public class AesAlgorithmSecure implements AlgorithmSecure {
+    // the iv and key lenght
+    private static final int KEY_PART_LENGTH = 16;
+
+    // the default encrypt / decrypt algorithm
+    private static final String DEFAULT_ALGORITHM = "AES/CBC/PKCS5PADDING";
+
+    // the default key generator algorithm
+    private static final String DEFAULT_KEY_ALGORITHM = "AES";
+
+    @Override
+    public String encrypt(final byte[] content) throws Exception {

Review comment:
       Hi here is already the same algorithm, i.e, `AESEncryptAlgorithm` , 
could we consider reusing this class?

##########
File path: 
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java
##########
@@ -132,8 +132,20 @@
      * Proxy backend query fetch size. A larger value may increase the memory 
usage of ShardingSphere Proxy.
      * The default value is -1, which means set the minimum value for 
different JDBC drivers.
      */
-    PROXY_BACKEND_QUERY_FETCH_SIZE("proxy-backend-query-fetch-size", "-1", 
int.class);
-    
+    PROXY_BACKEND_QUERY_FETCH_SIZE("proxy-backend-query-fetch-size", "-1", 
int.class),
+
+    /**
+     * Proxy backend password encrypt/decrypt algorithm
+     * The default value is NONE, which means no algorithm will be run.
+     */
+    PROXY_BACKEND_ALGORITHM("proxy-backend-algorithm", "NONE", String.class),

Review comment:
       Hi do you think `proxy-backend-password-algorithm` and 
"proxy-frontend-password-algorithm" will be better?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to