diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index e5631cb749..25566d5acb 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -58,7 +58,7 @@ typedef struct { int64_t segSize; EWalType level; // wal level int32_t encryptAlgorithm; - char encryptKey[17]; + char encryptKey[ENCRYPT_KEY_LEN + 1]; } SWalCfg; typedef struct { diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 76dd0d4e48..3526b7daab 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -376,13 +376,13 @@ int mainWindows(int argc, char **argv) { dError("failed to generate encrypt code since taosd is running, please stop it first"); return -1; } - int ret = updateEncryptKey(global.encryptKey); + int ret = dmUpdateEncryptKey(global.encryptKey); taosCloseLog(); taosCleanupArgs(); return ret; } - if(getEncryptKey() != 0){ + if(dmGetEncryptKey() != 0){ dError("failed to start since failed to get encrypt key"); taosCloseLog(); taosCleanupArgs(); diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index a7c64e2fb9..f576ee334a 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -233,7 +233,7 @@ int32_t dmProcessCreateEncryptKeyReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { goto _exit; } - code = updateEncryptKey(cfgReq.value); + code = dmUpdateEncryptKey(cfgReq.value); if(code == 0) { tsEncryptionKeyChksum = taosCalcChecksum(0, cfgReq.value, strlen(cfgReq.value)); tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED; diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 46a13b8715..0344ca685d 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -193,8 +193,8 @@ void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); bool dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port); void dmRemoveDnodePairs(SDnodeData *pData); void dmGetDnodeEp(void *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort); -int32_t updateEncryptKey(char *key); -int32_t getEncryptKey(); +int32_t dmUpdateEncryptKey(char *key); +int32_t dmGetEncryptKey(); #ifdef __cplusplus } #endif diff --git a/source/dnode/mgmt/node_util/src/dmFile.c b/source/dnode/mgmt/node_util/src/dmFile.c index aae80c77a9..2e8ea38c2d 100644 --- a/source/dnode/mgmt/node_util/src/dmFile.c +++ b/source/dnode/mgmt/node_util/src/dmFile.c @@ -21,7 +21,7 @@ #include "tchecksum.h" #define MAXLEN 1024 -#define DM_KEY_INDICATOR "this indicator!" +#define DM_KEY_INDICATOR "this indicator!" #define DM_ENCRYPT_CODE_FILE "encryptCode.cfg" #define DM_CHECK_CODE_FILE "checkCode.bin" @@ -186,7 +186,7 @@ TdFilePtr dmCheckRunning(const char *dataDir) { extern int32_t generateEncryptCode(const char *key, const char *machineId, char **encryptCode); -static int32_t writeCheckCode(char* file, char* realfile, char* key){ +static int32_t dmWriteCheckCodeFile(char* file, char* realfile, char* key){ TdFilePtr pFile = NULL; char *result = NULL; int32_t code = -1; @@ -220,7 +220,7 @@ _OVER: return code; } -static int32_t writeEncryptCode(char* file, char* realfile, char* encryptCode){ +static int32_t dmWriteEncryptCodeFile(char* file, char* realfile, char* encryptCode){ TdFilePtr pFile = NULL; int32_t code = -1; @@ -243,7 +243,7 @@ _OVER: return code; } -static int32_t compareCheckCode(char* file, char* key){ +static int32_t dmCompareEncryptKey(char* file, char* key){ char *content = NULL; int64_t size = 0; TdFilePtr pFile = NULL; @@ -304,7 +304,7 @@ _OVER: return code; } -int32_t updateEncryptKey(char *key) { +int32_t dmUpdateEncryptKey(char *key) { int32_t code = -1; char *machineId = NULL; char *encryptCode = NULL; @@ -332,7 +332,7 @@ int32_t updateEncryptKey(char *key) { } if(taosCheckExistFile(realCheckFile)){ - if(compareCheckCode(realCheckFile, key) != 0){ + if(dmCompareEncryptKey(realCheckFile, key) != 0){ goto _OVER; } } @@ -346,11 +346,11 @@ int32_t updateEncryptKey(char *key) { goto _OVER; } - if(writeEncryptCode(encryptFile, realEncryptFile, encryptCode) != 0){ + if(dmWriteEncryptCodeFile(encryptFile, realEncryptFile, encryptCode) != 0){ goto _OVER; } - if(writeCheckCode(checkFile, realCheckFile, key) != 0){ + if(dmWriteCheckCodeFile(checkFile, realCheckFile, key) != 0){ goto _OVER; } @@ -367,7 +367,7 @@ _OVER: extern int32_t checkAndGetCryptKey(const char *encryptCode, const char *machineId, char **key); -static int32_t readEncryptCode(char* file, char** output){ +static int32_t dmReadEncryptCodeFile(char* file, char** output){ TdFilePtr pFile = NULL; int32_t code = -1; char *content = NULL; @@ -410,7 +410,7 @@ _OVER: return code; } -int32_t getEncryptKey(){ +int32_t dmGetEncryptKey(){ int32_t code = -1; char encryptFile[PATH_MAX] = {0}; char checkFile[PATH_MAX] = {0}; @@ -426,7 +426,7 @@ int32_t getEncryptKey(){ return 0; } - if(readEncryptCode(encryptFile, &content) != 0){ + if(dmReadEncryptCodeFile(encryptFile, &content) != 0){ goto _OVER; } @@ -448,7 +448,7 @@ int32_t getEncryptKey(){ goto _OVER; } - if(compareCheckCode(checkFile, encryptKey) != 0){ + if(dmCompareEncryptKey(checkFile, encryptKey) != 0){ goto _OVER; } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 6dd4955353..d6a279922c 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -304,7 +304,6 @@ struct SVnodeCfg { int8_t isRsma; int8_t hashMethod; int8_t standby; - int8_t encryptAlgorithm; STsdbCfg tsdbCfg; SWalCfg walCfg; SSyncCfg syncCfg; diff --git a/source/libs/sm4/src/sm4.c b/source/libs/sm4/src/sm4.c index 91dacc10b0..0a50c9f18d 100644 --- a/source/libs/sm4/src/sm4.c +++ b/source/libs/sm4/src/sm4.c @@ -395,6 +395,7 @@ void SMS4_CBC_DecryptionEx(unsigned char ciphertext[16], unsigned int key[32], u } } +/* int SM4_ECB_Encrypt( unsigned char *pKey, unsigned int KeyLen, unsigned char *pInData, @@ -461,7 +462,7 @@ int SM4_ECB_Decrypt( unsigned char *pKey, *pOutDataLen = inDataLen; return 0; } - +*/ int SM4_CBC_Encrypt( unsigned char *pKey, unsigned int KeyLen, unsigned char *pIV, diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 13b091ea46..b3351cf787 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -394,7 +394,7 @@ struct STDB { #endif int64_t txnId; int32_t encryptAlgorithm; - char encryptKey[ENCRYPT_KEY_LEN]; + char encryptKey[ENCRYPT_KEY_LEN + 1]; }; struct SPager {