summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-04-27 14:41:57 +0800
committerIru Cai <mytbk920423@gmail.com>2018-04-29 16:51:12 +0800
commitb288c451e26295e173bc32f8a0017bd56fec93d3 (patch)
tree6768da3c65349dcee3700fb355bc67aff76c1996
parenta6519b094415341e055852812856ecd90f29940d (diff)
downloadfqterm-b288c451e26295e173bc32f8a0017bd56fec93d3.tar.xz
kill fqterm_ssh_md5
-rw-r--r--src/protocol/CMakeLists.txt3
-rw-r--r--src/protocol/internal/fqterm_ssh2_kex.cpp1
-rw-r--r--src/protocol/internal/fqterm_ssh_hash.h47
-rw-r--r--src/protocol/internal/fqterm_ssh_kex.cpp14
-rw-r--r--src/protocol/internal/fqterm_ssh_md5.cpp36
-rw-r--r--src/protocol/internal/fqterm_ssh_md5.h50
6 files changed, 7 insertions, 144 deletions
diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt
index 03a84e4..b808fb9 100644
--- a/src/protocol/CMakeLists.txt
+++ b/src/protocol/CMakeLists.txt
@@ -28,11 +28,9 @@ set(internal_SRCS
internal/fqterm_ssh_auth.h
internal/fqterm_ssh_buffer.h
internal/fqterm_ssh_const.h
- internal/fqterm_ssh_hash.h
internal/fqterm_ssh_kex.h
internal/fqterm_ssh2_kex.h
internal/fqterm_ssh_mac.h
- internal/fqterm_ssh_md5.h
internal/fqterm_ssh_packet.h
internal/fqterm_ssh1_packet.h
internal/fqterm_ssh2_packet.h
@@ -44,7 +42,6 @@ set(internal_SRCS
internal/fqterm_ssh_kex.cpp
internal/fqterm_ssh2_kex.cpp
internal/fqterm_ssh_mac.cpp
- internal/fqterm_ssh_md5.cpp
internal/fqterm_ssh_packet.cpp
internal/fqterm_ssh1_packet.cpp
internal/fqterm_ssh2_packet.cpp
diff --git a/src/protocol/internal/fqterm_ssh2_kex.cpp b/src/protocol/internal/fqterm_ssh2_kex.cpp
index fe35452..906acca 100644
--- a/src/protocol/internal/fqterm_ssh2_kex.cpp
+++ b/src/protocol/internal/fqterm_ssh2_kex.cpp
@@ -27,7 +27,6 @@
#include <openssl/evp.h>
#include "fqterm_ssh2_kex.h"
-#include "fqterm_ssh_md5.h"
#include "fqterm_trace.h"
#include "ssh_pubkey_crypto.h"
#include "ssh_cipher.h"
diff --git a/src/protocol/internal/fqterm_ssh_hash.h b/src/protocol/internal/fqterm_ssh_hash.h
deleted file mode 100644
index b4679f4..0000000
--- a/src/protocol/internal/fqterm_ssh_hash.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
- * fqterm, a terminal emulator for both BBS and *nix. *
- * Copyright (C) 2008 fqterm development group. *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
- ***************************************************************************/
-
-#ifndef FQTERM_SSH_HASH_H
-#define FQTERM_SSH_HASH_H
-
-#include "fqterm_ssh_types.h"
-
-namespace FQTerm {
-
-class FQTermSSHHash {
-protected:
- int d_digestLength;
- int digestLength()const {
- return d_digestLength;
- }
-
-public:
- FQTermSSHHash() {
- d_digestLength = 0;
- }
- virtual ~FQTermSSHHash() {}
-
- virtual void update(u_char *data, int len) = 0;
- virtual void final(u_char *data) = 0;
-};
-
-} // namespace FQTerm
-
-#endif //FQTERM_SSH_HASH_H
diff --git a/src/protocol/internal/fqterm_ssh_kex.cpp b/src/protocol/internal/fqterm_ssh_kex.cpp
index eb3b012..e2975d1 100644
--- a/src/protocol/internal/fqterm_ssh_kex.cpp
+++ b/src/protocol/internal/fqterm_ssh_kex.cpp
@@ -19,8 +19,8 @@
***************************************************************************/
#include "fqterm_ssh_kex.h"
-#include "fqterm_ssh_md5.h"
#include "fqterm_trace.h"
+#include <openssl/md5.h>
namespace FQTerm {
@@ -191,13 +191,13 @@ void FQTermSSH1Kex::makeSessionKey() {
void FQTermSSH1Kex::makeSessionId() {
u_char *p;
- FQTermSSHMD5 *md5;
+ MD5_CTX ctx;
int servlen, hostlen;
const BIGNUM *host_n;
const BIGNUM *server_n;
const BIGNUM *e, *d;
- md5 = new FQTermSSHMD5;
+ MD5_Init(&ctx);
ssh_pubkey_getrsa(server_key_, &server_n, &e, &d);
ssh_pubkey_getrsa(host_key_, &host_n, &e, &d);
servlen = BN_num_bytes(server_n);
@@ -208,10 +208,10 @@ void FQTermSSH1Kex::makeSessionId() {
BN_bn2bin(host_n, p);
BN_bn2bin(server_n, p+hostlen);
- md5->update(p, servlen + hostlen);
- md5->update(cookie_, 8);
- md5->final(session_id_);
- delete md5;
+ MD5_Update(&ctx, p, servlen+hostlen);
+ MD5_Update(&ctx, cookie_, 8);
+ MD5_Final(session_id_, &ctx);
+
delete [] p;
}
diff --git a/src/protocol/internal/fqterm_ssh_md5.cpp b/src/protocol/internal/fqterm_ssh_md5.cpp
deleted file mode 100644
index 10713e9..0000000
--- a/src/protocol/internal/fqterm_ssh_md5.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/***************************************************************************
- * fqterm, a terminal emulator for both BBS and *nix. *
- * Copyright (C) 2008 fqterm development group. *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
- ***************************************************************************/
-
-#include "fqterm_ssh_md5.h"
-
-namespace FQTerm {
-
-//==============================================================================
-//FQTermSSHMD5
-//==============================================================================
-void FQTermSSHMD5::final(u_char *digest) {
- MD5_Final(digest, &d_md5);
-}
-
-void FQTermSSHMD5::update(u_char *data, int len) {
- MD5_Update(&d_md5, data, len);
-}
-
-} // namespace FQTerm
diff --git a/src/protocol/internal/fqterm_ssh_md5.h b/src/protocol/internal/fqterm_ssh_md5.h
deleted file mode 100644
index abb8127..0000000
--- a/src/protocol/internal/fqterm_ssh_md5.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/***************************************************************************
- * fqterm, a terminal emulator for both BBS and *nix. *
- * Copyright (C) 2008 fqterm development group. *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
- ***************************************************************************/
-
-#ifndef FQTERM_SSH_MD5_H
-#define FQTERM_SSH_MD5_H
-
-#include <stdio.h>
-
-#include <openssl/md5.h>
-
-#include "fqterm_ssh_types.h"
-#include "fqterm_ssh_hash.h"
-
-namespace FQTerm {
-
-class FQTermSSHMD5: public FQTermSSHHash {
-protected:
- MD5_CTX d_md5;
-public:
- FQTermSSHMD5()
- : FQTermSSHHash() {
- d_digestLength = 16;
- MD5_Init(&d_md5);
- }
- virtual ~FQTermSSHMD5() {}
-
- void update(u_char *data, int len);
- void final(u_char *digest);
-};
-
-} // namespace FQTerm
-
-#endif //FQTERM_SSH_MD5_H