chore: tdes code optimization

This commit is contained in:
kailixu 2023-12-12 15:21:52 +08:00
parent fe01fb635d
commit 458c85c0ab
1 changed files with 8 additions and 1 deletions

View File

@ -48,6 +48,10 @@ char* taosDesImp(uint8_t* key, char* src, uint32_t len, int32_t process_mode) {
key_set key_sets[17]; key_set key_sets[17];
memset(key_sets, 0, sizeof(key_sets)); memset(key_sets, 0, sizeof(key_sets));
char* dest = taosMemoryCalloc(len + 1, 1); char* dest = taosMemoryCalloc(len + 1, 1);
if (!dest) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
generate_sub_keys(key, key_sets); generate_sub_keys(key, key_sets);
for (uint32_t block_count = 0; block_count < number_of_blocks; block_count++) { for (uint32_t block_count = 0; block_count < number_of_blocks; block_count++) {
@ -61,7 +65,10 @@ char* taosDesImp(uint8_t* key, char* src, uint32_t len, int32_t process_mode) {
} }
char* taosDesEncode(int64_t key, char* src, int32_t len) { char* taosDesEncode(int64_t key, char* src, int32_t len) {
if (len % 8 != 0) return NULL; if (len % 8 != 0) {
terrno = TSDB_CODE_INVALID_PARA;
return NULL;
}
uint8_t* keyStr = (uint8_t*)(&key); uint8_t* keyStr = (uint8_t*)(&key);
return taosDesImp(keyStr, src, len, ENCRYPTION_MODE); return taosDesImp(keyStr, src, len, ENCRYPTION_MODE);
} }