From 9f3b7cfd65d63c98c87d37236b83093be36420d3 Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Tue, 24 Sep 2024 09:40:21 +0200 Subject: Added ndpi_quick_encrypt() ndpi_quick_decrypt() APi calls (#2568) * Added ndpi_quick_encrypt() ndpi_quick_decrypt(0 APi calls based on AES * Added aes.c --- example/ndpiReader.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'example') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 0d3a42791..1a1a34073 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -6203,6 +6203,24 @@ void ballTreeUnitTest() { /* *********************************************** */ +void cryptDecryptUnitTest() { + u_char enc_dec_key[64] = "9dedb817e5a8805c1de62eb8982665b9a2b4715174c34d23b9a46ffafacfb2a7" /* SHA256("nDPI") */; + const char *test_string = "The quick brown fox jumps over the lazy dog"; + char *enc, *dec; + + enc = ndpi_quick_encrypt(test_string, strlen(test_string), enc_dec_key); + assert(enc != NULL); + dec = ndpi_quick_decrypt((const char*)enc, strlen(enc), enc_dec_key); + assert(dec != NULL); + + assert(strcmp(dec, test_string) == 0); + + ndpi_free(enc); + ndpi_free(dec); +} + +/* *********************************************** */ + void encodeDomainsUnitTest() { NDPI_PROTOCOL_BITMASK all; struct ndpi_detection_module_struct *ndpi_str = ndpi_init_detection_module(NULL); @@ -6383,6 +6401,7 @@ int main(int argc, char **argv) { exit(0); #endif + cryptDecryptUnitTest(); kdUnitTest(); encodeDomainsUnitTest(); loadStressTest(); -- cgit v1.2.3