summaryrefslogtreecommitdiff
path: root/src/lib/tests/crypt_test.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-08-16 18:19:56 +0000
committerSander Vrijders <sander@ouroboros.rocks>2026-08-31 08:31:45 +0200
commitc63b6d3aed21f474080dd491f5583123448dd1ba (patch)
treead4bf0280b50bf7569567c9785e770f289c0beaf /src/lib/tests/crypt_test.c
parent63fc20aee272482a337513786e83f82c2e0e4c99 (diff)
downloadouroboros-c63b6d3aed21f474080dd491f5583123448dd1ba.tar.gz
ouroboros-c63b6d3aed21f474080dd491f5583123448dd1ba.zip
lib: Make crypt contexts thread-safe
Moves the per-packet EVP context to a thread-local state. Now refuses a security config with -ENOTSUP without supported crypto backend (OpenSSL). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/tests/crypt_test.c')
-rw-r--r--src/lib/tests/crypt_test.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/tests/crypt_test.c b/src/lib/tests/crypt_test.c
index 50b7268a..88c9634a 100644
--- a/src/lib/tests/crypt_test.c
+++ b/src/lib/tests/crypt_test.c
@@ -364,6 +364,22 @@ static int test_crypt_aad_tamper(int nid)
goto fail_rx;
}
+ enc.data[5] ^= 0x01;
+
+ if (crypt_decrypt(rx, enc, &dec) < 0) {
+ printf("Decryption failed after a rejected packet.\n");
+ freebuf(enc);
+ goto fail_rx;
+ }
+
+ if (dec.len != in.len || memcmp(dec.data, in.data, in.len) != 0) {
+ printf("Decrypted data mismatch after rejection.\n");
+ freebuf(dec);
+ freebuf(enc);
+ goto fail_rx;
+ }
+
+ freebuf(dec);
freebuf(enc);
crypt_destroy_ctx(rx);