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:
committed by
Andreas Schneider
parent
201fd66176
commit
239eef6322
34
src/packet.c
34
src/packet.c
@@ -1969,23 +1969,27 @@ ssh_packet_set_newkeys(ssh_session session,
|
||||
session->opts.rekey_time/1000);
|
||||
}
|
||||
|
||||
/* Initialize the encryption and decryption keys in next_crypto */
|
||||
rc = in_cipher->set_decrypt_key(in_cipher,
|
||||
session->next_crypto->decryptkey,
|
||||
session->next_crypto->decryptIV);
|
||||
if (rc < 0) {
|
||||
/* On error, make sure it is not used */
|
||||
session->next_crypto->used = 0;
|
||||
return SSH_ERROR;
|
||||
if (in_cipher->set_decrypt_key) {
|
||||
/* Initialize the encryption and decryption keys in next_crypto */
|
||||
rc = in_cipher->set_decrypt_key(in_cipher,
|
||||
session->next_crypto->decryptkey,
|
||||
session->next_crypto->decryptIV);
|
||||
if (rc < 0) {
|
||||
/* On error, make sure it is not used */
|
||||
session->next_crypto->used = 0;
|
||||
return SSH_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
rc = out_cipher->set_encrypt_key(out_cipher,
|
||||
session->next_crypto->encryptkey,
|
||||
session->next_crypto->encryptIV);
|
||||
if (rc < 0) {
|
||||
/* On error, make sure it is not used */
|
||||
session->next_crypto->used = 0;
|
||||
return SSH_ERROR;
|
||||
if (out_cipher->set_encrypt_key) {
|
||||
rc = out_cipher->set_encrypt_key(out_cipher,
|
||||
session->next_crypto->encryptkey,
|
||||
session->next_crypto->encryptIV);
|
||||
if (rc < 0) {
|
||||
/* On error, make sure it is not used */
|
||||
session->next_crypto->used = 0;
|
||||
return SSH_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return SSH_OK;
|
||||
|
||||
Reference in New Issue
Block a user