1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00

packet: Check if set_*_key functions exists before calling it

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2020-04-28 12:27:03 +02:00
committed by Andreas Schneider
parent 201fd66176
commit 239eef6322

View File

@@ -1969,23 +1969,27 @@ ssh_packet_set_newkeys(ssh_session session,
session->opts.rekey_time/1000); session->opts.rekey_time/1000);
} }
/* Initialize the encryption and decryption keys in next_crypto */ if (in_cipher->set_decrypt_key) {
rc = in_cipher->set_decrypt_key(in_cipher, /* Initialize the encryption and decryption keys in next_crypto */
session->next_crypto->decryptkey, rc = in_cipher->set_decrypt_key(in_cipher,
session->next_crypto->decryptIV); session->next_crypto->decryptkey,
if (rc < 0) { session->next_crypto->decryptIV);
/* On error, make sure it is not used */ if (rc < 0) {
session->next_crypto->used = 0; /* On error, make sure it is not used */
return SSH_ERROR; session->next_crypto->used = 0;
return SSH_ERROR;
}
} }
rc = out_cipher->set_encrypt_key(out_cipher, if (out_cipher->set_encrypt_key) {
session->next_crypto->encryptkey, rc = out_cipher->set_encrypt_key(out_cipher,
session->next_crypto->encryptIV); session->next_crypto->encryptkey,
if (rc < 0) { session->next_crypto->encryptIV);
/* On error, make sure it is not used */ if (rc < 0) {
session->next_crypto->used = 0; /* On error, make sure it is not used */
return SSH_ERROR; session->next_crypto->used = 0;
return SSH_ERROR;
}
} }
return SSH_OK; return SSH_OK;