aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDirkjan Bussink <d.bussink@gmail.com>2014-04-20 10:10:38 +0000
committerAndreas Schneider <asn@cryptomilk.org>2014-04-22 10:57:35 +0200
commitc520d97dd9d58a11284cbd28c9d1fef026d94f45 (patch)
treee32a525fe8d364b3465b5331df4257f0aef6c4ed /tests
parent6c74d6f891bab99f68fffdb78dec66de369898c7 (diff)
downloadlibssh-c520d97dd9d58a11284cbd28c9d1fef026d94f45.tar.gz
libssh-c520d97dd9d58a11284cbd28c9d1fef026d94f45.tar.xz
libssh-c520d97dd9d58a11284cbd28c9d1fef026d94f45.zip
Add tests for SHA2 HMAC algorithms
BUG: https://red.libssh.org/issues/91 Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/client/torture_algorithms.c136
1 files changed, 111 insertions, 25 deletions
diff --git a/tests/client/torture_algorithms.c b/tests/client/torture_algorithms.c
index 180efb71..8a466380 100644
--- a/tests/client/torture_algorithms.c
+++ b/tests/client/torture_algorithms.c
@@ -37,7 +37,7 @@ static void teardown(void **state) {
ssh_free(*state);
}
-static void test_algorithm(ssh_session session, const char *algo) {
+static void test_algorithm(ssh_session session, const char *algo, const char *hmac) {
int rc;
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
@@ -49,6 +49,12 @@ static void test_algorithm(ssh_session session, const char *algo) {
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, algo);
assert_true(rc == SSH_OK);
+ rc = ssh_options_set(session, SSH_OPTIONS_HMAC_C_S, hmac);
+ assert_true(rc == SSH_OK);
+
+ rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, hmac);
+ assert_true(rc == SSH_OK);
+
rc = ssh_connect(session);
assert_true(rc == SSH_OK);
@@ -61,36 +67,100 @@ static void test_algorithm(ssh_session session, const char *algo) {
ssh_disconnect(session);
}
-static void torture_algorithms_aes128_cbc(void **state) {
- test_algorithm(*state, "aes128-cbc");
+static void torture_algorithms_aes128_cbc_hmac_sha1(void **state) {
+ test_algorithm(*state, "aes128-cbc", "hmac-sha1");
+}
+
+static void torture_algorithms_aes128_cbc_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "aes128-cbc", "hmac-sha2-256");
+}
+
+static void torture_algorithms_aes128_cbc_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "aes128-cbc", "hmac-sha2-512");
+}
+
+static void torture_algorithms_aes192_cbc_hmac_sha1(void **state) {
+ test_algorithm(*state, "aes192-cbc", "hmac-sha1");
+}
+
+static void torture_algorithms_aes192_cbc_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "aes192-cbc", "hmac-sha2-256");
+}
+
+static void torture_algorithms_aes192_cbc_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "aes192-cbc", "hmac-sha2-512");
+}
+
+static void torture_algorithms_aes256_cbc_hmac_sha1(void **state) {
+ test_algorithm(*state, "aes256-cbc", "hmac-sha1");
+}
+
+static void torture_algorithms_aes256_cbc_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "aes256-cbc", "hmac-sha2-256");
+}
+
+static void torture_algorithms_aes256_cbc_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "aes256-cbc", "hmac-sha2-512");
+}
+
+static void torture_algorithms_aes128_ctr_hmac_sha1(void **state) {
+ test_algorithm(*state, "aes128-ctr", "hmac-sha1");
+}
+
+static void torture_algorithms_aes128_ctr_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "aes128-ctr", "hmac-sha2-256");
+}
+
+static void torture_algorithms_aes128_ctr_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "aes128-ctr", "hmac-sha2-512");
+}
+
+static void torture_algorithms_aes192_ctr_hmac_sha1(void **state) {
+ test_algorithm(*state, "aes192-ctr", "hmac-sha1");
+}
+
+static void torture_algorithms_aes192_ctr_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "aes192-ctr", "hmac-sha2-256");
+}
+
+static void torture_algorithms_aes192_ctr_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "aes192-ctr", "hmac-sha2-512");
+}
+
+static void torture_algorithms_aes256_ctr_hmac_sha1(void **state) {
+ test_algorithm(*state, "aes256-ctr", "hmac-sha1");
+}
+
+static void torture_algorithms_aes256_ctr_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "aes256-ctr", "hmac-sha2-256");
}
-static void torture_algorithms_aes192_cbc(void **state) {
- test_algorithm(*state, "aes192-cbc");
+static void torture_algorithms_aes256_ctr_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "aes256-ctr", "hmac-sha2-512");
}
-static void torture_algorithms_aes256_cbc(void **state) {
- test_algorithm(*state, "aes256-cbc");
+static void torture_algorithms_3des_cbc_hmac_sha1(void **state) {
+ test_algorithm(*state, "3des-cbc", "hmac-sha1");
}
-static void torture_algorithms_aes128_ctr(void **state) {
- test_algorithm(*state, "aes128-ctr");
+static void torture_algorithms_3des_cbc_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "3des-cbc", "hmac-sha2-256");
}
-static void torture_algorithms_aes192_ctr(void **state) {
- test_algorithm(*state, "aes192-ctr");
+static void torture_algorithms_3des_cbc_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "3des-cbc", "hmac-sha2-512");
}
-static void torture_algorithms_aes256_ctr(void **state) {
- test_algorithm(*state, "aes256-ctr");
+static void torture_algorithms_blowfish_cbc_hmac_sha1(void **state) {
+ test_algorithm(*state, "blowfish-cbc", "hmac-sha1");
}
-static void torture_algorithms_3des_cbc(void **state) {
- test_algorithm(*state, "3des-cbc");
+static void torture_algorithms_blowfish_cbc_hmac_sha2_256(void **state) {
+ test_algorithm(*state, "blowfish-cbc", "hmac-sha2-256");
}
-static void torture_algorithms_blowfish_cbc(void **state) {
- test_algorithm(*state, "blowfish-cbc");
+static void torture_algorithms_blowfish_cbc_hmac_sha2_512(void **state) {
+ test_algorithm(*state, "blowfish-cbc", "hmac-sha2-512");
}
static void torture_algorithms_zlib(void **state) {
@@ -220,14 +290,30 @@ static void torture_algorithms_dh_group1(void **state) {
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {
- unit_test_setup_teardown(torture_algorithms_aes128_cbc, setup, teardown),
- unit_test_setup_teardown(torture_algorithms_aes192_cbc, setup, teardown),
- unit_test_setup_teardown(torture_algorithms_aes256_cbc, setup, teardown),
- unit_test_setup_teardown(torture_algorithms_aes128_ctr, setup, teardown),
- unit_test_setup_teardown(torture_algorithms_aes192_ctr, setup, teardown),
- unit_test_setup_teardown(torture_algorithms_aes256_ctr, setup, teardown),
- unit_test_setup_teardown(torture_algorithms_3des_cbc, setup, teardown),
- unit_test_setup_teardown(torture_algorithms_blowfish_cbc, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_512, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_512, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_512, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_512, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_512, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_512, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_512, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha1, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_256, setup, teardown),
+ unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_512, setup, teardown),
unit_test_setup_teardown(torture_algorithms_zlib, setup, teardown),
unit_test_setup_teardown(torture_algorithms_zlib_openssh, setup, teardown),
unit_test_setup_teardown(torture_algorithms_dh_group1,setup,teardown),