New ndpi_sha256() nDPI API call (#2230)

* Added ndpi_sha256.c to the Windows project

* Added ndpi_sha256() nDPI API call
This commit is contained in:
Luca Deri
2023-12-23 10:47:28 +01:00
committed by GitHub
parent f2be972224
commit 99d4838328
6 changed files with 27 additions and 17 deletions
+3 -8
View File
@@ -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",