diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index bbe582466cca06eb98cca3bc7cdebb2efae6583f..93cdd1ab99e48ce5a6ff75f8284031d30c58640a 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -177,10 +177,10 @@ static int32_t getSmlMd5ChildTableName(TAOS_SML_DATA_POINT* point, char* tableNa } size_t len = 0; char* keyJoined = taosStringBuilderGetResult(&sb, &len); - TAOS_MD5_CTX context; - taos_MD5Init(&context); - taos_MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); - taos_MD5Final(&context); + T_MD5_CTX context; + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + tMD5Final(&context); uint64_t digest1 = *(uint64_t*)(context.digest); uint64_t digest2 = *(uint64_t*)(context.digest + 8); *tableNameLen = snprintf(tableName, *tableNameLen, diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index 221ff36d879b1442e4b6d65e22bc7f8d2ded0188..c49d561e2b552bd6dfdeb2a7d161da5ad75d3628 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -350,10 +350,10 @@ int32_t httpShrinkTableName(HttpContext *pContext, int32_t pos, char *name) { return pos; } - TAOS_MD5_CTX context; - taos_MD5Init(&context); - taos_MD5Update(&context, (uint8_t *)name, (uint32_t)len); - taos_MD5Final(&context); + T_MD5_CTX context; + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)name, (uint32_t)len); + tMD5Final(&context); int32_t table_name = httpAddToSqlCmdBuffer( pContext, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index c602cf793a10bf31aaf781275f07cad0c1a87006..47ee0d8e229c3b4e692f4472e7f15cbd72ceb40e 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1541,14 +1541,14 @@ static SRpcHead *rpcDecompressRpcMsg(SRpcHead *pHead) { } static int rpcAuthenticateMsg(void *pMsg, int msgLen, void *pAuth, void *pKey) { - TAOS_MD5_CTX context; + T_MD5_CTX context; int ret = -1; - taos_MD5Init(&context); - taos_MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - taos_MD5Update(&context, (uint8_t *)pMsg, msgLen); - taos_MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - taos_MD5Final(&context); + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Update(&context, (uint8_t *)pMsg, msgLen); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Final(&context); if (memcmp(context.digest, pAuth, sizeof(context.digest)) == 0) ret = 0; @@ -1556,13 +1556,13 @@ static int rpcAuthenticateMsg(void *pMsg, int msgLen, void *pAuth, void *pKey) { } static void rpcBuildAuthHead(void *pMsg, int msgLen, void *pAuth, void *pKey) { - TAOS_MD5_CTX context; + T_MD5_CTX context; - taos_MD5Init(&context); - taos_MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - taos_MD5Update(&context, (uint8_t *)pMsg, msgLen); - taos_MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - taos_MD5Final(&context); + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Update(&context, (uint8_t *)pMsg, msgLen); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Final(&context); memcpy(pAuth, context.digest, sizeof(context.digest)); } diff --git a/src/util/inc/tmd5.h b/src/util/inc/tmd5.h index 1bf168857ddf1d88d7a647ab6b3ac8514fa82bec..bf6a7d86eec43360ff40eaf2cfe6921161ae5064 100644 --- a/src/util/inc/tmd5.h +++ b/src/util/inc/tmd5.h @@ -31,11 +31,17 @@ typedef struct { uint32_t i[2]; /* number of _bits_ handled mod 2^64 */ uint32_t buf[4]; /* scratch buffer */ uint8_t in[64]; /* input buffer */ - uint8_t digest[16]; /* actual digest after taos_MD5Final call */ -} TAOS_MD5_CTX; + uint8_t digest[16]; /* actual digest after tMD5Final call */ +} MD5_CTX; -void taos_MD5Init(TAOS_MD5_CTX *mdContext); -void taos_MD5Update(TAOS_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); -void taos_MD5Final(TAOS_MD5_CTX *mdContext); +typedef MD5_CTX T_MD5_CTX; + +void MD5Init(T_MD5_CTX *mdContext); +void MD5Update(T_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); +void MD5Final(T_MD5_CTX *mdContext); + +void tMD5Init(T_MD5_CTX *mdContext); +void tMD5Update(T_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); +void tMD5Final(T_MD5_CTX *mdContext); #endif diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index dd0d6f2b66c07c407b2f11bdf8eae3a881f7bc11..60faa4d5a24082f0c1cf3e5967ece07d68a74e4e 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -47,10 +47,10 @@ void jsonKeyMd5(void *pMsg, int msgLen, void *pKey); bool isValidateTag(char *input); static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) { - TAOS_MD5_CTX context; - taos_MD5Init(&context); - taos_MD5Update(&context, inBuf, (unsigned int)inLen); - taos_MD5Final(&context); + T_MD5_CTX context; + tMD5Init(&context); + tMD5Update(&context, inBuf, (unsigned int)inLen); + tMD5Final(&context); memcpy(target, context.digest, TSDB_KEY_LEN); } diff --git a/src/util/src/tmd5.c b/src/util/src/tmd5.c index 1cac7f408324c982077bae6b1684ae1f3b50f310..bcf9bfeca58fa1884d9b94ce9203fc59a70919f3 100644 --- a/src/util/src/tmd5.c +++ b/src/util/src/tmd5.c @@ -2,9 +2,9 @@ *********************************************************************** ** Message-digest routines: ** ** To form the message digest for a message M ** - ** (1) Initialize a context buffer mdContext using taos_MD5Init ** - ** (2) Call taos_MD5Update on mdContext and M ** - ** (3) Call taos_MD5Final on mdContext ** + ** (1) Initialize a context buffer mdContext using tMD5Init ** + ** (2) Call tMD5Update on mdContext and M ** + ** (3) Call tMD5Final on mdContext ** ** The message digest is now in mdContext->digest[0...15] ** *********************************************************************** */ @@ -82,11 +82,11 @@ static uint8_t PADDING[64] = {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x (a) += (b); \ } -/* The routine taos_MD5Init initializes the message-digest context +/* The routine tMD5Init initializes the message-digest context mdContext. All fields are set to zero. */ -void taos_MD5Init(TAOS_MD5_CTX *mdContext) { - memset(mdContext, 0, sizeof(TAOS_MD5_CTX)); +void tMD5Init(T_MD5_CTX *mdContext) { + memset(mdContext, 0, sizeof(T_MD5_CTX)); /* Load magic initialization constants. */ mdContext->buf[0] = (uint32_t)0x67452301; @@ -94,12 +94,15 @@ void taos_MD5Init(TAOS_MD5_CTX *mdContext) { mdContext->buf[2] = (uint32_t)0x98badcfe; mdContext->buf[3] = (uint32_t)0x10325476; } +void MD5Init(MD5_CTX *mdContext) { + return tMD5Init(mdContext); +} -/* The routine taos_MD5Update updates the message-digest context to +/* The routine tMD5Update updates the message-digest context to account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ -void taos_MD5Update(TAOS_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { +void tMD5Update(T_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { uint32_t in[16]; int mdi; unsigned int i, ii; @@ -126,11 +129,14 @@ void taos_MD5Update(TAOS_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) } } } +void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { + return tMD5Update(mdContext, inBuf, inLen); +} -/* The routine taos_MD5Final terminates the message-digest computation and +/* The routine tMD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ -void taos_MD5Final(TAOS_MD5_CTX *mdContext) { +void tMD5Final(T_MD5_CTX *mdContext) { uint32_t in[16]; int mdi; unsigned int i, ii; @@ -145,7 +151,7 @@ void taos_MD5Final(TAOS_MD5_CTX *mdContext) { /* pad out to 56 mod 64 */ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); - taos_MD5Update(mdContext, PADDING, padLen); + tMD5Update(mdContext, PADDING, padLen); /* append length in bits and transform */ for (i = 0, ii = 0; i < 14; i++, ii += 4) @@ -161,6 +167,9 @@ void taos_MD5Final(TAOS_MD5_CTX *mdContext) { mdContext->digest[ii + 3] = (uint8_t)((mdContext->buf[i] >> 24) & 0xFF); } } +void MD5Final(MD5_CTX *mdContext) { + return tMD5Final(mdContext); +} /* Basic MD5 step. Transforms buf based on in. */ diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 8a26c937a51196171554fb1ce517c89348ead793..7e08178c42cbb7e34a0aec340352916d874a7094 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -455,11 +455,11 @@ char *taosIpStr(uint32_t ipInt) { } void jsonKeyMd5(void *pMsg, int msgLen, void *pKey) { - TAOS_MD5_CTX context; + T_MD5_CTX context; - taos_MD5Init(&context); - taos_MD5Update(&context, (uint8_t *)pMsg, msgLen); - taos_MD5Final(&context); + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)pMsg, msgLen); + tMD5Final(&context); memcpy(pKey, context.digest, sizeof(context.digest)); }