Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.6 short invites #1571

Merged
merged 48 commits into from Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
720d5ea
Implement libretroshare short invites support
G10h4ck May 12, 2019
bde6235
Fix windows compilation
G10h4ck May 13, 2019
dac7643
Merge pull request #1565 from G10h4ck/short_invites_v2
csoler May 21, 2019
56e591f
added a flag in peerState specific to short invites, and several chec…
csoler May 22, 2019
4eb6b0b
fixed uninitialized memory read for variable mRsEventsHandle
csoler May 26, 2019
8fddb55
fixed stupid bug that crashed the code in a different place
csoler May 27, 2019
3a799ba
added optional display of short invites in places with certificates
csoler Jun 6, 2019
4bd5aaa
added parsing of short invites in connect friend wizard (not working …
csoler Jun 9, 2019
fb52f67
fixed up addign friend from short invite
csoler Jun 9, 2019
76cf64f
fixed compilation
csoler Jun 9, 2019
a7141cb
removed unused startWizard and loadCert code in HomePage
csoler Jun 9, 2019
6294aef
removed unused intro page from ConnectFriendWizard
csoler Jun 9, 2019
0c510a5
removed unused RsId and Fof pages from ConnectFriendWizard
csoler Jun 9, 2019
c0436b7
removed unused Email page from ConnectFriendWizard
csoler Jun 9, 2019
a55e824
removed unused FriendRequest page from ConnectFriendWizard
csoler Jun 9, 2019
a04079d
removed unused Cert page from ConnectFriendWizard
csoler Jun 9, 2019
1f56ef3
removed unused Cert page from ConnectFriendWizard
csoler Jun 9, 2019
38434f2
removed unused Cert page from ConnectFriendWizard
csoler Jun 9, 2019
57a5485
fixed adding friend with short invite
csoler Jun 10, 2019
805f753
fixed parsing of short invite
csoler Jun 20, 2019
6114d97
removed CIRCLES-related dead code from friendlist
csoler Jun 20, 2019
e132ce7
attempt to add SSL-only friends in FriendList - does not work yet
csoler Jun 20, 2019
9312d0c
converted short invites to compact PGP format for increased robustness
csoler Jun 21, 2019
a52451b
moved SSL part of friend list into a separate function
csoler Jun 22, 2019
daec6b3
arranged to show PGP id for friends from short invite. Name not avail…
csoler Jun 22, 2019
6419b03
merged upstream/master
csoler Sep 8, 2019
dd90314
fixed missing type conversion
csoler Sep 8, 2019
c8064e1
fixed missing parameter in jsonapi declaration
csoler Sep 8, 2019
3a58aa4
add special profile item for not yet validated peer from short invite
csoler Sep 10, 2019
bbf92bd
fixed remanent bug due causing the deletion of rsEvent
csoler Sep 10, 2019
b0c7f8f
fixed display of non validated nodes without fingerprint
csoler Sep 10, 2019
a20ec1a
fixed exchange of PGP keys in binary format and update of PGP signatu…
csoler Sep 14, 2019
bea6769
removed unused code from p3gossipdiscovery
csoler Sep 14, 2019
b4fe1d4
started documenting p3GossipDiscovery
csoler Sep 16, 2019
32b4312
improved security checks in authssl by verifying that the supplied PG…
csoler Sep 17, 2019
44d6cb7
finished documentation/review of discovery
csoler Sep 17, 2019
654d760
fixed comments from review of PR
csoler Sep 19, 2019
4fabf3d
renamed skip_signature_validation into more appropriate skip_pgp_sign…
csoler Sep 19, 2019
ed864f9
removed some debug info about PGP signature validation, and added the…
csoler Sep 21, 2019
6919711
restricted check for matching PGP ids to short invites only, since ot…
csoler Sep 21, 2019
9c7edff
fixed bug caused by shadowing a variable
csoler Sep 22, 2019
19ced52
fixed bug caused by wrong reading of disc flag
csoler Sep 22, 2019
9b78447
used RsInfo instead of std::cerr in authssl.cc
csoler Sep 22, 2019
cdeee01
removed dependency of FriendDialog on RsAutoUpdatePage which is not n…
csoler Sep 22, 2019
282d2d3
added missing notifications when adding friends
csoler Sep 22, 2019
a04d56e
fixed wrong default value for showUnconnected nodes
csoler Sep 23, 2019
d055887
removed some dead code
csoler Sep 23, 2019
24781a7
removed unused mOthersList from PeerMgr
csoler Sep 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc
Expand Up @@ -27,6 +27,7 @@
#include "retroshare/rsiface.h"
#include "rsserver/p3face.h"
#include "util/rsdebug.h"
#include "retroshare/rspeers.h"

/****
* #define P3DISC_DEBUG 1
Expand Down Expand Up @@ -99,7 +100,7 @@ void DiscPgpInfo::mergeFriendList(const std::set<PGPID> &friends)
p3discovery2::p3discovery2(
p3PeerMgr* peerMgr, p3LinkMgr* linkMgr, p3NetMgr* netMgr,
p3ServiceControl* sc, RsGixs* gixs ) :
p3Service(), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr),
p3Service(), mRsEventsHandle(0), mPeerMgr(peerMgr), mLinkMgr(linkMgr), mNetMgr(netMgr),
mServiceCtrl(sc), mGixs(gixs), mDiscMtx("p3discovery2"), mLastPgpUpdate(0)
{
Dbg3() << __PRETTY_FUNCTION__ << std::endl;
Expand Down Expand Up @@ -1249,9 +1250,25 @@ void p3discovery2::recvInvite(

void p3discovery2::rsEventsHandler(const RsEvent& event)
{
Dbg3() << __PRETTY_FUNCTION__ << " " << static_cast<uint32_t>(event.mType)
<< std::endl;

switch(event.mType)
{
// TODO: When an SSL-only friend become online requestInvite(...)
case RsEventType::PEER_STATE_CHANGED:
{
const RsPeerId& sslId =
static_cast<const RsPeerStateChangedEvent&>(event).mSslId;
if( rsPeers && rsPeers->isSslOnlyFriend(sslId) &&
mServiceCtrl->isPeerConnected(
getServiceInfo().mServiceType, sslId ) )
{
if(!requestInvite(sslId, sslId))
RsErr() << __PRETTY_FUNCTION__ << " requestInvite to peer "
<< sslId << " failed" << std::endl;
}
break;
}
default: break;
}
}
Expand Down
5 changes: 5 additions & 0 deletions libretroshare/src/pgp/pgphandler.cc
Expand Up @@ -1571,6 +1571,11 @@ void PGPHandler::locked_updateOwnSignatureFlag(PGPCertificateInfo& cert,const Rs
cert._flags &= ~PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_SIGNED_ME ;
}

RsPgpId PGPHandler::pgpIdFromFingerprint(const PGPFingerprintType& f)
{
return RsPgpId(f.toByteArray() + _RsIdSize::PGP_FINGERPRINT - _RsIdSize::PGP_ID);
}

bool PGPHandler::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const
{
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
Expand Down
1 change: 1 addition & 0 deletions libretroshare/src/pgp/pgphandler.h
Expand Up @@ -153,6 +153,7 @@ class PGPHandler

static void setPassphraseCallback(PassphraseCallback cb) ;
static PassphraseCallback passphraseCallback() { return _passphrase_callback ; }
static RsPgpId pgpIdFromFingerprint(const PGPFingerprintType& f) ;

// Gets info about the key. Who are the signers, what's the owner's name, etc.
//
Expand Down
18 changes: 13 additions & 5 deletions libretroshare/src/pgp/rscertificate.cc
Expand Up @@ -552,14 +552,22 @@ unsigned short RsCertificate::loc_port_us() const
return (int)ipv4_internal_ip_and_port[4]*256 + (int)ipv4_internal_ip_and_port[5] ;
}

bool RsCertificate::cleanCertificate(
const std::string& input, std::string& output, Format& format,
int& error_code, bool check_content )
bool RsCertificate::cleanCertificate( const std::string& input, std::string& output, Format& format, int& error_code, bool check_content )
{
if(cleanCertificate(input,output,error_code))
if(cleanRadix64(input,output,error_code))
{
RsPeerDetails details;

if(rsPeers->parseShortInvite(output,details))
{
format = RS_CERTIFICATE_SHORT_RADIX;
return true;
}

format = RS_CERTIFICATE_RADIX;

if(!check_content) return true;

uint32_t errCode;
auto crt = RsCertificate::fromString(input, errCode);
error_code = static_cast<int>(errCode);
Expand All @@ -576,7 +584,7 @@ std::string RsCertificate::armouredPGPKey() const

// Yeah, this is simple, and that is what's good about the radix format. Can't be broken ;-)
//
bool RsCertificate::cleanCertificate(const std::string& instr,std::string& str,int& error_code)
bool RsCertificate::cleanRadix64(const std::string& instr,std::string& str,int& error_code)
{
error_code = RS_PEER_CERT_CLEANING_CODE_NO_ERROR ;

Expand Down
5 changes: 2 additions & 3 deletions libretroshare/src/pgp/rscertificate.h
Expand Up @@ -36,7 +36,7 @@ struct RsPeerDetails;
class RsCertificate
{
public:
typedef enum { RS_CERTIFICATE_OLD_FORMAT, RS_CERTIFICATE_RADIX } Format;
typedef enum { RS_CERTIFICATE_OLD_FORMAT, RS_CERTIFICATE_RADIX, RS_CERTIFICATE_SHORT_RADIX } Format;

/**
* @brief Create certificate object from certificate string
Expand Down Expand Up @@ -99,8 +99,7 @@ class RsCertificate

private:
// new radix format
static bool cleanCertificate( const std::string& input,
std::string& output, int&);
static bool cleanRadix64( const std::string& input, std::string& output, int&);

static void scan_ip( const std::string& ip_string, unsigned short port,
unsigned char *destination_memory );
Expand Down
11 changes: 8 additions & 3 deletions libretroshare/src/pqi/authssl.cc
Expand Up @@ -1196,6 +1196,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
std::string sslCn = RsX509Cert::getCertIssuerString(*x509Cert);
RsPgpId pgpId(sslCn);


if(sslId.isNull())
{
std::string errMsg = "x509Cert has invalid sslId!";
Expand Down Expand Up @@ -1231,8 +1232,10 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
return verificationFailed;
}

bool isSslOnlyFriend = rsPeers->isSslOnlyFriend(sslId);

uint32_t auth_diagnostic;
if(!AuthX509WithGPG(x509Cert, auth_diagnostic))
if(!isSslOnlyFriend && !AuthX509WithGPG(x509Cert, auth_diagnostic))
{
std::string errMsg = "Certificate was rejected because PGP "
"signature verification failed with diagnostic: "
Expand All @@ -1255,7 +1258,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
return verificationFailed;
}

if ( pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() &&
if ( !isSslOnlyFriend && pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() &&
!AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
{
std::string errMsg = "Connection attempt signed by PGP key id: " +
Expand All @@ -1279,7 +1282,9 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
setCurrentConnectionAttemptInfo(pgpId, sslId, sslCn);
LocalStoreCert(x509Cert);

Dbg1() << __PRETTY_FUNCTION__ << " authentication successfull!" << std::endl;
RsInfo() << __PRETTY_FUNCTION__ << " authentication successfull for "
<< "sslId: " << sslId << " isSslOnlyFriend: " << isSslOnlyFriend
<< std::endl;

if(rsEvents)
{
Expand Down