Expose API to calculate the MD5 hash

This commit is contained in:
emanuele-f
2019-11-20 11:57:21 +01:00
parent ead0325deb
commit 68b7986d9b
2 changed files with 13 additions and 0 deletions
+2
View File
@@ -855,6 +855,8 @@ extern "C" {
ndpi_protocol l7_protocol,
ndpi_serializer *serializer);
void ndpi_md5(const u_char *data, size_t data_len, u_char hash[16]);
/* ptree (trie) API */
ndpi_ptree_t* ndpi_ptree_create(void);
int ndpi_ptree_insert(ndpi_ptree_t *tree, const ndpi_ip_addr_t *addr, u_int8_t bits, uint user_data);
+11
View File
@@ -48,6 +48,7 @@
#include "ndpi_content_match.c.inc"
#include "third_party/include/ndpi_patricia.h"
#include "third_party/include/ht_hash.h"
#include "third_party/include/ndpi_md5.h"
/* stun.c */
extern u_int32_t get_stun_lru_key(struct ndpi_flow_struct *flow, u_int8_t rev);
@@ -6711,3 +6712,13 @@ int ndpi_ptree_match_addr(ndpi_ptree_t *tree, const ndpi_ip_addr_t *addr, uint *
return(-1);
}
/* ******************************************************************** */
void ndpi_md5(const u_char *data, size_t data_len, u_char hash[16]) {
ndpi_MD5_CTX ctx;
ndpi_MD5Init(&ctx);
ndpi_MD5Update(&ctx, data, data_len);
ndpi_MD5Final(hash, &ctx);
}