diff options
author | Iru Cai <mytbk920423@gmail.com> | 2016-11-05 14:54:10 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2016-11-08 15:16:40 +0800 |
commit | 0a817b9fcb8e7a1bf5c4a910eb0de1a549b5ba9f (patch) | |
tree | f765c09f54e47f0d1e34afb5d09885579e946c76 /src/protocol/internal/fqterm_ssh1_packet.cpp | |
parent | 92c88c20fe34add9876e9d4e89813ea285f1bbac (diff) | |
download | fqterm-0a817b9fcb8e7a1bf5c4a910eb0de1a549b5ba9f.tar.xz |
Implement ssh_cipher_t for symmetric ciphers in SSH
* remove FQTermSSHCipher and FQTermSSH3DES, use ssh_cipher_t instead
* implement EVP ciphers and 3DES-SSH1
Diffstat (limited to 'src/protocol/internal/fqterm_ssh1_packet.cpp')
-rw-r--r-- | src/protocol/internal/fqterm_ssh1_packet.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/protocol/internal/fqterm_ssh1_packet.cpp b/src/protocol/internal/fqterm_ssh1_packet.cpp index ded7fe4..aab8f92 100644 --- a/src/protocol/internal/fqterm_ssh1_packet.cpp +++ b/src/protocol/internal/fqterm_ssh1_packet.cpp @@ -21,7 +21,6 @@ #include "fqterm_trace.h" #include "fqterm_ssh_buffer.h" #include "fqterm_ssh1_packet.h" -#include "fqterm_ssh_des.h" #include "fqterm_serialization.h" #include "crc32.h" @@ -43,6 +42,11 @@ namespace FQTerm { // //============================================================================== + FQTermSSH1PacketSender::FQTermSSH1PacketSender() + { + cipher = new_3des_ssh1(1); + } + void FQTermSSH1PacketSender::makePacket() { int len, padding, i; u_int32_t rand_val = 0; @@ -68,14 +72,20 @@ void FQTermSSH1PacketSender::makePacket() { output_buffer_->putInt(ssh_crc32(output_buffer_->data() + 4, output_buffer_->len() - 4)); if (is_encrypt_) { - cipher_->encrypt(output_buffer_->data() + 4, output_buffer_->data() + 4, output_buffer_->len() - 4); - } + cipher->crypt(cipher, output_buffer_->data() + 4, output_buffer_->data() + 4, output_buffer_->len() - 4); + } } //============================================================================== //FQTermSSH1PacketReceiver //============================================================================== + + FQTermSSH1PacketReceiver::FQTermSSH1PacketReceiver() + { + cipher = new_3des_ssh1(0); + } + void FQTermSSH1PacketReceiver::parseData(FQTermSSHBuffer *input) { u_int mycrc, gotcrc; u_char *buf = NULL; @@ -116,11 +126,11 @@ void FQTermSSH1PacketReceiver::parseData(FQTermSSHBuffer *input) { input->getRawData((char*)sourceData, total_len); if (is_decrypt_) { - cipher_->decrypt(sourceData, targetData, total_len); + cipher->crypt(cipher, sourceData, targetData, total_len); } else { - memcpy(targetData, sourceData, total_len); - } - + memcpy(targetData, sourceData, total_len); + } + buffer_->putRawData((char*)targetData, total_len); // Check the crc32. |