You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/27 13:04:57 UTC

[GitHub] [shardingsphere] strongduanmu opened a new issue #15129: Add EncryptContext parameter to EncryptAlgorithm and QueryAssistedEncryptAlgorithm SPI interface

strongduanmu opened a new issue #15129:
URL: https://github.com/apache/shardingsphere/issues/15129


   In order to improve scalability of EncryptAlgorithm and QueryAssistedEncryptAlgorithm SPI interfaces, we need to add EncryptContext parameter which provides encryption-related context information to the algorithm, and allow users to implement more advanced encryption algorithms based on these context information.
   
   The modified SPI interface is as follows:
   
   EncryptAlgorithm SPI interface:
   
   ```java
   /**
    * Encrypt algorithm for SPI.
    * 
    * @param <I> type of plain value
    * @param <O> type of cipher value
    */
   public interface EncryptAlgorithm<I, O> extends ShardingSphereAlgorithm, ShardingSphereAlgorithmPostProcessor {
       
       /**
        * Encode.
        *
        * @param plainValue plain value
        * @return cipher value
        */
       O encrypt(I plainValue, EncryptContext encryptContext);
       
       /**
        * Decode.
        *
        * @param cipherValue cipher value
        * @return plain value
        */
       I decrypt(O cipherValue, EncryptContext encryptContext);
   }
   ```
   
   QueryAssistedEncryptAlgorithm SPI interface:
   
   ```java
   /**
    * Query assisted encrypt algorithm for SPI.
    *
    * @param <I> type of plain value
    * @param <O> type of  cipher value
    */
   public interface QueryAssistedEncryptAlgorithm<I, O> extends EncryptAlgorithm<I, O> {
       
       /**
        * Query assisted encrypt.
        *
        * @param plainValue plain value
        * @return cipher value
        */
       O queryAssistedEncrypt(I plainValue, EncryptContext encryptContext);
   }
   ```
   
   EncryptContext:
   
   ```java
   /**
    * Encrypt context.
    */
   @RequiredArgsConstructor
   @Getter
   @ToString
   public final class EncryptContext {
       
       private final String schemaName;
       
       private final String tableName;
       
       private final String columnName;
       
       private final ColumnDataType logicDataType;
       
       private final ColumnDataType plainDataType;
       
       private final ColumnDataType cipherDataType;
       
       private final ColumnDataType assistedQueryDataType;
   }
   
   
   /**
    * Column data type.
    */
   @RequiredArgsConstructor
   @Getter
   public final class ColumnDataType {
       
       private final int dateType;
       
       private final String typeName;
   }
   ```
   
   After modifying the SPI interface, we need to encapsulate the original parameters passed to the algorithm through props, encapsulate them with EncryptContext and then pass them to the algorithm for use.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu closed issue #15129: Add EncryptContext parameter to EncryptAlgorithm and QueryAssistedEncryptAlgorithm SPI interface

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #15129:
URL: https://github.com/apache/shardingsphere/issues/15129


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org