kongfanshen-0801 commented on code in PR #1424:
URL: https://github.com/apache/cloudberry/pull/1424#discussion_r2509015856


##########
src/backend/crypto/bufenc.c:
##########
@@ -51,12 +51,9 @@ InitializeBufferEncryption(void)
 
        if (CheckIsSM4Method())
        {
-               bool found;
-               BufEncCtx = ShmemInitStruct("sm4 encryption method encrypt ctx",
-                                                                               
                sizeof(sm4_ctx), &found);
+               BufEncCtx = malloc(sizeof(sm4_ctx));

Review Comment:
   It is feasible to use static variables here. But multiple variables are 
needed.
   The type of the BufEncCtx/BufDecCtx variable is void *, and different memory 
sizes can be applied depending on the encryption algorithm used.
   If it is sm4, then the variable type is sm4_ctx.
   If it is the AES algorithm, then the variable type is PgCipherCtx.
   PgCipherCtx is not a fixed type and needs to be determined based on the 
compilation macro parameters. The code is as follows:
   #ifdef USE_OPENSSL
   typedef EVP_CIPHER_CTX PgCipherCtx;
   #else
   typedef void PgCipherCtx;
   #endif
   So here we use the void * type and apply different memory sizes according to 
different algorithms.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to