]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ja3: use SCMd5HashBufferToHex to print hash as hex
authorJason Ish <jason.ish@oisf.net>
Wed, 30 Dec 2020 22:18:39 +0000 (16:18 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 13 Jan 2021 08:01:05 +0000 (09:01 +0100)
Replace snprintf loop with new function that hashes a single
buffer to an MD5 hex string.

src/util-ja3.c

index 24e8bf3064a92021f6b122029a6d5461eae08327..a2fee4efb3c7bde7116dc4892672272d4f062144 100644 (file)
@@ -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;
 }