aboutsummaryrefslogtreecommitdiff
path: root/libssh/crypt.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-17 12:52:27 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-17 12:52:27 +0000
commit845615cdd87acc892ec6a28930b5510d52e802fe (patch)
tree3d3b8b4f2106de6f5481296eee04b04d61e6c6dc /libssh/crypt.c
parent32fd37d1ad88e18db9322b626893e34d318b4172 (diff)
downloadlibssh-845615cdd87acc892ec6a28930b5510d52e802fe.tar.gz
libssh-845615cdd87acc892ec6a28930b5510d52e802fe.tar.xz
libssh-845615cdd87acc892ec6a28930b5510d52e802fe.zip
Add return values to set_encrypt_key and set_decrypt_key.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@519 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/crypt.c')
-rw-r--r--libssh/crypt.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/libssh/crypt.c b/libssh/crypt.c
index 27d02cc..8ccdc56 100644
--- a/libssh/crypt.c
+++ b/libssh/crypt.c
@@ -67,10 +67,17 @@ int packet_decrypt(SSH_SESSION *session, void *data,u32 len) {
ssh_log(session,SSH_LOG_PACKET, "Decrypting %d bytes", len);
#ifdef HAVE_LIBGCRYPT
- crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey,session->current_crypto->decryptIV);
+ if (crypto->set_decrypt_key(crypto, session->current_crypto->decryptkey,
+ session->current_crypto->decryptIV) < 0) {
+ SAFE_FREE(out);
+ return -1;
+ }
crypto->cbc_decrypt(crypto,data,out,len);
#elif defined HAVE_LIBCRYPTO
- crypto->set_decrypt_key(crypto,session->current_crypto->decryptkey);
+ if (crypto->set_decrypt_key(crypto, session->current_crypto->decryptkey) < 0) {
+ SAFE_FREE(out);
+ return -1;
+ }
crypto->cbc_decrypt(crypto,data,out,len,session->current_crypto->decryptIV);
#endif
@@ -105,10 +112,16 @@ unsigned char *packet_encrypt(SSH_SESSION *session, void *data, u32 len) {
session->send_seq,len);
#ifdef HAVE_LIBGCRYPT
- crypto->set_encrypt_key(crypto, session->current_crypto->encryptkey,
- session->current_crypto->encryptIV);
+ if (crypto->set_encrypt_key(crypto, session->current_crypto->encryptkey,
+ session->current_crypto->encryptIV) < 0) {
+ SAFE_FREE(out);
+ return NULL;
+ }
#elif defined HAVE_LIBCRYPTO
- crypto->set_encrypt_key(crypto, session->current_crypto->encryptkey);
+ if (crypto->set_encrypt_key(crypto, session->current_crypto->encryptkey) < 0) {
+ SAFE_FREE(out);
+ return NULL;
+ }
#endif
if (session->version == 2) {