diff options
author | Luca Deri <lucaderi@users.noreply.github.com> | 2024-09-24 09:40:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:40:21 +0200 |
commit | 9f3b7cfd65d63c98c87d37236b83093be36420d3 (patch) | |
tree | 13164c9f4a4a647a44d2901ecdda2c9d2e179b0d /example/ndpiReader.c | |
parent | 2bf869ca594ccceca05985de648f7221e9848d37 (diff) |
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
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r-- | example/ndpiReader.c | 19 |
1 files changed, 19 insertions, 0 deletions
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(); |