From fe979040a2dde665df7f82437ed3f02693a1f101 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Mon, 22 Jan 2007 14:15:38 +0000 Subject: [PATCH] Remove non-iovec based RSA/DSA signing (not used, and DSA code even buggy). --- src/hostkey.c | 77 ---------------------------------------------- src/libssh2_priv.h | 1 - 2 files changed, 78 deletions(-) diff --git a/src/hostkey.c b/src/hostkey.c index d109f32..ad4224d 100644 --- a/src/hostkey.c +++ b/src/hostkey.c @@ -175,44 +175,6 @@ static int libssh2_hostkey_method_ssh_rsa_sig_verify(LIBSSH2_SESSION *session, } /* }}} */ -/* {{{ libssh2_hostkey_method_ssh_rsa_sign - * Sign data to send to remote - */ -static int libssh2_hostkey_method_ssh_rsa_sign(LIBSSH2_SESSION *session, unsigned char **signature, unsigned long *signature_len, - const unsigned char *buf, unsigned long buf_len, void **abstract) -{ - RSA *rsactx = (RSA*)(*abstract); - int ret; - unsigned char hash[SHA_DIGEST_LENGTH]; - libssh2_sha1_ctx ctx; - unsigned char *sig; - unsigned int sig_len; - - sig_len = RSA_size(rsactx); - sig = LIBSSH2_ALLOC(session, sig_len); - - if (!sig) { - return -1; - } - - libssh2_sha1_init(&ctx); - libssh2_sha1_update(ctx, buf, buf_len); - libssh2_sha1_final(ctx, hash); - - ret = RSA_sign(NID_sha1, hash, SHA_DIGEST_LENGTH, sig, - &sig_len, rsactx); - if (!ret) { - LIBSSH2_FREE(session, sig); - return -1; - } - - *signature = sig; - *signature_len = sig_len; - - return 0; -} -/* }}} */ - /* {{{ libssh2_hostkey_method_ssh_rsa_signv * Construct a signature from an array of vectors */ @@ -277,7 +239,6 @@ static LIBSSH2_HOSTKEY_METHOD libssh2_hostkey_method_ssh_rsa = { libssh2_hostkey_method_ssh_rsa_init, libssh2_hostkey_method_ssh_rsa_initPEM, libssh2_hostkey_method_ssh_rsa_sig_verify, - libssh2_hostkey_method_ssh_rsa_sign, libssh2_hostkey_method_ssh_rsa_signv, NULL, /* encrypt */ libssh2_hostkey_method_ssh_rsa_dtor, @@ -392,43 +353,6 @@ static int libssh2_hostkey_method_ssh_dss_sig_verify(LIBSSH2_SESSION *session, c } /* }}} */ -/* {{{ libssh2_hostkey_method_ssh_dss_sign - * Sign data to send to remote - */ -static int libssh2_hostkey_method_ssh_dss_sign(LIBSSH2_SESSION *session, unsigned char **signature, unsigned long *signature_len, - const unsigned char *buf, unsigned long buf_len, void **abstract) -{ - DSA *dsactx = (DSA*)(*abstract); - DSA_SIG *sig; - unsigned char hash[SHA_DIGEST_LENGTH]; - libssh2_sha1_ctx ctx; - - *signature = LIBSSH2_ALLOC(session, 2 * SHA_DIGEST_LENGTH); - *signature_len = 2 * SHA_DIGEST_LENGTH; - - if (!(*signature)) { - return -1; - } - - libssh2_sha1_init(&ctx); - libssh2_sha1_update(ctx, buf, buf_len); - libssh2_sha1_final(ctx, hash); - - sig = DSA_do_sign(hash, SHA_DIGEST_LENGTH, dsactx); - if (!sig) { - LIBSSH2_FREE(session, *signature); - return -1; - } - - BN_bn2bin(sig->r, *signature); - BN_bn2bin(sig->s, *signature + SHA_DIGEST_LENGTH); - - DSA_SIG_free(sig); - - return 0; -} -/* }}} */ - /* {{{ libssh2_hostkey_method_ssh_dss_signv * Construct a signature from an array of vectors */ @@ -503,7 +427,6 @@ static LIBSSH2_HOSTKEY_METHOD libssh2_hostkey_method_ssh_dss = { libssh2_hostkey_method_ssh_dss_init, libssh2_hostkey_method_ssh_dss_initPEM, libssh2_hostkey_method_ssh_dss_sig_verify, - libssh2_hostkey_method_ssh_dss_sign, libssh2_hostkey_method_ssh_dss_signv, NULL, /* encrypt */ libssh2_hostkey_method_ssh_dss_dtor, diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index 1a79536..7e0541f 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -273,7 +273,6 @@ struct _LIBSSH2_HOSTKEY_METHOD { int (*init)(LIBSSH2_SESSION *session, unsigned char *hostkey_data, unsigned long hostkey_data_len, void **abstract); int (*initPEM)(LIBSSH2_SESSION *session, unsigned const char *privkeyfile, unsigned const char *passphrase, void **abstract); int (*sig_verify)(LIBSSH2_SESSION *session, const unsigned char *sig, unsigned long sig_len, const unsigned char *m, unsigned long m_len, void **abstract); - int (*sign)(LIBSSH2_SESSION *session, unsigned char **signature, unsigned long *signature_len, const unsigned char *data, unsigned long data_len, void **abstract); int (*signv)(LIBSSH2_SESSION *session, unsigned char **signature, unsigned long *signature_len, unsigned long veccount, const struct iovec datavec[], void **abstract); int (*encrypt)(LIBSSH2_SESSION *session, unsigned char **dst, unsigned long *dst_len, const unsigned char *src, unsigned long src_len, void **abstract); int (*dtor)(LIBSSH2_SESSION *session, void **abstract);