diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2005-08-07 10:48:08 +0000 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2005-08-07 10:48:08 +0000 |
commit | 5c26ae735483d140f802d58b1872b2fe9468d219 (patch) | |
tree | e8e8e8dea72c371e15f6e510ecc97948a4139383 /libssh/wrapper.c | |
parent | 3113d8756628f463fda33b93801aee3c6ee9aa32 (diff) | |
download | libssh-5c26ae735483d140f802d58b1872b2fe9468d219.tar.gz libssh-5c26ae735483d140f802d58b1872b2fe9468d219.tar.xz libssh-5c26ae735483d140f802d58b1872b2fe9468d219.zip |
server kex done :)
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@6 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/wrapper.c')
-rw-r--r-- | libssh/wrapper.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/libssh/wrapper.c b/libssh/wrapper.c index 1c49ed79..9d418df0 100644 --- a/libssh/wrapper.c +++ b/libssh/wrapper.c @@ -299,7 +299,6 @@ static int crypt_set_algorithms2(SSH_SESSION *session){ } ssh_say(2,"Set input algorithm %s\n",wanted); session->next_crypto->in_cipher=cipher_new(i); - /* compression */ if(strstr(session->client_kex.methods[SSH_COMP_C_S],"zlib")) session->next_crypto->do_compress_out=1; @@ -327,3 +326,61 @@ int crypt_set_algorithms(SSH_SESSION *session){ crypt_set_algorithms2(session); } +int crypt_set_algorithms_server(SSH_SESSION *session){ + /* we must scan the kex entries to find crypto algorithms and set their appropriate structure */ + int i=0; + /* out */ + char *server=session->server_kex.methods[SSH_CRYPT_S_C]; + char *client=session->client_kex.methods[SSH_CRYPT_S_C]; + char *match=ssh_find_matching(client,server); + while(ssh_ciphertab[i].name && strcmp(match,ssh_ciphertab[i].name)) + i++; + if(!ssh_ciphertab[i].name){ + ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms : no crypto algorithm function found for %s",server); + return -1; + } + ssh_say(2,"Set output algorithm %s\n",match); + session->next_crypto->out_cipher=cipher_new(i); + i=0; + /* in */ + client=session->client_kex.methods[SSH_CRYPT_C_S]; + server=session->server_kex.methods[SSH_CRYPT_S_C]; + match=ssh_find_matching(client,server); + while(ssh_ciphertab[i].name && strcmp(match,ssh_ciphertab[i].name)) + i++; + if(!ssh_ciphertab[i].name){ + ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms : no crypto algorithm function found for %s",server); + return -1; + } + ssh_say(2,"Set input algorithm %s\n",match); + session->next_crypto->in_cipher=cipher_new(i); + /* compression */ + client=session->client_kex.methods[SSH_CRYPT_C_S]; + server=session->server_kex.methods[SSH_CRYPT_C_S]; + match=ssh_find_matching(client,server); + if(match && !strcmp(match,"zlib")){ + ssh_say(2,"enabling C->S compression\n"); + session->next_crypto->do_compress_in=1; + } + + client=session->client_kex.methods[SSH_CRYPT_S_C]; + server=session->server_kex.methods[SSH_CRYPT_S_C]; + match=ssh_find_matching(client,server); + if(match && !strcmp(match,"zlib")){ + ssh_say(2,"enabling S->C compression\n"); + session->next_crypto->do_compress_out=1; + } + + server=session->server_kex.methods[SSH_HOSTKEYS]; + client=session->client_kex.methods[SSH_HOSTKEYS]; + match=ssh_find_matching(client,server); + if(!strcmp(match,"ssh-dss")) + session->hostkeys=TYPE_DSS; + else if(!strcmp(match,"ssh-rsa")) + session->hostkeys=TYPE_RSA; + else { + ssh_set_error(session,SSH_FATAL,"cannot know what %s is into %s",match,server); + return -1; + } + return 0; +} |