aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTilo Eckert <tilo.eckert@flam.de>2018-12-21 13:37:13 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-01-11 15:56:02 +0100
commit481d7495590fc47300ddd016c2f301afeb6538ce (patch)
tree4a120707ea6df563c5d5fc42f5933411a642ef37 /tests
parentc7aba3a716b82a4b4f6bdb6ad7f25e2b946e7b04 (diff)
downloadlibssh-481d7495590fc47300ddd016c2f301afeb6538ce.tar.gz
libssh-481d7495590fc47300ddd016c2f301afeb6538ce.tar.xz
libssh-481d7495590fc47300ddd016c2f301afeb6538ce.zip
tests: Fix incorrect hash type parameter on signature import
RSA with SHA-256/512 signatures have been interpreted as RSA with SHA-1 Signed-off-by: Tilo Eckert <tilo.eckert@flam.de> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/torture_pki.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 8269bbb8..a3e4a22b 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -230,15 +230,20 @@ static void torture_pki_verify_mismatch(void **state)
new_sig = pki_signature_from_blob(verify_key,
blob,
sig_type,
- SSH_DIGEST_SHA1);
+ import_sig->hash_type);
if (sig_type != key_type) {
assert_true(new_sig == NULL);
} else {
/* Importing with the same key type should work */
assert_true(new_sig != NULL);
assert_int_equal(new_sig->type, key->type);
- assert_string_equal(new_sig->type_c, key->type_c);
- assert_string_equal(new_sig->type_c, signature_types[sig_type]);
+ if (key_type == SSH_KEYTYPE_RSA) {
+ assert_string_equal(key->type_c, "ssh-rsa");
+ assert_string_equal(new_sig->type_c, hash_signatures[new_sig->hash_type]);
+ } else {
+ assert_string_equal(new_sig->type_c, key->type_c);
+ assert_string_equal(new_sig->type_c, signature_types[sig_type]);
+ }
/* The verification should not work */
rc = pki_signature_verify(session,