From d330130b98e92e340245442c6620c42d6ac85a4b Mon Sep 17 00:00:00 2001 From: Shubham Turakhia Date: Thu, 22 Apr 2021 13:23:12 -0700 Subject: [PATCH] Hash code refactoring --- aws_protocol_adaptor/device_client/aws_nvmsgbroker.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/aws_protocol_adaptor/device_client/aws_nvmsgbroker.c b/aws_protocol_adaptor/device_client/aws_nvmsgbroker.c index e9e9677..42d3ee1 100755 --- a/aws_protocol_adaptor/device_client/aws_nvmsgbroker.c +++ b/aws_protocol_adaptor/device_client/aws_nvmsgbroker.c @@ -404,18 +404,15 @@ bool is_valid_connection_str(char *connection_str) char *generate_sha256_hash(char *output_str, char *str) { unsigned char hashval[SHA256_DIGEST_LENGTH]; - int len = SHA256_DIGEST_LENGTH * 2 + 1; - char res[len]; - strcpy(res, output_str); SHA256_CTX sha256; SHA256_Init(&sha256); SHA256_Update(&sha256, str, strlen(str)); SHA256_Final(hashval, &sha256); for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) { - sprintf(res + (i * 2), "%02x", hashval[i]); + sprintf(output_str + (i * 2), "%02x", hashval[i]); } - return res; + return output_str; } NvDsMsgApiErrorType nvds_msgapi_connection_signature(char *broker_str, char *cfg, char *output_str, int max_len)