From 3a8215386656a274cc2e89181034375b71e49dde Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 30 Dec 2020 16:18:39 -0600 Subject: [PATCH] ja3: use SCMd5HashBufferToHex to print hash as hex Replace snprintf loop with new function that hashes a single buffer to an MD5 hex string. --- src/util-ja3.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/util-ja3.c b/src/util-ja3.c index 24e8bf3064..a2fee4efb3 100644 --- a/src/util-ja3.c +++ b/src/util-ja3.c @@ -233,14 +233,8 @@ char *Ja3GenerateHash(JA3Buffer *buffer) return NULL; } - unsigned char md5[SC_MD5_LEN]; - SCMd5HashBuffer((unsigned char *)buffer->data, buffer->used, md5, sizeof(md5)); - - int i, x; - for (i = 0, x = 0; x < SC_MD5_LEN; x++) { - i += snprintf(ja3_hash + i, MD5_STRING_LENGTH - i, "%02x", md5[x]); - } - + SCMd5HashBufferToHex((unsigned char *)buffer->data, buffer->used, ja3_hash, + MD5_STRING_LENGTH * sizeof(char)); return ja3_hash; } -- 2.47.2