From 864e1b27b30ec7c12ef1b7b64c8491d8dfcbf686 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 30 Dec 2025 00:58:26 +0100 Subject: [PATCH] Add in-place encryption test --- test/default/ipcrypt.c | 16 ++++++++++++++++ test/default/ipcrypt.exp | 3 +++ 2 files changed, 19 insertions(+) diff --git a/test/default/ipcrypt.c b/test/default/ipcrypt.c index 1fd52be9..198c5b13 100644 --- a/test/default/ipcrypt.c +++ b/test/default/ipcrypt.c @@ -181,6 +181,22 @@ main(void) } printf("OK: Deterministic encryption verified\n"); + printf("\nTest 7: In-place encryption and decryption\n"); + + crypto_ipcrypt_encrypt(output, input, key); + memcpy(decrypted, input, sizeof input); + crypto_ipcrypt_encrypt(decrypted, decrypted, key); + if (memcmp(output, decrypted, sizeof output) != 0) { + printf("FAILED: In-place encryption differs from out-of-place\n"); + return 1; + } + crypto_ipcrypt_decrypt(decrypted, decrypted, key); + if (memcmp(input, decrypted, sizeof input) != 0) { + printf("FAILED: In-place decryption does not match original\n"); + return 1; + } + printf("OK: In-place round-trip successful\n"); + printf("\nAll tests passed!\n"); return 0; diff --git a/test/default/ipcrypt.exp b/test/default/ipcrypt.exp index 2ddb004a..f3fd91fa 100644 --- a/test/default/ipcrypt.exp +++ b/test/default/ipcrypt.exp @@ -46,4 +46,7 @@ Input[3]: 00000000000000000000ffff00000003 Test 6: Verify deterministic encryption OK: Deterministic encryption verified +Test 7: In-place encryption and decryption +OK: In-place round-trip successful + All tests passed!