added display of SSL encryption parameters in PeerDetails dialog

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6465 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-06-28 21:47:25 +00:00
parent 1ebde8788f
commit 9f88917ac1
12 changed files with 102 additions and 7 deletions

View File

@ -346,6 +346,12 @@ void pqipersongrp::statusChanged()
///////////////////////////////////////////////////////////
#endif
bool pqipersongrp::getCryptoParams(const std::string& id,RsPeerCryptoParams& params)
{
RsStackMutex stack(coreMtx); /******* LOCKED MUTEX **********/
return locked_getCryptoParams(id,params) ;
}
int pqipersongrp::addPeer(std::string id)
{

View File

@ -45,6 +45,7 @@
const unsigned long PQIPERSON_NO_LISTENER = 0x0001;
const unsigned long PQIPERSON_ALL_BW_LIMITED = 0x0010;
class RsPeerCryptoParams ;
class pqipersongrp: public pqihandler, public pqiMonitor, public p3ServiceServer, public pqiNetListener
{
@ -90,8 +91,11 @@ bool notifyConnect(std::string id, uint32_t type, bool success, struct sockad
virtual int tick();
virtual int status();
virtual bool getCryptoParams(const std::string&,RsPeerCryptoParams&) ;
protected:
virtual bool locked_getCryptoParams(const std::string&, RsPeerCryptoParams&) { return false ;}
/********* FUNCTIONS to OVERLOAD for specialisation ********/
// THESE NEED TO BE LOCKED UNTIL PQILISTENER IS THREAD-SAFE.
virtual pqilistener *locked_createListener(struct sockaddr_in laddr) = 0;

View File

@ -38,6 +38,7 @@
#include "pqi/pqissllistener.h"
#include "pqi/p3linkmgr.h"
#include <retroshare/rspeers.h>
const int pqisslzone = 37714;
@ -309,6 +310,31 @@ bool pqissl::connect_parameter(uint32_t type, uint32_t value)
*
*/
void pqissl::getCryptoParams(RsPeerCryptoParams& params)
{
if(active)
{
params.connexion_state = 1 ;
params.cipher_name = std::string( SSL_get_cipher(ssl_connection));
int alg ;
int al2 = SSL_get_cipher_bits(ssl_connection,&alg);
params.cipher_bits_1 = alg ;
params.cipher_bits_2 = al2 ;
params.cipher_version = SSL_get_cipher_version(ssl_connection) ;
}
else
{
params.connexion_state = 0 ;
params.cipher_name.clear() ;
params.cipher_bits_1 = 0 ;
params.cipher_bits_2 = 0 ;
params.cipher_version.clear() ;
}
}
/* returns ...
* -1 if inactive.
* 0 if connecting.

View File

@ -83,6 +83,7 @@ class cert;
class pqissllistener;
class p3LinkMgr;
class RsPeerCryptoParams ;
class pqissl: public NetBinInterface
{
@ -152,6 +153,8 @@ public:
int accept(SSL *ssl, int fd, struct sockaddr_in foreign_addr);
void getCryptoParams(RsPeerCryptoParams& params) ;
protected:
//protected internal fns that are overloaded for udp case.

View File

@ -55,6 +55,17 @@ pqilistener * pqisslpersongrp::locked_createListener(struct sockaddr_in laddr)
return listener;
}
bool pqisslpersongrp::locked_getCryptoParams(const std::string& id,RsPeerCryptoParams& params)
{
std::map<std::string, pqissl*>::const_iterator it = ssl_tunnels.find(id) ;
if(it == ssl_tunnels.end())
return false ;
it->second->getCryptoParams(params) ;
return true ;
}
pqiperson * pqisslpersongrp::locked_createPerson(std::string id, pqilistener *listener)
{
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, "pqipersongrp::createPerson() PeerId: " + id);
@ -69,6 +80,8 @@ pqiperson * pqisslpersongrp::locked_createPerson(std::string id, pqilistener *li
* * ServiceGeneric
*/
ssl_tunnels[id] = pqis ; // keeps for getting crypt info per peer.
RsSerialiser *rss = new RsSerialiser();
rss->addSerialType(new RsFileItemSerialiser());
rss->addSerialType(new RsCacheItemSerialiser());

View File

@ -31,6 +31,8 @@
#include "pqi/pqipersongrp.h"
class p3PeerMgr;
class RsPeerCryptoParams;
class pqissl ;
class pqisslpersongrp: public pqipersongrp
{
@ -38,6 +40,8 @@ class pqisslpersongrp: public pqipersongrp
pqisslpersongrp(SecurityPolicy *pol, unsigned long flags, p3PeerMgr *pm)
:pqipersongrp(pol, flags), mPeerMgr(pm) { return; }
bool locked_getCryptoParams(const std::string&, RsPeerCryptoParams&) ;
protected:
/********* FUNCTIONS to OVERLOAD for specialisation ********/
@ -48,6 +52,7 @@ virtual pqiperson *locked_createPerson(std::string id, pqilistener *listener);
private:
p3PeerMgr *mPeerMgr;
std::map<std::string,pqissl*> ssl_tunnels ;
};

View File

@ -35,6 +35,7 @@ class NotifyBase;
class RsIface;
class RsControl;
class RsInit;
class RsPeerCryptoParams;
struct TurtleFileInfo ;
/* declare single RsIface for everyone to use! */
@ -163,8 +164,10 @@ class RsControl /* The Main Interface Class - for controlling the server */
/****************************************/
NotifyBase &getNotify() { return cb; }
RsIface &getIface() { return rsIface; }
NotifyBase & getNotify() { return cb; }
RsIface & getIface() { return rsIface; }
virtual bool getPeerCryptoDetails(const std::string& ssl_id,RsPeerCryptoParams& params) = 0;
private:
NotifyBase &cb;

View File

@ -228,6 +228,19 @@ class RsPeerDetails
uint32_t linkType;
};
// This class is used to get info about crytographic algorithms used with a
// particular peer.
//
class RsPeerCryptoParams
{
public:
int connexion_state ;
std::string cipher_name ;
int cipher_bits_1 ;
int cipher_bits_2 ;
std::string cipher_version ;
};
class RsGroupInfo
{
public:

View File

@ -158,6 +158,8 @@ class RsServer: public RsControl, public RsThread
/****************************************/
public:
virtual bool getPeerCryptoDetails(const std::string& ssl_id,RsPeerCryptoParams& params) { return pqih->getCryptoParams(ssl_id,params); }
private:

View File

@ -85,13 +85,11 @@ public:
virtual void lockData()
{
// std::cerr << "RsIfaceReal::lockData()" << std::endl;
return rsIfaceMutex.lock();
}
virtual void unlockData()
{
// std::cerr << "RsIfaceReal::unlockData()" << std::endl;
return rsIfaceMutex.unlock();
}

View File

@ -199,9 +199,19 @@ void ConfCertDialog::load()
std::map<std::string, std::string> versions;
bool retv = rsDisc->getDiscVersions(versions);
if (retv && versions.end() != (vit = versions.find(detail.id)))
{
ui.version->setText(QString::fromStdString(vit->second));
}
RsPeerCryptoParams cdet ;
if(rsicontrol->getPeerCryptoDetails(detail.id,cdet) && cdet.connexion_state!=0)
{
QString ct ;
ct += QString::fromStdString(cdet.cipher_name) ;
ct += QString::number(cdet.cipher_bits_1) ;
ct += "-"+QString::fromStdString(cdet.cipher_version) ;
ui.crypto_info->setText(ct) ;
}
else
ui.crypto_info->setText(tr("Not connected")) ;
/* set local address */
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
@ -245,6 +255,8 @@ void ConfCertDialog::load()
ui.version->hide();
ui.label_version->hide();
ui.groupBox_4->hide();
ui.crypto_info->hide();
ui.crypto_label->hide();
ui.groupBox->hide();
}

View File

@ -60,7 +60,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="stabWidget">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
@ -140,6 +140,16 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="crypto_label">
<property name="text">
<string>Encryption</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="crypto_info"/>
</item>
</layout>
</widget>
</item>