mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
Improve packet_decrypt().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@479 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -57,11 +57,15 @@ u32 packet_decrypt_len(SSH_SESSION *session, char *crypted){
|
|||||||
|
|
||||||
int packet_decrypt(SSH_SESSION *session, void *data,u32 len) {
|
int packet_decrypt(SSH_SESSION *session, void *data,u32 len) {
|
||||||
struct crypto_struct *crypto = session->current_crypto->in_cipher;
|
struct crypto_struct *crypto = session->current_crypto->in_cipher;
|
||||||
char *out=malloc(len);
|
char *out = NULL;
|
||||||
|
|
||||||
|
out = malloc(len);
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_log(session,SSH_LOG_PACKET, "Decrypting %d bytes", len);
|
ssh_log(session,SSH_LOG_PACKET, "Decrypting %d bytes", len);
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey,session->current_crypto->decryptIV);
|
crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey,session->current_crypto->decryptIV);
|
||||||
crypto->cbc_decrypt(crypto,data,out,len);
|
crypto->cbc_decrypt(crypto,data,out,len);
|
||||||
@@ -69,9 +73,11 @@ int packet_decrypt(SSH_SESSION *session, void *data,u32 len){
|
|||||||
crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey);
|
crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey);
|
||||||
crypto->cbc_decrypt(crypto,data,out,len,session->current_crypto->decryptIV);
|
crypto->cbc_decrypt(crypto,data,out,len,session->current_crypto->decryptIV);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memcpy(data,out,len);
|
memcpy(data,out,len);
|
||||||
memset(out,0,len);
|
memset(out,0,len);
|
||||||
free(out);
|
|
||||||
|
SAFE_FREE(out);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user