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/ndpi_main.c | |
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/ndpi_main.c')
-rw-r--r-- | src/lib/ndpi_main.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index e80cef78e..0b9b28864 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -124,6 +124,7 @@ /* Third party libraries */ #include "third_party/include/ndpi_patricia.h" #include "third_party/include/ndpi_md5.h" +#include "third_party/include/ndpi_sha256.h" #ifdef HAVE_NBPF #include "nbpf.h" @@ -10092,6 +10093,16 @@ void ndpi_md5(const u_char *data, size_t data_len, u_char hash[16]) { /* ******************************************************************** */ +void ndpi_sha256(const u_char *data, size_t data_len, u_int8_t sha_hash[32]) { + ndpi_SHA256_CTX sha_ctx; + + ndpi_sha256_init(&sha_ctx); + ndpi_sha256_update(&sha_ctx, data, data_len); + ndpi_sha256_final(&sha_ctx, sha_hash); +} + +/* ******************************************************************** */ + static int enough(int a, int b) { u_int8_t percentage = 20; |