From 6df87e64b78ae794ba49a5937b093e4c5dad4914 Mon Sep 17 00:00:00 2001 From: Peter Stuge Date: Fri, 29 Jan 2010 23:06:31 +0100 Subject: [PATCH] Use LIBSSH2_HOSTKEY_HASH_SHA1 instead of _MD5 in examples and tests MD5 support is optional and may not always be available, while SHA1 is both required and recommended. --- example/direct_tcpip.c | 4 ++-- example/scp.c | 4 ++-- example/scp_nonblock.c | 4 ++-- example/scp_write.c | 4 ++-- example/scp_write_nonblock.c | 4 ++-- example/sftp.c | 4 ++-- example/sftp_RW_nonblock.c | 4 ++-- example/sftp_mkdir.c | 4 ++-- example/sftp_mkdir_nonblock.c | 4 ++-- example/sftp_nonblock.c | 4 ++-- example/sftp_write.c | 4 ++-- example/sftp_write_nonblock.c | 4 ++-- example/sftpdir.c | 4 ++-- example/sftpdir_nonblock.c | 4 ++-- example/ssh2.c | 4 ++-- example/ssh2_agent.c | 4 ++-- tests/ssh2.c | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/example/direct_tcpip.c b/example/direct_tcpip.c index 8b3bfbde..224798a4 100644 --- a/example/direct_tcpip.c +++ b/example/direct_tcpip.c @@ -126,9 +126,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); fprintf(stderr, "Fingerprint: "); - for(i = 0; i < 16; i++) + for(i = 0; i < 20; i++) fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]); fprintf(stderr, "\n"); diff --git a/example/scp.c b/example/scp.c index 12c0c922..fee7b07c 100644 --- a/example/scp.c +++ b/example/scp.c @@ -103,9 +103,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); fprintf(stderr, "Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]); } fprintf(stderr, "\n"); diff --git a/example/scp_nonblock.c b/example/scp_nonblock.c index 3480cfd8..ff0c2879 100644 --- a/example/scp_nonblock.c +++ b/example/scp_nonblock.c @@ -160,9 +160,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); fprintf(stderr, "Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]); } fprintf(stderr, "\n"); diff --git a/example/scp_write.c b/example/scp_write.c index f6af1865..c8623a5a 100644 --- a/example/scp_write.c +++ b/example/scp_write.c @@ -118,9 +118,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); fprintf(stderr, "Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]); } fprintf(stderr, "\n"); diff --git a/example/scp_write_nonblock.c b/example/scp_write_nonblock.c index 092505e2..d9509a1a 100644 --- a/example/scp_write_nonblock.c +++ b/example/scp_write_nonblock.c @@ -126,9 +126,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); fprintf(stderr, "Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]); } fprintf(stderr, "\n"); diff --git a/example/sftp.c b/example/sftp.c index 2c9c2c3c..f443b907 100644 --- a/example/sftp.c +++ b/example/sftp.c @@ -136,9 +136,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); fprintf(stderr, "Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]); } fprintf(stderr, "\n"); diff --git a/example/sftp_RW_nonblock.c b/example/sftp_RW_nonblock.c index 70aad82a..69a6fa1a 100644 --- a/example/sftp_RW_nonblock.c +++ b/example/sftp_RW_nonblock.c @@ -109,9 +109,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/sftp_mkdir.c b/example/sftp_mkdir.c index 8d61fed7..ccbabe02 100644 --- a/example/sftp_mkdir.c +++ b/example/sftp_mkdir.c @@ -105,9 +105,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/sftp_mkdir_nonblock.c b/example/sftp_mkdir_nonblock.c index 346dab26..c9303faa 100644 --- a/example/sftp_mkdir_nonblock.c +++ b/example/sftp_mkdir_nonblock.c @@ -108,9 +108,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/sftp_nonblock.c b/example/sftp_nonblock.c index 45e15548..984ef842 100644 --- a/example/sftp_nonblock.c +++ b/example/sftp_nonblock.c @@ -161,9 +161,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); fprintf(stderr, "Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]); } fprintf(stderr, "\n"); diff --git a/example/sftp_write.c b/example/sftp_write.c index 4d583ab0..02c46548 100644 --- a/example/sftp_write.c +++ b/example/sftp_write.c @@ -123,9 +123,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/sftp_write_nonblock.c b/example/sftp_write_nonblock.c index a40046f0..3a7308a9 100644 --- a/example/sftp_write_nonblock.c +++ b/example/sftp_write_nonblock.c @@ -127,9 +127,9 @@ int main(int argc, char *argv[]) * have it hard coded, may go to a file, may present it to the user, * that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/sftpdir.c b/example/sftpdir.c index dd679530..dfa7ad03 100644 --- a/example/sftpdir.c +++ b/example/sftpdir.c @@ -105,9 +105,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/sftpdir_nonblock.c b/example/sftpdir_nonblock.c index 4389022c..9de2e47a 100644 --- a/example/sftpdir_nonblock.c +++ b/example/sftpdir_nonblock.c @@ -111,9 +111,9 @@ int main(int argc, char *argv[]) * may have it hard coded, may go to a file, may present it to the * user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/ssh2.c b/example/ssh2.c index 90eebfdd..97fb0ce6 100644 --- a/example/ssh2.c +++ b/example/ssh2.c @@ -121,9 +121,9 @@ int main(int argc, char *argv[]) * hard coded, may go to a file, may present it to the user, that's your * call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/example/ssh2_agent.c b/example/ssh2_agent.c index 6b0c3236..bebeb88c 100644 --- a/example/ssh2_agent.c +++ b/example/ssh2_agent.c @@ -150,9 +150,9 @@ int main(int argc, char *argv[]) * hard coded, may go to a file, may present it to the user, that's your * call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n"); diff --git a/tests/ssh2.c b/tests/ssh2.c index 20f1d8b9..e09ba8ab 100644 --- a/tests/ssh2.c +++ b/tests/ssh2.c @@ -90,9 +90,9 @@ int main(int argc, char *argv[]) * The first thing to do is check the hostkey's fingerprint against our known hosts * Your app may have it hard coded, may go to a file, may present it to the user, that's your call */ - fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5); + fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); printf("Fingerprint: "); - for(i = 0; i < 16; i++) { + for(i = 0; i < 20; i++) { printf("%02X ", (unsigned char)fingerprint[i]); } printf("\n");