From ae4ef84702cbecd4ca004349bcb4ff6cae6153fe Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 30 Mar 2009 13:11:47 +0000 Subject: Create a ssh_get_hexa function. This function converts a buffer into a colon separated hex string. git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@308 7dcaeef0-15fb-0310-b436-a5af3365683c --- include/libssh/libssh.h | 3 ++- libssh/dh.c | 57 ++++++++++++++++++++++++++++++++++++++++--------- libssh/libssh.vers | 2 +- sample.c | 7 ++++-- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 233f9f6c..d865aa36 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -231,7 +231,8 @@ void *string_data(STRING *str); void string_free(STRING *str); /* useful for debug */ -void ssh_print_hexa(char *descr, const unsigned char *what, int len); +char *ssh_get_hexa(const unsigned char *what, size_t len); +void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len); int ssh_get_random(void *where,int len,int strong); /* this one can be called by the client to see the hash of the public key before accepting it */ diff --git a/libssh/dh.c b/libssh/dh.c index 924c5755..377cfe34 100644 --- a/libssh/dh.c +++ b/libssh/dh.c @@ -141,17 +141,54 @@ void ssh_print_bignum(char *which,bignum num){ free(hex); } -void ssh_print_hexa(char *descr, const unsigned char *what, int len){ - int i; - printf("%s : ",descr); - if(len>16) - printf ("\n "); - for(i=0;i