Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@
"message": "Initialization of SSH2 session failed",
"description": "libssh2_session_init() failed"
},
"sftpThreadError_sshKEXMethodPrefsFailed" : {
"message": "Couldn't set key exchange method preferences",
"description": "libssh_session_method_prefs() failed"
},
"sftpThreadError_sshSessionHandshakeFailed" : {
"message": "Finishing SSH2 session failed",
"description": "Error when starting up SSH session"
Expand Down
3 changes: 3 additions & 0 deletions src/_locales/nl/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
"sftpThreadError_sshInitSessionFailed" : {
"message": "Initialiseren van een SSH2-sessie is mislukt"
},
"sftpThreadError_sshKEXMethodPrefsFailed" : {
"message": "Kan de voorkeuren voor de sleuteluitwisseling methode niet instellen"
},
"sftpThreaderror_sshSessionHandshakeFailed" : {
"message": "Voltooien van een SSH2-sessie is mislukt"
},
Expand Down
15 changes: 15 additions & 0 deletions src/nacl_src/sftp_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ void SftpThread::ConnectAndHandshakeImpl()
InitializeLibssh2();
sock = ConnectToSshServer(server_hostname_, server_port_);
session = InitializeSession();
SetKEXMethodPrefs(session);
HandshakeSession(session, sock);
std::string fingerprint;
fingerprint = GetHostKeyHash(session);
Expand Down Expand Up @@ -374,6 +375,20 @@ LIBSSH2_SESSION* SftpThread::InitializeSession() throw(CommunicationException)
return session;
}

void SftpThread::SetKEXMethodPrefs(LIBSSH2_SESSION *session)
throw(CommunicationException)
{
fprintf(stderr, "SftpThread::SetKEXMethodPrefs\n");
const char *methods;
methods = "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256";
int rc;
while ((rc = libssh2_session_method_pref(session, LIBSSH2_METHOD_HOSTKEY, methods)) == LIBSSH2_ERROR_EAGAIN);
fprintf(stderr, "SftpThread::SetKEXMethodPrefs rc=%d\n", rc);
if (rc) {
THROW_COMMUNICATION_EXCEPTION("sftpThreadError_sshKEXMethodPrefsFailed", rc);
}
}

void SftpThread::HandshakeSession(LIBSSH2_SESSION *session, int sock)
throw(CommunicationException)
{
Expand Down
1 change: 1 addition & 0 deletions src/nacl_src/sftp_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class SftpThread
void InitializeLibssh2() throw(CommunicationException);
int ConnectToSshServer(const std::string &hostname, const int port) throw(CommunicationException);
LIBSSH2_SESSION* InitializeSession() throw(CommunicationException);
void SetKEXMethodPrefs(LIBSSH2_SESSION *session) throw(CommunicationException);
void HandshakeSession(LIBSSH2_SESSION *session,
int sock) throw(CommunicationException);
std::string GetHostKeyHash(LIBSSH2_SESSION *session);
Expand Down