]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
ja3: remove requirement on NSS
authorJason Ish <jason.ish@oisf.net>
Tue, 22 Dec 2020 22:44:42 +0000 (16:44 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 12 Jan 2021 20:17:29 +0000 (21:17 +0100)
src/app-layer-ssl.c
src/tests/detect-tls-ja3-hash.c
src/tests/detect-tls-ja3-string.c
src/tests/detect-tls-ja3s-hash.c
src/tests/detect-tls-ja3s-string.c
src/util-ja3.c

index bc012e3a4f6cdd42510711b8e130d0b53f27d5f6..abdefdbc45828a40e5ce90fd21e2de9624a94878 100644 (file)
@@ -3026,18 +3026,9 @@ void RegisterSSLParsers(void)
         }
         SC_ATOMIC_SET(ssl_config.enable_ja3, enable_ja3);
 
-#ifndef HAVE_NSS
-        if (SC_ATOMIC_GET(ssl_config.enable_ja3)) {
-            SCLogWarning(SC_WARN_NO_JA3_SUPPORT,
-                         "no MD5 calculation support built in (LibNSS), disabling JA3");
-            SC_ATOMIC_SET(ssl_config.enable_ja3, 0);
-        }
-#else
         if (RunmodeIsUnittests()) {
             SC_ATOMIC_SET(ssl_config.enable_ja3, 1);
         }
-#endif
-
     } else {
         SCLogConfig("Parsed disabled for %s protocol. Protocol detection"
                   "still on.", proto_name);
@@ -3057,7 +3048,6 @@ void RegisterSSLParsers(void)
  */
 void SSLEnableJA3(void)
 {
-#ifdef HAVE_NSS
     if (ssl_config.disable_ja3) {
         return;
     }
@@ -3065,16 +3055,13 @@ void SSLEnableJA3(void)
         return;
     }
     SC_ATOMIC_SET(ssl_config.enable_ja3, 1);
-#endif
 }
 
 bool SSLJA3IsEnabled(void)
 {
-#ifdef HAVE_NSS
     if (SC_ATOMIC_GET(ssl_config.enable_ja3)) {
         return true;
     }
-#endif
     return false;
 }
 
index 8919815ad5f3d57d71569c0ef24ac7d32912b06b..a7929df6fe03dd98509b3b49e36701f6de5f9d6d 100644 (file)
  *
  */
 
-#ifndef HAVE_NSS
-
-static void DetectTlsJa3HashRegisterTests(void)
-{
-    /* Don't register any tests */
-}
-
-#else /* HAVE_NSS */
-
 /**
  * \test Test matching on a simple client hello packet
  */
@@ -224,5 +215,3 @@ static void DetectTlsJa3HashRegisterTests(void)
     UtRegisterTest("DetectTlsJa3HashTest01", DetectTlsJa3HashTest01);
     UtRegisterTest("DetectTlsJa3HashTest02", DetectTlsJa3HashTest02);
 }
-
-#endif /* HAVE_NSS */
index 09115cd089b57a464ab84f6d09500fd1de376674..f245c02cdb24cd6cf72e962bb15656241f76c4c5 100644 (file)
  *
  */
 
-#ifndef HAVE_NSS
-
-static void DetectTlsJa3StringRegisterTests(void)
-{
-    /* Don't register any tests */
-}
-
-#else /* HAVE_NSS */
-
 /**
  * \test Test matching on a simple client hello packet
  */
@@ -127,5 +118,3 @@ static void DetectTlsJa3StringRegisterTests(void)
 {
     UtRegisterTest("DetectTlsJa3StringTest01", DetectTlsJa3StringTest01);
 }
-
-#endif /* HAVE_NSS */
index a8b21c82375cd12dd3efe0ebfa74c775b3cafced..571668c537ad8dd4b36ee242b67852bbc8f4c803 100644 (file)
  *
  */
 
-#ifndef HAVE_NSS
-
-static void DetectTlsJa3SHashRegisterTests(void)
-{
-    /* Don't register any tests */
-}
-
-#else /* HAVE_NSS */
-
 /**
  * \test Test matching on a JA3S hash from a ServerHello record
  */
@@ -173,5 +164,3 @@ void DetectTlsJa3SHashRegisterTests(void)
 {
     UtRegisterTest("DetectTlsJa3SHashTest01", DetectTlsJa3SHashTest01);
 }
-
-#endif /* HAVE_NSS */
index 1ca93bbb746e05afd0d5cc379ebd6a91f37ca003..54841e000122c9dc8d2a38f60dbe65b0d04e8460 100644 (file)
  * 02110-1301, USA.
  */
 
-#ifndef HAVE_NSS
-
-static void DetectTlsJa3SStringRegisterTests(void)
-{
-    /* Don't register any tests */
-}
-
-#else /* HAVE_NSS */
-
 /**
  * \test Test matching on a simple client hello packet
  */
@@ -166,5 +157,3 @@ static void DetectTlsJa3SStringRegisterTests(void)
 {
     UtRegisterTest("DetectTlsJa3SStringTest01", DetectTlsJa3SStringTest01);
 }
-
-#endif /* HAVE_NSS */
index 743ec97bd04edf378a928c44c3a0ef0da0660a91..24e8bf3064a92021f6b122029a6d5461eae08327 100644 (file)
 #include "util-validate.h"
 #include "util-ja3.h"
 
-#ifdef HAVE_NSS
-#include <sechash.h>
-#endif
-
 #define MD5_STRING_LENGTH 33
 
 /**
@@ -220,8 +216,6 @@ int Ja3BufferAddValue(JA3Buffer **buffer, uint32_t value)
  */
 char *Ja3GenerateHash(JA3Buffer *buffer)
 {
-
-#ifdef HAVE_NSS
     if (buffer == NULL) {
         SCLogError(SC_ERR_INVALID_ARGUMENT, "Buffer should not be NULL");
         return NULL;
@@ -239,19 +233,15 @@ char *Ja3GenerateHash(JA3Buffer *buffer)
         return NULL;
     }
 
-    unsigned char md5[MD5_LENGTH];
-    HASH_HashBuf(HASH_AlgMD5, md5, (unsigned char *)buffer->data, buffer->used);
+    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 < MD5_LENGTH; x++) {
+    for (i = 0, x = 0; x < SC_MD5_LEN; x++) {
         i += snprintf(ja3_hash + i, MD5_STRING_LENGTH - i, "%02x", md5[x]);
     }
 
     return ja3_hash;
-#else
-    return NULL;
-#endif /* HAVE_NSS */
-
 }
 
 /**
@@ -275,16 +265,5 @@ int Ja3IsDisabled(const char *type)
         return 1;
     }
 
-#ifndef HAVE_NSS
-    else {
-        if (strcmp(type, "rule") != 0) {
-            SCLogWarning(SC_WARN_NO_JA3_SUPPORT,
-                    "no MD5 calculation support built in (LibNSS), skipping %s",
-                    type);
-        }
-        return 1;
-    }
-#endif /* HAVE_NSS */
-
     return 0;
 }