From: Jason Ish Date: Wed, 30 Dec 2020 22:18:39 +0000 (-0600) Subject: ja3: use SCMd5HashBufferToHex to print hash as hex X-Git-Tag: suricata-7.0.0-beta1~1879 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a8215386656a274cc2e89181034375b71e49dde;p=thirdparty%2Fsuricata.git ja3: use SCMd5HashBufferToHex to print hash as hex Replace snprintf loop with new function that hashes a single buffer to an MD5 hex string. --- 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; }