diff options
author | Luca Deri <lucaderi@users.noreply.github.com> | 2023-12-23 10:47:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-23 10:47:28 +0100 |
commit | 99d48383286fbb865ab58db5e5f768d8ed14f41e (patch) | |
tree | b76de4e166329667b1db41896f2f28508c5d1be4 /src/lib/protocols | |
parent | f2be9722242880fb9bff3be31d59dae6a25a8690 (diff) |
New ndpi_sha256() nDPI API call (#2230)
* Added ndpi_sha256.c to the Windows project
* Added ndpi_sha256() nDPI API call
Diffstat (limited to 'src/lib/protocols')
-rw-r--r-- | src/lib/protocols/tls.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c index 9bc948f23..fb3bd7d2e 100644 --- a/src/lib/protocols/tls.c +++ b/src/lib/protocols/tls.c @@ -1605,8 +1605,7 @@ static void ndpi_compute_ja4(struct ndpi_detection_module_struct *ndpi_struct, union ja_info *ja) { u_int8_t tmp_str[JA_STR_LEN]; u_int tmp_str_len, num_extn; - SHA256_CTX sha_ctx; - u_int8_t sha_hash[SHA256_BLOCK_SIZE]; + u_int8_t sha_hash[NDPI_SHA256_BLOCK_SIZE]; char ja_str[JA_STR_LEN]; u_int16_t ja_str_len, i; int rc; @@ -1690,9 +1689,7 @@ static void ndpi_compute_ja4(struct ndpi_detection_module_struct *ndpi_struct, if((rc > 0) && (tmp_str_len + rc < JA_STR_LEN)) tmp_str_len += rc; else break; } - ndpi_sha256_init(&sha_ctx); - ndpi_sha256_update(&sha_ctx, tmp_str, tmp_str_len); - ndpi_sha256_final(&sha_ctx, sha_hash); + ndpi_sha256(tmp_str, tmp_str_len, sha_hash); rc = ndpi_snprintf(&ja_str[ja_str_len], JA_STR_LEN-ja_str_len, "%02x%02x%02x%02x%02x%02x_", @@ -1724,9 +1721,7 @@ static void ndpi_compute_ja4(struct ndpi_detection_module_struct *ndpi_struct, printf("[EXTN] %s [len: %u]\n", tmp_str, tmp_str_len); #endif - ndpi_sha256_init(&sha_ctx); - ndpi_sha256_update(&sha_ctx, tmp_str, tmp_str_len); - ndpi_sha256_final(&sha_ctx, sha_hash); + ndpi_sha256(tmp_str, tmp_str_len, sha_hash); rc = ndpi_snprintf(&ja_str[ja_str_len], JA_STR_LEN-ja_str_len, "%02x%02x%02x%02x%02x%02x", |