mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
packet_crypt: Avoid setting keys every time
Avoid setting keys on every packet decrypt or encrypt operation. Signed-off-by: Alberto Aguirre <albaguirre@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
23accdde1a
commit
1ece5a849c
@@ -117,13 +117,6 @@ int ssh_packet_decrypt(ssh_session session,
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = crypto->set_decrypt_key(crypto,
|
|
||||||
session->current_crypto->decryptkey,
|
|
||||||
session->current_crypto->decryptIV);
|
|
||||||
if (rc < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crypto->aead_decrypt != NULL) {
|
if (crypto->aead_decrypt != NULL) {
|
||||||
return crypto->aead_decrypt(crypto,
|
return crypto->aead_decrypt(crypto,
|
||||||
source,
|
source,
|
||||||
@@ -177,12 +170,6 @@ unsigned char *ssh_packet_encrypt(ssh_session session, void *data, uint32_t len)
|
|||||||
hmac_update(ctx,data,len);
|
hmac_update(ctx,data,len);
|
||||||
hmac_final(ctx,session->current_crypto->hmacbuf,&finallen);
|
hmac_final(ctx,session->current_crypto->hmacbuf,&finallen);
|
||||||
|
|
||||||
if (crypto->set_encrypt_key(crypto, session->current_crypto->encryptkey,
|
|
||||||
session->current_crypto->encryptIV) < 0) {
|
|
||||||
SAFE_FREE(out);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("mac: ",data,hmac_digest_len(type));
|
ssh_print_hexa("mac: ",data,hmac_digest_len(type));
|
||||||
if (finallen != hmac_digest_len(type)) {
|
if (finallen != hmac_digest_len(type)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user