From a1d80e41ddc9fc7e280a9d7167533d33aee7cdae Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Tue, 22 Aug 2023 17:59:19 +0100 Subject: [PATCH] testcrypt: allow null return from ssh2_mac_new. This can now happen if, for instance, the CLMUL implementation of aesgcm is compiled in, but not available at runtime because we're on an old Intel CPU. In this situation, testcrypt would segfault when driven by test/cryptsuite.py, and test/list-accel.py would erroneously claim the CLMUL implementation was available when it wasn't. --- test/testcrypt-func.h | 2 +- test/testcrypt.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testcrypt-func.h b/test/testcrypt-func.h index bd007293..7b955b92 100644 --- a/test/testcrypt-func.h +++ b/test/testcrypt-func.h @@ -269,7 +269,7 @@ FUNC(opt_val_hash, blake2b_new_general, ARG(uint, hashlen)) * to ssh2_mac_new. Also, again, I've invented an ssh2_mac_update so * you can put data into the MAC. */ -FUNC(val_mac, ssh2_mac_new, ARG(macalg, alg), ARG(opt_val_cipher, cipher)) +FUNC(opt_val_mac, ssh2_mac_new, ARG(macalg, alg), ARG(opt_val_cipher, cipher)) FUNC(void, ssh2_mac_setkey, ARG(val_mac, m), ARG(val_string_ptrlen, key)) FUNC(void, ssh2_mac_start, ARG(val_mac, m)) FUNC(void, ssh2_mac_update, ARG(val_mac, m), ARG(val_string_ptrlen, data)) diff --git a/test/testcrypt.c b/test/testcrypt.c index 54941cb2..3b495bba 100644 --- a/test/testcrypt.c +++ b/test/testcrypt.c @@ -584,6 +584,7 @@ NULLABLE_RETURN_WRAPPER(val_string, strbuf *) NULLABLE_RETURN_WRAPPER(val_string_asciz, char *) NULLABLE_RETURN_WRAPPER(val_string_asciz_const, const char *) NULLABLE_RETURN_WRAPPER(val_cipher, ssh_cipher *) +NULLABLE_RETURN_WRAPPER(val_mac, ssh2_mac *) NULLABLE_RETURN_WRAPPER(val_hash, ssh_hash *) NULLABLE_RETURN_WRAPPER(val_key, ssh_key *) NULLABLE_RETURN_WRAPPER(val_mpint, mp_int *)