aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2020-04-28 13:09:54 +0200
committerAndreas Schneider <asn@cryptomilk.org>2020-05-05 14:23:06 +0200
commitb90131dfe696b40b7cc0bc18cdfc307e6d14480a (patch)
tree18e5391aa5be574a5a0cdd8042183ce958e5838d
parent4f976ce5c4a393d528d05a8ef2e270f9ac1d3b96 (diff)
downloadlibssh-b90131dfe696b40b7cc0bc18cdfc307e6d14480a.tar.gz
libssh-b90131dfe696b40b7cc0bc18cdfc307e6d14480a.tar.xz
libssh-b90131dfe696b40b7cc0bc18cdfc307e6d14480a.zip
tests: Verify functionality of none cipher and mac
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--tests/unittests/torture_packet.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/tests/unittests/torture_packet.c b/tests/unittests/torture_packet.c
index 130ddad0..9f07f394 100644
--- a/tests/unittests/torture_packet.c
+++ b/tests/unittests/torture_packet.c
@@ -93,17 +93,21 @@ torture_packet(const char *cipher, const char *mac_type,
crypto->decryptMAC = copy_data(mac, sizeof(mac));
in_cipher = session->current_crypto->in_cipher;
- rc = in_cipher->set_decrypt_key(in_cipher,
- session->current_crypto->decryptkey,
- session->current_crypto->decryptIV);
- assert_int_equal(rc, SSH_OK);
+ if (in_cipher->set_decrypt_key != NULL) {
+ rc = in_cipher->set_decrypt_key(in_cipher,
+ session->current_crypto->decryptkey,
+ session->current_crypto->decryptIV);
+ assert_int_equal(rc, SSH_OK);
+ }
out_cipher = session->current_crypto->out_cipher;
- rc = out_cipher->set_encrypt_key(out_cipher,
- session->current_crypto->encryptkey,
- session->current_crypto->encryptIV);
+ if (out_cipher->set_decrypt_key != NULL) {
+ rc = out_cipher->set_encrypt_key(out_cipher,
+ session->current_crypto->encryptkey,
+ session->current_crypto->encryptIV);
+ assert_int_equal(rc, SSH_OK);
+ }
session->current_crypto->used = SSH_DIRECTION_BOTH;
- assert_int_equal(rc, SSH_OK);
assert_non_null(session->out_buffer);
ssh_buffer_add_data(session->out_buffer, test_data, payload_len);
@@ -161,6 +165,35 @@ static void torture_packet_aes256_ctr_etm(UNUSED_PARAM(void **state))
}
}
+#ifdef WITH_INSECURE_NONE
+static void torture_packet_none_sha1(UNUSED_PARAM(void **state))
+{
+ int i;
+
+ for (i = 1; i < 256; ++i) {
+ torture_packet("none", "hmac-sha1", "none", i);
+ }
+}
+
+static void torture_packet_aes128_ctr_none(UNUSED_PARAM(void **state))
+{
+ int i;
+
+ for (i = 1; i < 256; ++i) {
+ torture_packet("aes128-ctr", "none", "none", i);
+ }
+}
+
+static void torture_packet_none_none(UNUSED_PARAM(void **state))
+{
+ int i;
+
+ for (i = 1; i < 256; ++i) {
+ torture_packet("none", "none", "none", i);
+ }
+}
+#endif /* WITH_INSECURE_NONE */
+
static void torture_packet_aes128_ctr(void **state)
{
int i;
@@ -329,6 +362,11 @@ int torture_run_tests(void) {
cmocka_unit_test(torture_packet_aes256_gcm),
cmocka_unit_test(torture_packet_compress_zlib),
cmocka_unit_test(torture_packet_compress_zlib_openssh),
+#ifdef WITH_INSECURE_NONE
+ cmocka_unit_test(torture_packet_none_sha1),
+ cmocka_unit_test(torture_packet_aes128_ctr_none),
+ cmocka_unit_test(torture_packet_none_none),
+#endif
};
ssh_init();