aboutsummaryrefslogtreecommitdiff
path: root/src/server.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-11-22 16:01:56 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-01-09 10:31:45 +0100
commitc86a00d06b732c57153bdd5677a5d77f7f1be0a9 (patch)
tree45f849845429ea810eb8e600896383454956eae9 /src/server.c
parent8e0c047031d69bdf882f550886e3dd43afd8db05 (diff)
downloadlibssh-c86a00d06b732c57153bdd5677a5d77f7f1be0a9.tar.gz
libssh-c86a00d06b732c57153bdd5677a5d77f7f1be0a9.tar.xz
libssh-c86a00d06b732c57153bdd5677a5d77f7f1be0a9.zip
packet: Provide a function to switch crypto in separate directions
This also fixes the test using the crypto directly Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Daiki Ueno <dueno@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/server.c')
-rw-r--r--src/server.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/server.c b/src/server.c
index 5702e5c9..78e5ece6 100644
--- a/src/server.c
+++ b/src/server.c
@@ -484,37 +484,9 @@ static void ssh_server_connection_callback(ssh_session session){
break;
case SSH_SESSION_STATE_DH:
if(session->dh_handshake_state==DH_STATE_FINISHED){
- if (ssh_generate_session_keys(session) < 0) {
- goto error;
- }
-
- /*
- * Once we got SSH2_MSG_NEWKEYS we can switch next_crypto and
- * current_crypto
- */
- if (session->current_crypto) {
- crypto_free(session->current_crypto);
- }
- /* FIXME TODO later, include a function to change keys */
- session->current_crypto = session->next_crypto;
- session->next_crypto = crypto_new();
- if (session->next_crypto == NULL) {
- goto error;
- }
- session->next_crypto->session_id = malloc(session->current_crypto->digest_len);
- if (session->next_crypto->session_id == NULL) {
- ssh_set_error_oom(session);
- goto error;
- }
- memcpy(session->next_crypto->session_id, session->current_crypto->session_id,
- session->current_crypto->digest_len);
- if (session->current_crypto->in_cipher->set_decrypt_key(session->current_crypto->in_cipher, session->current_crypto->decryptkey,
- session->current_crypto->decryptIV) < 0) {
- goto error;
- }
- if (session->current_crypto->out_cipher->set_encrypt_key(session->current_crypto->out_cipher, session->current_crypto->encryptkey,
- session->current_crypto->encryptIV) < 0) {
+ rc = ssh_packet_set_newkeys(session, SSH_DIRECTION_IN);
+ if (rc != SSH_OK) {
goto error;
}