diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-09-02 16:12:31 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-09-20 17:23:41 +0200 |
commit | 03134c2932e2ac2633617aa8a94cdc4dd2728453 (patch) | |
tree | c9b34284a0342bd595c70c1d535574b03e3252af | |
parent | 95d0c143b3298178821870f119e56f871abbf8aa (diff) | |
download | libssh-03134c2932e2ac2633617aa8a94cdc4dd2728453.tar.gz libssh-03134c2932e2ac2633617aa8a94cdc4dd2728453.tar.xz libssh-03134c2932e2ac2633617aa8a94cdc4dd2728453.zip |
tests: Add test for ssh_get_fingerprint_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 5a198732a5cefac63fef3dc9d6a4dafa2ca6b87a)
-rw-r--r-- | tests/unittests/torture_hashes.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unittests/torture_hashes.c b/tests/unittests/torture_hashes.c index 2e242563..104aa7c9 100644 --- a/tests/unittests/torture_hashes.c +++ b/tests/unittests/torture_hashes.c @@ -101,6 +101,30 @@ static void torture_sha256_hash(void **state) } +static void torture_sha256_fingerprint(void **state) +{ + ssh_key pubkey = *state; + unsigned char *hash = NULL; + char *sha256 = NULL; + int rc = 0; + size_t hlen; + + rc = ssh_get_publickey_hash(pubkey, + SSH_PUBLICKEY_HASH_SHA256, + &hash, + &hlen); + assert_true(rc == 0); + + sha256 = ssh_get_fingerprint_hash(SSH_PUBLICKEY_HASH_SHA256, + hash, + hlen); + ssh_string_free_char(discard_const(hash)); + assert_string_equal(sha256, + "SHA256:jXstVLLe84fSDo1kEYGn6iumnPCSorhaiWxnJz8VTII"); + + ssh_string_free_char(sha256); +} + int torture_run_tests(void) { int rc; struct CMUnitTest tests[] = { @@ -113,6 +137,9 @@ int torture_run_tests(void) { cmocka_unit_test_setup_teardown(torture_sha256_hash, setup_rsa_key, teardown), + cmocka_unit_test_setup_teardown(torture_sha256_fingerprint, + setup_rsa_key, + teardown), }; torture_filter_tests(tests); |