|
From: <hep...@us...> - 2016-11-13 22:32:18
|
Revision: 1353
http://sourceforge.net/p/qterm/code/1353
Author: hephooey
Date: 2016-11-13 22:32:15 +0000 (Sun, 13 Nov 2016)
Log Message:
-----------
Add RSA hostkey verfication
Modified Paths:
--------------
trunk/qterm/src/ssh/kex.cpp
Modified: trunk/qterm/src/ssh/kex.cpp
===================================================================
--- trunk/qterm/src/ssh/kex.cpp 2016-11-13 22:32:13 UTC (rev 1352)
+++ trunk/qterm/src/ssh/kex.cpp 2016-11-13 22:32:15 UTC (rev 1353)
@@ -335,7 +335,17 @@
qDebug() << "key type: " << type;
#endif
DSA *dsa = DSA_new();
+ RSA *rsa = RSA_new();
+ if (type == "ssh-rsa") {
+ rsa->e = BN_new();
+ rsa->n = BN_new();
+ tmp.getBN(rsa->e);
+ tmp.getBN(rsa->n);
+ tmp.atEnd();
+ qDebug() << "key size: " << RSA_size(rsa);
+ }
+
if (type == "ssh-dss") {
#ifdef SSH_DEBUG
qDebug() << "generate DSA key";
@@ -358,6 +368,14 @@
#ifdef SSH_DEBUG
//dumpData ( signBlob );
#endif
+ if (type == "ssh-rsa") {
+ if (signBlob.size() != RSA_size(rsa)) {
+ qDebug() << "TODO: key size mismatch";
+ }
+ QByteArray digest = QCryptographicHash::hash(hash, QCryptographicHash::Sha1);
+ ret = RSA_verify(NID_sha1, (const unsigned char *) digest.data(), digest.size(), (const unsigned char *)signBlob.data(), signBlob.size(), rsa);
+ qDebug() << "Verify RSA: " << ret;
+ }
if (type == "ssh-dss") {
#ifdef SSH_DEBUG
@@ -381,6 +399,7 @@
}
DSA_free(dsa);
+ RSA_free(rsa);
if (ret == 1)
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|