mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-11 00:44:27 -05:00
removed getAuthGPG and replaced AuthGPG with a class with static members
This commit is contained in:
parent
b8f4e64393
commit
b084b20280
@ -107,7 +107,7 @@ p3discovery2::p3discovery2(
|
||||
addSerialType(new RsDiscSerialiser());
|
||||
|
||||
// Add self into PGP FriendList.
|
||||
mFriendList[AuthGPG::getAuthGPG()->getGPGOwnId()] = DiscPgpInfo();
|
||||
mFriendList[AuthGPG::getGPGOwnId()] = DiscPgpInfo();
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +219,7 @@ void p3discovery2::removeFriend(const RsPeerId &sslId)
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* pgp peer without any ssl entries -> check if they are still a real friend */
|
||||
if (!(AuthGPG::getAuthGPG()->isGPGAccepted(pgpId)))
|
||||
if (!(AuthGPG::isGPGAccepted(pgpId)))
|
||||
{
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "p3discovery2::addFriend() pgpId is no longer a friend, removing";
|
||||
@ -604,8 +604,8 @@ void p3discovery2::updatePgpFriendList()
|
||||
std::list<RsPgpId>::iterator lit;
|
||||
std::map<RsPgpId, DiscPgpInfo>::iterator it;
|
||||
|
||||
RsPgpId ownPgpId = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
AuthGPG::getAuthGPG()->getGPGAcceptedList(pgpList);
|
||||
RsPgpId ownPgpId = AuthGPG::getGPGOwnId();
|
||||
AuthGPG::getGPGAcceptedList(pgpList);
|
||||
pgpList.push_back(ownPgpId);
|
||||
|
||||
// convert to set for ordering.
|
||||
@ -723,7 +723,7 @@ void p3discovery2::processPGPList(const RsPeerId &fromId, const RsDiscPgpListIte
|
||||
std::set<RsPgpId>::const_iterator fit;
|
||||
for(fit = item->pgpIdSet.ids.begin(); fit != item->pgpIdSet.ids.end(); ++fit)
|
||||
{
|
||||
if (!AuthGPG::getAuthGPG()->isGPGId(*fit))
|
||||
if (!AuthGPG::isPGPId(*fit))
|
||||
{
|
||||
#ifdef P3DISC_DEBUG
|
||||
std::cerr << "p3discovery2::processPGPList() requesting certificate for PgpId: " << *fit;
|
||||
@ -1058,11 +1058,11 @@ void p3discovery2::recvPGPCertificateRequest( const RsPeerId& fromId, const RsDi
|
||||
return;
|
||||
}
|
||||
|
||||
RsPgpId ownPgpId = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
RsPgpId ownPgpId = AuthGPG::getGPGOwnId();
|
||||
for(const RsPgpId& pgpId : item->pgpIdSet.ids)
|
||||
if (pgpId == ownPgpId)
|
||||
sendPGPCertificate(pgpId, fromId);
|
||||
else if(ps.vs_disc != RS_VS_DISC_OFF && AuthGPG::getAuthGPG()->isGPGAccepted(pgpId))
|
||||
else if(ps.vs_disc != RS_VS_DISC_OFF && AuthGPG::isGPGAccepted(pgpId))
|
||||
sendPGPCertificate(pgpId, fromId);
|
||||
else
|
||||
std::cerr << "(WW) not sending certificate " << pgpId << " asked by friend " << fromId << " because this either this cert is not a friend, or discovery is off" << std::endl;
|
||||
@ -1078,7 +1078,7 @@ void p3discovery2::sendPGPCertificate(const RsPgpId &aboutId, const RsPeerId &to
|
||||
unsigned char *bin_data;
|
||||
size_t bin_len;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(aboutId,bin_data,bin_len,false,true))
|
||||
if(!AuthGPG::exportPublicKey(aboutId,bin_data,bin_len,false,true))
|
||||
{
|
||||
std::cerr << "(EE) cannot export public key " << aboutId << " requested by peer " << toId << std::endl;
|
||||
return ;
|
||||
@ -1098,7 +1098,7 @@ void p3discovery2::recvPGPCertificate(const RsPeerId& fromId, RsDiscPgpKeyItem*
|
||||
std::string cert_name;
|
||||
std::list<RsPgpId> cert_signers;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->getGPGDetailsFromBinaryBlock( (unsigned char*)item->bin_data,item->bin_len, cert_pgp_id, cert_name, cert_signers ))
|
||||
if(!AuthGPG::getGPGDetailsFromBinaryBlock( (unsigned char*)item->bin_data,item->bin_len, cert_pgp_id, cert_name, cert_signers ))
|
||||
{
|
||||
std::cerr << "(EE) cannot parse own PGP key sent by " << fromId << std::endl;
|
||||
return;
|
||||
@ -1147,7 +1147,7 @@ void p3discovery2::recvPGPCertificate(const RsPeerId& fromId, RsDiscPgpKeyItem*
|
||||
// otherwise the connection should already be accepted. This only happens when the short invite peer sends its own PGP key.
|
||||
|
||||
if(det.skip_pgp_signature_validation)
|
||||
AuthGPG::getAuthGPG()->AllowConnection(det.gpg_id,true);
|
||||
AuthGPG::AllowConnection(det.gpg_id,true);
|
||||
}
|
||||
|
||||
/************* from pqiServiceMonitor *******************/
|
||||
|
@ -34,7 +34,7 @@ PgpAuxUtilsImpl::PgpAuxUtilsImpl()
|
||||
|
||||
const RsPgpId& PgpAuxUtilsImpl::getPGPOwnId()
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
return AuthGPG::getGPGOwnId();
|
||||
}
|
||||
|
||||
RsPgpId PgpAuxUtilsImpl::getPGPId(const RsPeerId& sslid)
|
||||
@ -44,7 +44,7 @@ RsPgpId PgpAuxUtilsImpl::getPGPId(const RsPeerId& sslid)
|
||||
|
||||
bool PgpAuxUtilsImpl::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->getKeyFingerprint(id, fp);
|
||||
return AuthGPG::getKeyFingerprint(id, fp);
|
||||
}
|
||||
|
||||
bool PgpAuxUtilsImpl::VerifySignBin(const void *data,
|
||||
@ -54,17 +54,17 @@ bool PgpAuxUtilsImpl::VerifySignBin(const void *data,
|
||||
const PGPFingerprintType& withfingerprint)
|
||||
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->VerifySignBin(data, len, sign, signlen, withfingerprint);
|
||||
return AuthGPG::VerifySignBin(data, len, sign, signlen, withfingerprint);
|
||||
}
|
||||
|
||||
bool PgpAuxUtilsImpl::getGPGAllList(std::list<RsPgpId> &ids)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->getGPGAllList(ids);
|
||||
return AuthGPG::getGPGAllList(ids);
|
||||
}
|
||||
|
||||
bool PgpAuxUtilsImpl::parseSignature(unsigned char *sign, unsigned int signlen, RsPgpId& issuer) const
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->parseSignature(sign,signlen,issuer);
|
||||
return AuthGPG::parseSignature(sign,signlen,issuer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,9 +54,21 @@ void cleanupZombies(int numkill); // function to cleanup zombies under OSX.
|
||||
|
||||
/* Function to sign X509_REQ via GPGme. */
|
||||
|
||||
int AuthGPG::availableGPGCertificatesWithPrivateKeys(std::list<RsPgpId>& pgpIds)
|
||||
{
|
||||
return instance()->mPgpHandler->availableGPGCertificatesWithPrivateKeys(pgpIds);
|
||||
}
|
||||
bool AuthGPG::getGPGDetailsFromBinaryBlock(const unsigned char *mem,size_t mem_size,RsPgpId& key_id, std::string& name, std::list<RsPgpId>& signers)
|
||||
{
|
||||
return instance()->mPgpHandler->getGPGDetailsFromBinaryBlock(mem,mem_size,key_id,name,signers);
|
||||
}
|
||||
void AuthGPG::registerToConfigMgr(const std::string& fname,p3ConfigMgr *CfgMgr)
|
||||
{
|
||||
CfgMgr->addConfiguration(fname, instance());
|
||||
}
|
||||
bool AuthGPG::decryptTextFromFile(std::string& text,const std::string& inputfile)
|
||||
{
|
||||
return PGPHandler::decryptTextFromFile(mOwnGpgId,text,inputfile) ;
|
||||
return instance()->mPgpHandler->decryptTextFromFile(instance()->mOwnGpgId,text,inputfile) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::removeKeysFromPGPKeyring(const std::set<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
||||
@ -66,22 +78,22 @@ bool AuthGPG::removeKeysFromPGPKeyring(const std::set<RsPgpId>& pgp_ids,std::str
|
||||
// for(std::list<RsPgpId>::const_iterator it(pgp_ids.begin());it!=pgp_ids.end();++it)
|
||||
// pids.push_back(RsPgpId(*it)) ;
|
||||
|
||||
return PGPHandler::removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
|
||||
return instance()->mPgpHandler->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
|
||||
}
|
||||
|
||||
// bool AuthGPG::decryptTextFromString(std::string& encrypted_text,std::string& output)
|
||||
// {
|
||||
// return PGPHandler::decryptTextFromString(mOwnGpgId,encrypted_text,output) ;
|
||||
// return instance()->mPgpHandler->decryptTextFromString(mOwnGpgId,encrypted_text,output) ;
|
||||
// }
|
||||
|
||||
bool AuthGPG::encryptTextToFile(const std::string& text,const std::string& outfile)
|
||||
{
|
||||
return PGPHandler::encryptTextToFile(mOwnGpgId,text,outfile) ;
|
||||
return instance()->mPgpHandler->encryptTextToFile(instance()->mOwnGpgId,text,outfile) ;
|
||||
}
|
||||
|
||||
// bool AuthGPG::encryptTextToString(const std::string& pgp_id,const std::string& text,std::string& outstr)
|
||||
// {
|
||||
// return PGPHandler::encryptTextToString(RsPgpId(pgp_id),text,outstr) ;
|
||||
// return instance()->mPgpHandler->encryptTextToString(RsPgpId(pgp_id),text,outstr) ;
|
||||
// }
|
||||
|
||||
std::string pgp_pwd_callback(void * /*hook*/, const char *uid_title, const char *uid_hint, const char * /*passphrase_info*/, int prev_was_bad,bool *cancelled)
|
||||
@ -107,8 +119,8 @@ void AuthGPG::init(
|
||||
std::cerr << "AuthGPG::init() called twice!" << std::endl ;
|
||||
}
|
||||
|
||||
// if(cb) PGPHandler::setPassphraseCallback(cb);else
|
||||
PGPHandler::setPassphraseCallback(pgp_pwd_callback);
|
||||
// if(cb) instance()->mPgpHandler->setPassphraseCallback(cb);else
|
||||
instance()->mPgpHandler->setPassphraseCallback(pgp_pwd_callback);
|
||||
_instance = new AuthGPG( path_to_public_keyring,
|
||||
path_to_secret_keyring,
|
||||
path_to_trustdb, pgp_lock_file );
|
||||
@ -126,7 +138,6 @@ void AuthGPG::exit()
|
||||
|
||||
AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& path_to_secret_keyring,const std::string& path_to_trustdb,const std::string& pgp_lock_file)
|
||||
:p3Config(),
|
||||
OpenPGPSDKHandler(path_to_public_keyring,path_to_secret_keyring,path_to_trustdb,pgp_lock_file),
|
||||
gpgMtxService("AuthGPG-service"),
|
||||
gpgMtxEngine("AuthGPG-engine"),
|
||||
gpgMtxData("AuthGPG-data"),
|
||||
@ -135,6 +146,8 @@ AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& pa
|
||||
_force_sync_database(false),
|
||||
mCount(0)
|
||||
{
|
||||
mPgpHandler = new OpenPGPSDKHandler(path_to_public_keyring,path_to_secret_keyring,path_to_trustdb,pgp_lock_file);
|
||||
|
||||
start("AuthGPG");
|
||||
}
|
||||
|
||||
@ -149,7 +162,7 @@ AuthGPG::AuthGPG(const std::string& path_to_public_keyring,const std::string& pa
|
||||
//{
|
||||
// std::list<RsPgpId> pids ;
|
||||
//
|
||||
// PGPHandler::availableGPGCertificatesWithPrivateKeys(pids) ;
|
||||
// mPgpHandler->availableGPGCertificatesWithPrivateKeys(pids) ;
|
||||
//
|
||||
// for(std::list<RsPgpId>::const_iterator it(pids.begin());it!=pids.end();++it)
|
||||
// ids.push_back( (*it).toStdString() ) ;
|
||||
@ -171,11 +184,11 @@ int AuthGPG::GPGInit(const RsPgpId &ownId)
|
||||
std::cerr << "AuthGPG::GPGInit() called with own gpg id : " << ownId.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
mOwnGpgId = RsPgpId(ownId);
|
||||
instance()->mOwnGpgId = ownId;
|
||||
|
||||
//force the validity of the private key. When set to unknown, it caused signature and text encryptions bugs
|
||||
privateTrustCertificate(ownId, 5);
|
||||
updateOwnSignatureFlag(mOwnGpgId) ;
|
||||
instance()->privateTrustCertificate(ownId, 5);
|
||||
instance()->mPgpHandler->updateOwnSignatureFlag(ownId) ;
|
||||
|
||||
#ifdef DEBUG_AUTHGPG
|
||||
std::cerr << "AuthGPG::GPGInit finished." << std::endl;
|
||||
@ -204,7 +217,7 @@ void AuthGPG::threadTick()
|
||||
/// - checks whether the keyring has changed on disk.
|
||||
/// - merges/updates according to status.
|
||||
///
|
||||
PGPHandler::syncDatabase() ;
|
||||
mPgpHandler->syncDatabase() ;
|
||||
mCount = 0;
|
||||
_force_sync_database = false ;
|
||||
}//if (++count >= 100 || _force_sync_database)
|
||||
@ -251,7 +264,7 @@ void AuthGPG::processServices()
|
||||
|
||||
|
||||
/* don't bother loading - if we already have the certificate */
|
||||
if (isGPGId(loadOrSave->m_certGpgId))
|
||||
if (mPgpHandler->isGPGId(loadOrSave->m_certGpgId))
|
||||
{
|
||||
#ifdef GPG_DEBUG
|
||||
std::cerr << "AuthGPGimpl::processServices() Skipping load - already have it" << std::endl;
|
||||
@ -307,64 +320,64 @@ void AuthGPG::processServices()
|
||||
|
||||
bool AuthGPG::DoOwnSignature(const void *data, unsigned int datalen, void *buf_sigout, unsigned int *outl, std::string reason /* = "" */)
|
||||
{
|
||||
return PGPHandler::SignDataBin(mOwnGpgId,data,datalen,(unsigned char *)buf_sigout,outl,false,reason) ;
|
||||
return instance()->mPgpHandler->SignDataBin(mOwnGpgId,data,datalen,(unsigned char *)buf_sigout,outl,false,reason) ;
|
||||
}
|
||||
|
||||
|
||||
/* import to GnuPG and other Certificates */
|
||||
bool AuthGPG::VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const PGPFingerprintType& withfingerprint)
|
||||
{
|
||||
return PGPHandler::VerifySignBin((unsigned char*)data,datalen,(unsigned char*)sig,siglen,withfingerprint) ;
|
||||
return instance()->mPgpHandler->VerifySignBin((unsigned char*)data,datalen,(unsigned char*)sig,siglen,withfingerprint) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::parseSignature(const void *sig, unsigned int siglen, RsPgpId& issuer_id)
|
||||
{
|
||||
return PGPHandler::parseSignature((unsigned char*)sig,siglen,issuer_id) ;
|
||||
return instance()->mPgpHandler->parseSignature((unsigned char*)sig,siglen,issuer_id) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::exportProfile(const std::string& fname,const RsPgpId& exported_id)
|
||||
{
|
||||
return PGPHandler::exportGPGKeyPair(fname,exported_id) ;
|
||||
return instance()->mPgpHandler->exportGPGKeyPair(fname,exported_id) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::exportIdentityToString(
|
||||
std::string& data, const RsPgpId& pgpId, bool includeSignatures,
|
||||
std::string& errorMsg )
|
||||
{
|
||||
return PGPHandler::exportGPGKeyPairToString(
|
||||
return instance()->mPgpHandler->exportGPGKeyPairToString(
|
||||
data, pgpId, includeSignatures, errorMsg);
|
||||
}
|
||||
|
||||
bool AuthGPG::importProfile(const std::string& fname,RsPgpId& imported_id,std::string& import_error)
|
||||
{
|
||||
return PGPHandler::importGPGKeyPair(fname,imported_id,import_error) ;
|
||||
return instance()->mPgpHandler->importGPGKeyPair(fname,imported_id,import_error) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::importProfileFromString(const std::string &data, RsPgpId &gpg_id, std::string &import_error)
|
||||
{
|
||||
return PGPHandler::importGPGKeyPairFromString(data, gpg_id, import_error);
|
||||
return instance()->mPgpHandler->importGPGKeyPairFromString(data, gpg_id, import_error);
|
||||
}
|
||||
|
||||
bool AuthGPG::active()
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
return gpgKeySelected;
|
||||
return instance()->gpgKeySelected;
|
||||
}
|
||||
|
||||
bool AuthGPG::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId& pgpId, const int keynumbits, std::string& errString)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxEngine); /******* LOCKED ******/
|
||||
|
||||
return PGPHandler::GeneratePGPCertificate(name, email, passwd, pgpId, keynumbits, errString) ;
|
||||
return instance()->mPgpHandler->GeneratePGPCertificate(name, email, passwd, pgpId, keynumbits, errString) ;
|
||||
}
|
||||
|
||||
/**** These Two are common */
|
||||
std::string AuthGPG::getGPGName(const RsPgpId& id,bool *success)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
const PGPCertificateInfo *info = getCertificateInfo(id) ;
|
||||
const PGPCertificateInfo *info = instance()->mPgpHandler->getCertificateInfo(id) ;
|
||||
|
||||
if(info != NULL)
|
||||
{
|
||||
@ -378,11 +391,29 @@ std::string AuthGPG::getGPGName(const RsPgpId& id,bool *success)
|
||||
}
|
||||
}
|
||||
|
||||
AuthGPG *AuthGPG::instance()
|
||||
{
|
||||
if(!_instance)
|
||||
{
|
||||
RsFatal() << "AuthGPG::instance() called before AuthGPG::init()! This should not happen." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
bool AuthGPG::isPGPId(const RsPgpId& id)
|
||||
{
|
||||
return instance()->mPgpHandler->isGPGId(id);
|
||||
}
|
||||
bool AuthGPG::isPGPAccepted(const RsPgpId& id)
|
||||
{
|
||||
return instance()->mPgpHandler->isGPGAccepted(id);
|
||||
}
|
||||
/**** These Two are common */
|
||||
std::string AuthGPG::getGPGEmail(const RsPgpId& id,bool *success)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
const PGPCertificateInfo *info = getCertificateInfo(id) ;
|
||||
RsStackMutex stack(instance()->gpgMtxData); /******* LOCKED ******/
|
||||
const PGPCertificateInfo *info = instance()->mPgpHandler->getCertificateInfo(id) ;
|
||||
|
||||
if(info != NULL)
|
||||
{
|
||||
@ -400,20 +431,20 @@ std::string AuthGPG::getGPGEmail(const RsPgpId& id,bool *success)
|
||||
|
||||
const RsPgpId& AuthGPG::getGPGOwnId()
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
return mOwnGpgId ;
|
||||
RsStackMutex stack(instance()->gpgMtxData); /******* LOCKED ******/
|
||||
return instance()->mOwnGpgId ;
|
||||
}
|
||||
|
||||
std::string AuthGPG::getGPGOwnName()
|
||||
{
|
||||
return getGPGName(mOwnGpgId) ;
|
||||
return getGPGName(instance()->mOwnGpgId) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::getGPGAllList(std::list<RsPgpId> &ids)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
PGPHandler::getGPGFilteredList(ids) ;
|
||||
instance()->mPgpHandler->getGPGFilteredList(ids) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -421,7 +452,7 @@ const PGPCertificateInfo *AuthGPG::getCertInfoFromStdString(const std::string& p
|
||||
{
|
||||
try
|
||||
{
|
||||
return PGPHandler::getCertificateInfo(RsPgpId(pgp_id)) ;
|
||||
return instance()->mPgpHandler->getCertificateInfo(RsPgpId(pgp_id)) ;
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
@ -429,13 +460,13 @@ const PGPCertificateInfo *AuthGPG::getCertInfoFromStdString(const std::string& p
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
bool AuthGPG::haveSecretKey(const RsPgpId& id) const
|
||||
bool AuthGPG::haveSecretKey(const RsPgpId& id)
|
||||
{
|
||||
return PGPHandler::haveSecretKey(id) ;
|
||||
return instance()->mPgpHandler->haveSecretKey(id) ;
|
||||
}
|
||||
bool AuthGPG::isKeySupported(const RsPgpId& id) const
|
||||
bool AuthGPG::isKeySupported(const RsPgpId& id)
|
||||
{
|
||||
const PGPCertificateInfo *pc = getCertificateInfo(id) ;
|
||||
const PGPCertificateInfo *pc = instance()->mPgpHandler->getCertificateInfo(id) ;
|
||||
|
||||
if(pc == NULL)
|
||||
return false ;
|
||||
@ -445,9 +476,9 @@ bool AuthGPG::isKeySupported(const RsPgpId& id) const
|
||||
|
||||
bool AuthGPG::getGPGDetails(const RsPgpId& pgp_id, RsPeerDetails &d)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
const PGPCertificateInfo *pc = PGPHandler::getCertificateInfo(pgp_id) ;
|
||||
const PGPCertificateInfo *pc = instance()->mPgpHandler->getCertificateInfo(pgp_id) ;
|
||||
|
||||
if(pc == NULL)
|
||||
return false ;
|
||||
@ -476,9 +507,7 @@ bool AuthGPG::getGPGDetails(const RsPgpId& pgp_id, RsPeerDetails &d)
|
||||
|
||||
bool AuthGPG::getGPGFilteredList(std::list<RsPgpId>& list,bool (*filter)(const PGPCertificateInfo&))
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
return PGPHandler::getGPGFilteredList(list,filter) ;
|
||||
return instance()->mPgpHandler->getGPGFilteredList(list,filter) ;
|
||||
}
|
||||
|
||||
static bool filter_Validity(const PGPCertificateInfo& /*info*/) { return true ; } //{ return info._validLvl >= PGPCertificateInfo::GPGME_VALIDITY_MARGINAL ; }
|
||||
@ -504,9 +533,9 @@ bool AuthGPG::getGPGSignedList(std::list<RsPgpId> &ids)
|
||||
// {
|
||||
// RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
// #ifdef LIMIT_CERTIFICATE_SIZE
|
||||
// certificate = PGPHandler::SaveCertificateToString(RsPgpId(id),false) ;
|
||||
// certificate = instance()->mPgpHandler->SaveCertificateToString(RsPgpId(id),false) ;
|
||||
// #else
|
||||
// certificate = PGPHandler::SaveCertificateToString(RsPgpId(id),true) ;
|
||||
// certificate = instance()->mPgpHandler->SaveCertificateToString(RsPgpId(id),true) ;
|
||||
// #endif
|
||||
//
|
||||
// // #ifdef LIMIT_CERTIFICATE_SIZE
|
||||
@ -530,18 +559,18 @@ bool AuthGPG::getGPGSignedList(std::list<RsPgpId> &ids)
|
||||
/* SKTAN : do not know how to use std::string id */
|
||||
std::string AuthGPG::SaveCertificateToString(const RsPgpId &id,bool include_signatures)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxEngine); /******* LOCKED ******/
|
||||
|
||||
return PGPHandler::SaveCertificateToString(id,include_signatures) ;
|
||||
return instance()->mPgpHandler->SaveCertificateToString(id,include_signatures) ;
|
||||
}
|
||||
/* import to GnuPG and other Certificates */
|
||||
bool AuthGPG::LoadPGPKeyFromBinaryData(const unsigned char *data,uint32_t data_len, RsPgpId& gpg_id,std::string& error_string)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxEngine); /******* LOCKED ******/
|
||||
|
||||
if(PGPHandler::LoadCertificateFromBinaryData(data,data_len,gpg_id,error_string))
|
||||
if(instance()->mPgpHandler->LoadCertificateFromBinaryData(data,data_len,gpg_id,error_string))
|
||||
{
|
||||
updateOwnSignatureFlag(gpg_id,mOwnGpgId) ;
|
||||
instance()->mPgpHandler->updateOwnSignatureFlag(gpg_id,instance()->mOwnGpgId) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@ -551,11 +580,11 @@ bool AuthGPG::LoadPGPKeyFromBinaryData(const unsigned char *data,uint32_t data_l
|
||||
/* import to GnuPG and other Certificates */
|
||||
bool AuthGPG::LoadCertificateFromString(const std::string &str, RsPgpId& gpg_id,std::string& error_string)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
|
||||
RsStackMutex stack(instance()->gpgMtxEngine); /******* LOCKED ******/
|
||||
|
||||
if(PGPHandler::LoadCertificateFromString(str,gpg_id,error_string))
|
||||
if(instance()->mPgpHandler->LoadCertificateFromString(str,gpg_id,error_string))
|
||||
{
|
||||
updateOwnSignatureFlag(gpg_id,mOwnGpgId) ;
|
||||
instance()->mPgpHandler->updateOwnSignatureFlag(gpg_id,instance()->mOwnGpgId) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@ -584,11 +613,11 @@ bool AuthGPG::AllowConnection(const RsPgpId& gpg_id, bool accept)
|
||||
|
||||
/* Was a "Reload Certificates" here -> be shouldn't be needed -> and very expensive, try without. */
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData);
|
||||
PGPHandler::setAcceptConnexion(gpg_id,accept) ;
|
||||
RsStackMutex stack(instance()->gpgMtxData);
|
||||
instance()->mPgpHandler->setAcceptConnexion(gpg_id,accept) ;
|
||||
}
|
||||
|
||||
IndicateConfigChanged();
|
||||
instance()->IndicateConfigChanged();
|
||||
|
||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_FRIENDS, accept ? NOTIFY_TYPE_ADD : NOTIFY_TYPE_DEL);
|
||||
|
||||
@ -602,7 +631,7 @@ bool AuthGPG::SignCertificateLevel0(const RsPgpId &id)
|
||||
std::cerr << "AuthGPG::SignCertificat(" << id << ")" << std::endl;
|
||||
#endif
|
||||
|
||||
return privateSignCertificate(id) ;
|
||||
return instance()->privateSignCertificate(id) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::RevokeCertificate(const RsPgpId &id)
|
||||
@ -622,26 +651,39 @@ bool AuthGPG::TrustCertificate(const RsPgpId& id, int trustlvl)
|
||||
#ifdef GPG_DEBUG
|
||||
std::cerr << "AuthGPG::TrustCertificate(" << id << ", " << trustlvl << ")" << std::endl;
|
||||
#endif
|
||||
return privateTrustCertificate(id, trustlvl) ;
|
||||
return instance()->privateTrustCertificate(id, trustlvl) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::encryptDataBin(const RsPgpId& pgp_id,const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
||||
{
|
||||
return PGPHandler::encryptDataBin(RsPgpId(pgp_id),data,datalen,sign,signlen) ;
|
||||
return instance()->mPgpHandler->encryptDataBin(RsPgpId(pgp_id),data,datalen,sign,signlen) ;
|
||||
}
|
||||
|
||||
bool AuthGPG::decryptDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen)
|
||||
{
|
||||
return PGPHandler::decryptDataBin(mOwnGpgId,data,datalen,sign,signlen) ;
|
||||
return instance()->mPgpHandler->decryptDataBin(instance()->mOwnGpgId,data,datalen,sign,signlen) ;
|
||||
}
|
||||
bool AuthGPG::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen, std::string reason /*= ""*/)
|
||||
{
|
||||
return DoOwnSignature(data, datalen, sign, signlen, reason);
|
||||
return instance()->DoOwnSignature(data, datalen, sign, signlen, reason);
|
||||
}
|
||||
|
||||
bool AuthGPG::exportPublicKey( const RsPgpId& id, unsigned char*& mem_block, size_t& mem_size, bool armoured, bool include_signatures )
|
||||
{
|
||||
return instance()->mPgpHandler->exportPublicKey(id,mem_block,mem_size,armoured,include_signatures);
|
||||
}
|
||||
|
||||
bool AuthGPG::isPgpPubKeyAvailable(const RsPgpId& pgp_id)
|
||||
{
|
||||
return instance()->mPgpHandler->isPgpPubKeyAvailable(pgp_id);
|
||||
}
|
||||
bool AuthGPG::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp)
|
||||
{
|
||||
return instance()->mPgpHandler->getKeyFingerprint(id,fp);
|
||||
}
|
||||
bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint)
|
||||
{
|
||||
return VerifySignature(data, datalen, sign, signlen, withfingerprint);
|
||||
return instance()->VerifySignature(data, datalen, sign, signlen, withfingerprint);
|
||||
}
|
||||
|
||||
/* Sign/Trust stuff */
|
||||
@ -650,7 +692,7 @@ int AuthGPG::privateSignCertificate(const RsPgpId &id)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||
|
||||
int ret = PGPHandler::privateSignCertificate(mOwnGpgId,id) ;
|
||||
int ret = mPgpHandler->privateSignCertificate(mOwnGpgId,id) ;
|
||||
_force_sync_database = true ;
|
||||
return ret ;
|
||||
}
|
||||
@ -675,7 +717,7 @@ int AuthGPG::privateTrustCertificate(const RsPgpId& id, int trustlvl)
|
||||
if(!isGPGAccepted(id))
|
||||
return 0;
|
||||
|
||||
int res = PGPHandler::privateTrustCertificate(id,trustlvl) ;
|
||||
int res = instance()->mPgpHandler->privateTrustCertificate(id,trustlvl) ;
|
||||
_force_sync_database = true ;
|
||||
return res ;
|
||||
}
|
||||
@ -690,6 +732,10 @@ RsSerialiser *AuthGPG::setupSerialiser()
|
||||
rss->addSerialType(new RsGeneralConfigSerialiser());
|
||||
return rss ;
|
||||
}
|
||||
bool AuthGPG::isGPGAccepted(const RsPgpId& id)
|
||||
{
|
||||
return instance()->mPgpHandler->isGPGAccepted(id);
|
||||
}
|
||||
|
||||
bool AuthGPG::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
||||
{
|
||||
@ -745,7 +791,7 @@ bool AuthGPG::loadList(std::list<RsItem*>& load)
|
||||
std::list<RsTlvKeyValue>::iterator kit;
|
||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
||||
if (kit->key != mOwnGpgId.toStdString())
|
||||
PGPHandler::setAcceptConnexion(RsPgpId(kit->key), (kit->value == "TRUE"));
|
||||
instance()->mPgpHandler->setAcceptConnexion(RsPgpId(kit->key), (kit->value == "TRUE"));
|
||||
}
|
||||
delete (*it);
|
||||
}
|
||||
@ -755,14 +801,14 @@ bool AuthGPG::loadList(std::list<RsItem*>& load)
|
||||
|
||||
bool AuthGPG::addService(AuthGPGService *service)
|
||||
{
|
||||
RsStackMutex stack(gpgMtxService); /********* LOCKED *********/
|
||||
RsStackMutex stack(instance()->gpgMtxService); /********* LOCKED *********/
|
||||
|
||||
if (std::find(services.begin(), services.end(), service) != services.end()) {
|
||||
if (std::find(instance()->services.begin(), instance()->services.end(), service) != instance()->services.end()) {
|
||||
/* it exists already! */
|
||||
return false;
|
||||
}
|
||||
|
||||
services.push_back(service);
|
||||
instance()->services.push_back(service);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,9 +89,7 @@ public:
|
||||
virtual void setGPGOperation(AuthGPGOperation *operation) = 0;
|
||||
};
|
||||
|
||||
// Note: replace OpenPGPSDKHandler with your own PGP handler class when needed.
|
||||
|
||||
class AuthGPG: public p3Config, public RsTickingThread, public OpenPGPSDKHandler
|
||||
class AuthGPG: public p3Config, public RsTickingThread
|
||||
{
|
||||
public:
|
||||
static void init(const std::string& path_to_pubring,
|
||||
@ -99,8 +97,11 @@ public:
|
||||
const std::string& path_to_trustdb,
|
||||
const std::string& pgp_lock_file);
|
||||
|
||||
static void registerToConfigMgr(const std::string& fname,p3ConfigMgr *CfgMgr);
|
||||
static void exit();
|
||||
static AuthGPG *getAuthGPG() { return _instance ; }
|
||||
|
||||
static bool isPGPId(const RsPgpId& id) ;
|
||||
static bool isPGPAccepted(const RsPgpId& id) ;
|
||||
|
||||
/**
|
||||
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
||||
@ -120,7 +121,7 @@ public:
|
||||
* (see storage at the end of the class)
|
||||
*
|
||||
****/
|
||||
virtual bool active();
|
||||
static bool active();
|
||||
|
||||
// /* Initialize */
|
||||
// virtual bool InitAuth ();
|
||||
@ -128,8 +129,11 @@ public:
|
||||
|
||||
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
|
||||
|
||||
virtual int GPGInit(const RsPgpId &ownId);
|
||||
virtual bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
||||
static int GPGInit(const RsPgpId &ownId);
|
||||
static bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
||||
|
||||
static bool getGPGDetailsFromBinaryBlock(const unsigned char *mem,size_t mem_size,RsPgpId& key_id, std::string& name, std::list<RsPgpId>& signers) ;
|
||||
static int availableGPGCertificatesWithPrivateKeys(std::list<RsPgpId>& pgpIds);
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 3 ***********************************************/
|
||||
@ -142,29 +146,35 @@ public:
|
||||
* provide access to details in cache list.
|
||||
*
|
||||
****/
|
||||
virtual std::string getGPGName(const RsPgpId &pgp_id,bool *success = NULL);
|
||||
virtual std::string getGPGEmail(const RsPgpId &pgp_id,bool *success = NULL);
|
||||
static std::string getGPGName(const RsPgpId &pgp_id,bool *success = NULL);
|
||||
static std::string getGPGEmail(const RsPgpId &pgp_id,bool *success = NULL);
|
||||
|
||||
static bool exportPublicKey( const RsPgpId& id, unsigned char*& mem_block, size_t& mem_size, bool armoured, bool include_signatures );
|
||||
|
||||
/* PGP web of trust management */
|
||||
virtual const RsPgpId& getGPGOwnId();
|
||||
virtual std::string getGPGOwnName();
|
||||
static const RsPgpId& getGPGOwnId();
|
||||
static std::string getGPGOwnName();
|
||||
|
||||
static bool isGPGAccepted(const RsPgpId& id);
|
||||
|
||||
//virtual std::string getGPGOwnEmail();
|
||||
virtual bool isKeySupported(const RsPgpId &id) const ;
|
||||
virtual bool haveSecretKey(const RsPgpId &id) const ;
|
||||
virtual bool getGPGDetails(const RsPgpId& id, RsPeerDetails &d);
|
||||
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||
virtual bool importProfile(const std::string& filename,RsPgpId& gpg_id,std::string& import_error) ;
|
||||
virtual bool importProfileFromString(const std::string& data,RsPgpId& gpg_id,std::string& import_error) ;
|
||||
virtual bool exportProfile(const std::string& filename,const RsPgpId& gpg_id) ;
|
||||
virtual bool exportIdentityToString(
|
||||
static bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) ;
|
||||
static bool isKeySupported(const RsPgpId &id) ;
|
||||
static bool isPgpPubKeyAvailable(const RsPgpId& pgp_id);
|
||||
static bool haveSecretKey(const RsPgpId &id) ;
|
||||
static bool getGPGDetails(const RsPgpId& id, RsPeerDetails &d);
|
||||
static bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||
static bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||
static bool getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||
static bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||
static bool importProfile(const std::string& filename,RsPgpId& gpg_id,std::string& import_error) ;
|
||||
static bool importProfileFromString(const std::string& data,RsPgpId& gpg_id,std::string& import_error) ;
|
||||
static bool exportProfile(const std::string& filename,const RsPgpId& gpg_id) ;
|
||||
static bool exportIdentityToString(
|
||||
std::string& data, const RsPgpId& pgpId, bool includeSignatures,
|
||||
std::string& errorMsg );
|
||||
|
||||
virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code) ;
|
||||
static bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code) ;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 4 ***********************************************/
|
||||
@ -173,9 +183,9 @@ public:
|
||||
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
|
||||
*
|
||||
****/
|
||||
virtual bool LoadCertificateFromString(const std::string &pem, RsPgpId& gpg_id,std::string& error_string);
|
||||
virtual bool LoadPGPKeyFromBinaryData(const unsigned char *data,uint32_t data_len, RsPgpId& gpg_id,std::string& error_string);
|
||||
virtual std::string SaveCertificateToString(const RsPgpId &id,bool include_signatures) ;
|
||||
static bool LoadCertificateFromString(const std::string &pem, RsPgpId& gpg_id,std::string& error_string);
|
||||
static bool LoadPGPKeyFromBinaryData(const unsigned char *data,uint32_t data_len, RsPgpId& gpg_id,std::string& error_string);
|
||||
static std::string SaveCertificateToString(const RsPgpId &id,bool include_signatures) ;
|
||||
|
||||
// Cached certificates.
|
||||
//bool getCachedGPGCertificate(const RsPgpId &id, std::string &certificate);
|
||||
@ -190,12 +200,12 @@ public:
|
||||
* done in gpgroot already.
|
||||
*
|
||||
****/
|
||||
virtual bool AllowConnection(const RsPgpId &gpg_id, bool accept);
|
||||
static bool AllowConnection(const RsPgpId &gpg_id, bool accept);
|
||||
|
||||
virtual bool SignCertificateLevel0(const RsPgpId &id);
|
||||
virtual bool RevokeCertificate(const RsPgpId &id); /* Particularly hard - leave for later */
|
||||
static bool SignCertificateLevel0(const RsPgpId &id);
|
||||
static bool RevokeCertificate(const RsPgpId &id); /* Particularly hard - leave for later */
|
||||
|
||||
virtual bool TrustCertificate(const RsPgpId& id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
|
||||
static bool TrustCertificate(const RsPgpId& id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 7 ***********************************************/
|
||||
@ -206,25 +216,25 @@ public:
|
||||
* There should also be Encryption Functions... (do later).
|
||||
*
|
||||
****/
|
||||
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "");
|
||||
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const PGPFingerprintType& withfingerprint);
|
||||
virtual bool parseSignature(const void *sig, unsigned int siglen, RsPgpId& issuer_id);
|
||||
static bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "");
|
||||
static bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const PGPFingerprintType& withfingerprint);
|
||||
static bool parseSignature(const void *sig, unsigned int siglen, RsPgpId& issuer_id);
|
||||
|
||||
virtual bool encryptDataBin(const RsPgpId& pgp_id,const void *data, const uint32_t len, unsigned char *encr, unsigned int *encrlen);
|
||||
virtual bool decryptDataBin(const void *data, const uint32_t len, unsigned char *decr, unsigned int *decrlen);
|
||||
static bool encryptDataBin(const RsPgpId& pgp_id,const void *data, const uint32_t len, unsigned char *encr, unsigned int *encrlen);
|
||||
static bool decryptDataBin(const void *data, const uint32_t len, unsigned char *decr, unsigned int *decrlen);
|
||||
|
||||
virtual bool decryptTextFromFile( std::string& text,const std::string& filename);
|
||||
virtual bool encryptTextToFile (const std::string& text,const std::string& filename);
|
||||
static bool decryptTextFromFile( std::string& text,const std::string& filename);
|
||||
static bool encryptTextToFile (const std::string& text,const std::string& filename);
|
||||
|
||||
// virtual bool decryptTextFromString( std::string& encrypted_text,std::string& clear_string);
|
||||
// virtual bool encryptTextToString (const std::string& pgp_id,const std::string& clear_text,std::string& encrypted_string);
|
||||
|
||||
bool getGPGFilteredList(std::list<RsPgpId>& list,bool (*filter)(const PGPCertificateInfo&) = NULL) ;
|
||||
static bool getGPGFilteredList(std::list<RsPgpId>& list,bool (*filter)(const PGPCertificateInfo&) = NULL) ;
|
||||
|
||||
//END of PGP public functions
|
||||
|
||||
/* GPG service */
|
||||
virtual bool addService(AuthGPGService *service) ;
|
||||
static bool addService(AuthGPGService *service) ;
|
||||
|
||||
// This is for debug purpose only. Don't use it !!
|
||||
static void setAuthGPG_debug(AuthGPG *auth_gpg) { _instance = auth_gpg ; }
|
||||
@ -236,9 +246,9 @@ public:
|
||||
/*****************************************************************/
|
||||
/*********************** p3config ******************************/
|
||||
/* Key Functions to be overloaded for Full Configuration */
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
virtual bool loadList(std::list<RsItem *>& load);
|
||||
virtual RsSerialiser *setupSerialiser() override;
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&) override;
|
||||
virtual bool loadList(std::list<RsItem *>& load) override;
|
||||
/*****************************************************************/
|
||||
|
||||
private:
|
||||
@ -276,8 +286,7 @@ private:
|
||||
void threadTick() override; /// @see RsTickingThread
|
||||
|
||||
private:
|
||||
|
||||
static AuthGPG *instance_gpg; // pointeur vers le singleton
|
||||
static AuthGPG *instance();
|
||||
|
||||
RsMutex gpgMtxService;
|
||||
RsMutex gpgMtxEngine;
|
||||
@ -292,6 +301,8 @@ private:
|
||||
|
||||
rstime_t mStoreKeyTime;
|
||||
|
||||
PGPHandler *mPgpHandler;
|
||||
|
||||
RsPgpId mOwnGpgId;
|
||||
bool gpgKeySelected;
|
||||
bool _force_sync_database ;
|
||||
|
@ -759,8 +759,7 @@ X509 *AuthSSLimpl::SignX509ReqWithGPG(X509_REQ *req, long /*days*/)
|
||||
//long version = 0x00;
|
||||
unsigned long chtype = MBSTRING_UTF8;
|
||||
X509_NAME *issuer_name = X509_NAME_new();
|
||||
X509_NAME_add_entry_by_txt(issuer_name, "CN", chtype,
|
||||
(unsigned char *) AuthGPG::getAuthGPG()->getGPGOwnId().toStdString().c_str(), -1, -1, 0);
|
||||
X509_NAME_add_entry_by_txt(issuer_name, "CN", chtype, (unsigned char *) AuthGPG::getGPGOwnId().toStdString().c_str(), -1, -1, 0);
|
||||
/****
|
||||
X509_NAME_add_entry_by_NID(issuer_name, 48, 0,
|
||||
(unsigned char *) "email@email.com", -1, -1, 0);
|
||||
@ -770,7 +769,7 @@ X509 *AuthSSLimpl::SignX509ReqWithGPG(X509_REQ *req, long /*days*/)
|
||||
(unsigned char *) "loc", -1, -1, 0);
|
||||
****/
|
||||
|
||||
std::cerr << "AuthSSLimpl::SignX509Req() Issuer name: " << AuthGPG::getAuthGPG()->getGPGOwnId().toStdString() << std::endl;
|
||||
std::cerr << "AuthSSLimpl::SignX509Req() Issuer name: " << AuthGPG::getGPGOwnId().toStdString() << std::endl;
|
||||
|
||||
#ifdef V07_NON_BACKWARD_COMPATIBLE_CHANGE_002
|
||||
static const uint64_t CERTIFICATE_SERIAL_NUMBER = RS_CERTIFICATE_VERSION_NUMBER_07_0001 ;
|
||||
@ -945,7 +944,7 @@ X509 *AuthSSLimpl::SignX509ReqWithGPG(X509_REQ *req, long /*days*/)
|
||||
std::cerr << "Buffers Allocated" << std::endl;
|
||||
|
||||
/* NOW Sign via GPG Functions */
|
||||
if (!AuthGPG::getAuthGPG()->SignDataBin(buf_in, inl, buf_sigout, (unsigned int *) &sigoutl,"AuthSSLimpl::SignX509ReqWithGPG()"))
|
||||
if (!AuthGPG::SignDataBin(buf_in, inl, buf_sigout, (unsigned int *) &sigoutl,"AuthSSLimpl::SignX509ReqWithGPG()"))
|
||||
{
|
||||
sigoutl = 0;
|
||||
goto err;
|
||||
@ -1040,7 +1039,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,bool verbose, uint32_t& diagnostic)
|
||||
{
|
||||
RsPgpId issuer = RsX509Cert::getCertIssuer(*x509);
|
||||
RsPeerDetails pd;
|
||||
if (!AuthGPG::getAuthGPG()->getGPGDetails(issuer, pd))
|
||||
if (!AuthGPG::getGPGDetails(issuer, pd))
|
||||
{
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " X509 NOT authenticated : "
|
||||
<< "AuthGPG::getAuthGPG()->getGPGDetails(" << issuer
|
||||
@ -1185,9 +1184,7 @@ bool AuthSSLimpl::AuthX509WithGPG(X509 *x509,bool verbose, uint32_t& diagnostic)
|
||||
|
||||
// passed, verify the signature itself
|
||||
|
||||
if (!AuthGPG::getAuthGPG()->VerifySignBin(
|
||||
signed_data, signed_data_length, signature->data,
|
||||
static_cast<unsigned int>(signature->length), pd.fpr ))
|
||||
if (!AuthGPG::VerifySignBin( signed_data, signed_data_length, signature->data, static_cast<unsigned int>(signature->length), pd.fpr ))
|
||||
{
|
||||
diagnostic = RS_SSL_HANDSHAKE_DIAGNOSTIC_WRONG_SIGNATURE;
|
||||
goto err;
|
||||
@ -1383,7 +1380,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
||||
std::cerr << "******* VerifyX509Callback cert: " << std::hex << ctx->cert <<std::dec << std::endl;
|
||||
#endif
|
||||
|
||||
if ( !isSslOnlyFriend && pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() && !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
||||
if ( !isSslOnlyFriend && pgpId != AuthGPG::getGPGOwnId() && !AuthGPG::isGPGAccepted(pgpId) )
|
||||
{
|
||||
std::string errMsg = "Connection attempt signed by PGP key id: " +
|
||||
pgpId.toStdString() + " not accepted because it is not"
|
||||
|
@ -812,11 +812,11 @@ int p3PeerMgrIMPL::getFriendCount(bool ssl, bool online)
|
||||
|
||||
// count all gpg id's
|
||||
std::list<RsPgpId> gpgIds;
|
||||
AuthGPG::getAuthGPG()->getGPGAcceptedList(gpgIds);
|
||||
AuthGPG::getGPGAcceptedList(gpgIds);
|
||||
|
||||
// add own gpg id, if we have more than one location
|
||||
std::list<RsPeerId> ownSslIds;
|
||||
getAssociatedPeers(AuthGPG::getAuthGPG()->getGPGOwnId(), ownSslIds);
|
||||
getAssociatedPeers(AuthGPG::getGPGOwnId(), ownSslIds);
|
||||
|
||||
return gpgIds.size() + ((ownSslIds.size() > 0) ? 1 : 0);
|
||||
}
|
||||
@ -962,7 +962,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
|
||||
|
||||
// check that the PGP key is known
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->isGPGId(gpg_id))
|
||||
if(!AuthGPG::isPGPId(gpg_id))
|
||||
{
|
||||
RsErr() << "Trying to add SSL id (" << id << ") to be validated with unknown PGP key (" << gpg_id << ". This is a bug!" << std::endl;
|
||||
return false;
|
||||
@ -970,7 +970,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
|
||||
|
||||
//Authentication is now tested at connection time, we don't store the ssl cert anymore
|
||||
//
|
||||
if (!AuthGPG::getAuthGPG()->isGPGAccepted(gpg_id) && gpg_id != AuthGPG::getAuthGPG()->getGPGOwnId())
|
||||
if (!AuthGPG::isGPGAccepted(gpg_id) && gpg_id != AuthGPG::getGPGOwnId())
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::addFriend() gpg is not accepted" << std::endl;
|
||||
@ -1024,7 +1024,7 @@ bool p3PeerMgrIMPL::addFriend(const RsPeerId& input_id, const RsPgpId& input_gpg
|
||||
|
||||
pstate.id = id;
|
||||
pstate.gpg_id = gpg_id;
|
||||
pstate.name = AuthGPG::getAuthGPG()->getGPGName(gpg_id);
|
||||
pstate.name = AuthGPG::getGPGName(gpg_id);
|
||||
|
||||
pstate.vs_disc = vs_disc;
|
||||
pstate.vs_dht = vs_dht;
|
||||
@ -1126,8 +1126,8 @@ bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_
|
||||
* superficially set to true the PGP signature verification would have been
|
||||
* skipped and the attacker connection would be accepted.
|
||||
* If the PGP key is available add it as full friend. */
|
||||
if(AuthGPG::getAuthGPG()->isPgpPubKeyAvailable(pgp_id))
|
||||
AuthGPG::getAuthGPG()->AllowConnection(pgp_id, true);
|
||||
if(AuthGPG::isPgpPubKeyAvailable(pgp_id))
|
||||
AuthGPG::AllowConnection(pgp_id, true);
|
||||
else
|
||||
pstate.skip_pgp_signature_validation = true;
|
||||
|
||||
@ -2470,7 +2470,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
setOwnNetworkMode(pitem->netMode);
|
||||
setOwnVisState(pitem->vs_disc, pitem->vs_dht);
|
||||
|
||||
mOwnState.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
mOwnState.gpg_id = AuthGPG::getGPGOwnId();
|
||||
mOwnState.location = AuthSSL::getAuthSSL()->getOwnLocation();
|
||||
}
|
||||
else
|
||||
@ -2642,7 +2642,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
#endif
|
||||
|
||||
for(uint32_t i=0;i<sitem->pgp_ids.size();++i)
|
||||
if(AuthGPG::getAuthGPG()->isGPGAccepted(sitem->pgp_ids[i]) || sitem->pgp_ids[i] == AuthGPG::getAuthGPG()->getGPGOwnId())
|
||||
if(AuthGPG::isGPGAccepted(sitem->pgp_ids[i]) || sitem->pgp_ids[i] == AuthGPG::getGPGOwnId())
|
||||
{
|
||||
mFriendsPermissionFlags[sitem->pgp_ids[i]] = sitem->service_flags[i] ;
|
||||
#ifdef PEER_DEBUG
|
||||
@ -2684,7 +2684,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
for(auto group_pair:groupList)
|
||||
{
|
||||
for(auto profileIdIt(group_pair.second.peerIds.begin());profileIdIt!=group_pair.second.peerIds.end();)
|
||||
if(AuthGPG::getAuthGPG()->isGPGAccepted(*profileIdIt) || *profileIdIt == AuthGPG::getAuthGPG()->getGPGOwnId())
|
||||
if(AuthGPG::isGPGAccepted(*profileIdIt) || *profileIdIt == AuthGPG::getGPGOwnId())
|
||||
++profileIdIt;
|
||||
else
|
||||
{
|
||||
|
@ -1213,8 +1213,7 @@ int pqissl::Authorise_SSL_Connection()
|
||||
}
|
||||
|
||||
RsPgpId pgpId = RsX509Cert::getCertIssuer(*peercert);
|
||||
if( !isSslOnlyFriend && pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() &&
|
||||
!AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
||||
if( !isSslOnlyFriend && pgpId != AuthGPG::getGPGOwnId() && !AuthGPG::isGPGAccepted(pgpId) )
|
||||
{
|
||||
RsFatal() << __PRETTY_FUNCTION__ << " pgpId: " << pgpId
|
||||
<< " is not friend. It is very unlikely to happen at this "
|
||||
|
@ -797,8 +797,7 @@ int pqissllistener::completeConnection(int fd, IncomingSSLInfo& info)
|
||||
exit(failure);
|
||||
}
|
||||
|
||||
if( !isSslOnlyFriend && pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() &&
|
||||
!AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
||||
if( !isSslOnlyFriend && pgpId != AuthGPG::getGPGOwnId() && !AuthGPG::isGPGAccepted(pgpId) )
|
||||
{
|
||||
RsFatal() << __PRETTY_FUNCTION__ << " pgpId: " << pgpId
|
||||
<< " is not friend. It is very unlikely to happen at this "
|
||||
|
@ -254,7 +254,7 @@ bool p3Peers::setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint
|
||||
|
||||
bool p3Peers::haveSecretKey(const RsPgpId& id)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->haveSecretKey(id);
|
||||
return AuthGPG::haveSecretKey(id);
|
||||
}
|
||||
|
||||
/* There are too many dependancies of this function
|
||||
@ -273,7 +273,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
if (id == sOwnId)
|
||||
{
|
||||
mPeerMgr->getOwnNetStatus(ps);
|
||||
ps.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
ps.gpg_id = AuthGPG::getGPGOwnId();
|
||||
}
|
||||
else if (!mPeerMgr->getFriendNetStatus(id, ps))
|
||||
{
|
||||
@ -559,17 +559,17 @@ bool p3Peers::isProxyAddress(const uint32_t type, const sockaddr_storage& addr)
|
||||
|
||||
bool p3Peers::isKeySupported(const RsPgpId& id)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->isKeySupported(id);
|
||||
return AuthGPG::isKeySupported(id);
|
||||
}
|
||||
|
||||
std::string p3Peers::getGPGName(const RsPgpId &gpg_id)
|
||||
{
|
||||
/* get from mAuthMgr as it should have more peers? */
|
||||
return AuthGPG::getAuthGPG()->getGPGName(gpg_id);
|
||||
return AuthGPG::getGPGName(gpg_id);
|
||||
}
|
||||
|
||||
bool p3Peers::isPgpFriend(const RsPgpId& pgpId)
|
||||
{ return AuthGPG::getAuthGPG()->isGPGAccepted(pgpId); }
|
||||
{ return AuthGPG::isGPGAccepted(pgpId); }
|
||||
|
||||
bool p3Peers::isSslOnlyFriend(const RsPeerId& sslId)
|
||||
{
|
||||
@ -597,7 +597,7 @@ std::string p3Peers::getPeerName(const RsPeerId& ssl)
|
||||
#endif
|
||||
std::string name;
|
||||
if (ssl == AuthSSL::getAuthSSL()->OwnId())
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnName();
|
||||
return AuthGPG::getGPGOwnName();
|
||||
|
||||
if (mPeerMgr->getPeerName(ssl, name))
|
||||
{
|
||||
@ -617,7 +617,7 @@ bool p3Peers::getGPGAllList(std::list<RsPgpId> &ids)
|
||||
#endif
|
||||
|
||||
/* get from mAuthMgr */
|
||||
AuthGPG::getAuthGPG()->getGPGAllList(ids);
|
||||
AuthGPG::getGPGAllList(ids);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -628,7 +628,7 @@ bool p3Peers::getGPGValidList(std::list<RsPgpId> &ids)
|
||||
#endif
|
||||
|
||||
/* get from mAuthMgr */
|
||||
AuthGPG::getAuthGPG()->getGPGValidList(ids);
|
||||
AuthGPG::getGPGValidList(ids);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -639,14 +639,14 @@ bool p3Peers::getGPGSignedList(std::list<RsPgpId> &ids)
|
||||
#endif
|
||||
|
||||
/* get from mAuthMgr */
|
||||
AuthGPG::getAuthGPG()->getGPGSignedList(ids);
|
||||
AuthGPG::getGPGSignedList(ids);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3Peers::getPgpFriendList(std::vector<RsPgpId>& pgpIds)
|
||||
{
|
||||
std::list<RsPgpId> ids;
|
||||
if(AuthGPG::getAuthGPG()->getGPGAcceptedList(ids))
|
||||
if(AuthGPG::getGPGAcceptedList(ids))
|
||||
{
|
||||
pgpIds.clear();
|
||||
std::copy(ids.begin(), ids.end(), std::back_inserter(pgpIds));
|
||||
@ -660,7 +660,7 @@ bool p3Peers::getGPGAcceptedList(std::list<RsPgpId> &ids)
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getGPGAcceptedList()" << std::endl;
|
||||
#endif
|
||||
AuthGPG::getAuthGPG()->getGPGAcceptedList(ids);
|
||||
AuthGPG::getGPGAcceptedList(ids);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -676,7 +676,7 @@ bool p3Peers::getAssociatedSSLIds(const RsPgpId &gpg_id, std::list<RsPeerId> &id
|
||||
|
||||
bool p3Peers::gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason /* = "" */)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen, reason);
|
||||
return AuthGPG::SignDataBin(data,len,sign,signlen, reason);
|
||||
}
|
||||
|
||||
RsPgpId p3Peers::pgpIdFromFingerprint(const RsPgpFingerprint& fpr)
|
||||
@ -691,7 +691,7 @@ bool p3Peers::getGPGDetails(const RsPgpId &pgp_id, RsPeerDetails &d)
|
||||
#endif
|
||||
|
||||
/* get from mAuthMgr */
|
||||
bool res = AuthGPG::getAuthGPG()->getGPGDetails(pgp_id, d);
|
||||
bool res = AuthGPG::getGPGDetails(pgp_id, d);
|
||||
|
||||
d.isOnlyGPGdetail = true ;
|
||||
d.service_perm_flags = mPeerMgr->servicePermissionFlags(pgp_id) ;
|
||||
@ -706,7 +706,7 @@ const RsPgpId& p3Peers::getGPGOwnId()
|
||||
#endif
|
||||
|
||||
/* get from mAuthMgr */
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
return AuthGPG::getGPGOwnId();
|
||||
}
|
||||
|
||||
RsPgpId p3Peers::getGPGId(const RsPeerId& sslid)
|
||||
@ -718,7 +718,7 @@ RsPgpId p3Peers::getGPGId(const RsPeerId& sslid)
|
||||
/* get from mAuthMgr */
|
||||
if (sslid == AuthSSL::getAuthSSL()->OwnId())
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
return AuthGPG::getGPGOwnId();
|
||||
}
|
||||
peerState pcs;
|
||||
if (mPeerMgr->getFriendNetStatus(sslid, pcs))
|
||||
@ -739,12 +739,12 @@ bool p3Peers::addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePe
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addFriend() with : id : " << id << "; gpg_id : " << gpg_id << std::endl;
|
||||
#endif
|
||||
if(AuthGPG::getAuthGPG()->isGPGId(gpg_id))
|
||||
if(AuthGPG::isPGPId(gpg_id))
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addFriend() Authorising GPG Id: " << gpg_id << std::endl;
|
||||
#endif
|
||||
if (AuthGPG::getAuthGPG()->AllowConnection(gpg_id, true))
|
||||
if (AuthGPG::AllowConnection(gpg_id, true))
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::addFriend() Authorization OK." << std::endl;
|
||||
@ -797,7 +797,7 @@ bool p3Peers::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_id,con
|
||||
|
||||
bool p3Peers::removeKeysFromPGPKeyring(const std::set<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
|
||||
return AuthGPG::removeKeysFromPGPKeyring(pgp_ids,backup_file,error_code) ;
|
||||
}
|
||||
|
||||
bool p3Peers::removeFriendLocation(const RsPeerId &sslId)
|
||||
@ -817,7 +817,7 @@ bool p3Peers::removeFriend(const RsPgpId& gpgId)
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::removeFriend() " << gpgId << std::endl;
|
||||
#endif
|
||||
if (gpgId == AuthGPG::getAuthGPG()->getGPGOwnId()) {
|
||||
if (gpgId == AuthGPG::getGPGOwnId()) {
|
||||
std::cerr << "p3Peers::removeFriend() ERROR we're not going to remove our own GPG id." << std::endl;
|
||||
return false;
|
||||
}
|
||||
@ -825,7 +825,7 @@ bool p3Peers::removeFriend(const RsPgpId& gpgId)
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::removeFriend() Removing GPG Id: " << gpgId << std::endl;
|
||||
#endif
|
||||
if (AuthGPG::getAuthGPG()->AllowConnection(gpgId, false))
|
||||
if (AuthGPG::AllowConnection(gpgId, false))
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::removeFriend() OK." << std::endl;
|
||||
@ -1107,9 +1107,7 @@ std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures)
|
||||
rs_owner_ptr<unsigned char> mem_block = nullptr;
|
||||
size_t mem_block_size = 0;
|
||||
|
||||
if( !AuthGPG::getAuthGPG()->exportPublicKey(
|
||||
RsPgpId(pgp_id), mem_block, mem_block_size,
|
||||
false, include_signatures ) )
|
||||
if( !AuthGPG::exportPublicKey( RsPgpId(pgp_id), mem_block, mem_block_size, false, include_signatures ) )
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__
|
||||
<< " Failure retriving certificate for id " << pgp_id
|
||||
@ -1140,8 +1138,7 @@ bool p3Peers::GetPGPBase64StringAndCheckSum(
|
||||
|
||||
rs_owner_ptr<unsigned char> mem_block = nullptr;
|
||||
size_t mem_block_size = 0;
|
||||
if(!AuthGPG::getAuthGPG()->exportPublicKey(
|
||||
gpg_id,mem_block,mem_block_size,false,false ))
|
||||
if(!AuthGPG::exportPublicKey( gpg_id,mem_block,mem_block_size,false,false ))
|
||||
return false;
|
||||
|
||||
RsBase64::encode(mem_block, mem_block_size, gpg_base64_string, true, false);
|
||||
@ -1601,7 +1598,7 @@ std::string p3Peers::GetRetroshareInvite( const RsPeerId& sslId, RetroshareInvit
|
||||
unsigned char *mem_block = nullptr;
|
||||
size_t mem_block_size = 0;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->exportPublicKey( RsPgpId(detail.gpg_id), mem_block, mem_block_size, false, !!(invite_flags & RetroshareInviteFlags::PGP_SIGNATURES) ))
|
||||
if(!AuthGPG::exportPublicKey( RsPgpId(detail.gpg_id), mem_block, mem_block_size, false, !!(invite_flags & RetroshareInviteFlags::PGP_SIGNATURES) ))
|
||||
{
|
||||
std::cerr << "Cannot output certificate for id \"" << detail.gpg_id
|
||||
<< "\". Sorry." << std::endl;
|
||||
@ -1637,7 +1634,7 @@ bool p3Peers::loadCertificateFromString(
|
||||
}
|
||||
|
||||
RsPgpId gpgid;
|
||||
bool res = AuthGPG::getAuthGPG()->LoadCertificateFromString( crt->armouredPGPKey(), gpgid, error_string );
|
||||
bool res = AuthGPG::LoadCertificateFromString( crt->armouredPGPKey(), gpgid, error_string );
|
||||
|
||||
gpg_id = gpgid;
|
||||
ssl_id = crt->sslid();
|
||||
@ -1654,7 +1651,7 @@ bool p3Peers::loadCertificateFromString(
|
||||
}
|
||||
bool p3Peers::loadPgpKeyFromBinaryData( const unsigned char *bin_key_data,uint32_t bin_key_len, RsPgpId& gpg_id, std::string& error_string )
|
||||
{
|
||||
bool res = AuthGPG::getAuthGPG()->LoadPGPKeyFromBinaryData( bin_key_data,bin_key_len, gpg_id, error_string );
|
||||
bool res = AuthGPG::LoadPGPKeyFromBinaryData( bin_key_data,bin_key_len, gpg_id, error_string );
|
||||
|
||||
if(res)
|
||||
mPeerMgr->notifyPgpKeyReceived(gpg_id);
|
||||
@ -1673,9 +1670,7 @@ bool p3Peers::loadDetailsFromStringCert( const std::string &certstr,
|
||||
|
||||
RsCertificate& cert = *certPtr;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->getGPGDetailsFromBinaryBlock(
|
||||
cert.pgp_key(), cert.pgp_key_size(),
|
||||
pd.gpg_id, pd.name, pd.gpgSigners ))
|
||||
if(!AuthGPG::getGPGDetailsFromBinaryBlock( cert.pgp_key(), cert.pgp_key_size(), pd.gpg_id, pd.name, pd.gpgSigners ))
|
||||
return false;
|
||||
|
||||
Dbg4() << __PRETTY_FUNCTION__ << " Parsing cert for sslid, location, ext "
|
||||
@ -1753,7 +1748,7 @@ bool p3Peers::signGPGCertificate(const RsPgpId &id, const std::string &gpg_pass
|
||||
rsNotify->cachePgpPassphrase(gpg_passphrase);
|
||||
rsNotify->setDisableAskPassword(true);
|
||||
|
||||
bool res = AuthGPG::getAuthGPG()->SignCertificateLevel0(id);
|
||||
bool res = AuthGPG::SignCertificateLevel0(id);
|
||||
|
||||
rsNotify->clearPgpPassphrase();
|
||||
rsNotify->setDisableAskPassword(false);
|
||||
@ -1767,7 +1762,7 @@ bool p3Peers::trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl)
|
||||
std::cerr << "p3Peers::TrustCertificate() " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return AuthGPG::getAuthGPG()->TrustCertificate(id, trustlvl);
|
||||
return AuthGPG::TrustCertificate(id, trustlvl);
|
||||
}
|
||||
|
||||
/* Group Stuff */
|
||||
|
@ -140,7 +140,7 @@ bool p3ServerConfig::setConfigurationOption(uint32_t key, const std::string &opt
|
||||
int p3ServerConfig::getConfigNetStatus(RsConfigNetStatus &status)
|
||||
{
|
||||
status.ownId = AuthSSL::getAuthSSL()->OwnId();
|
||||
status.ownName = AuthGPG::getAuthGPG()->getGPGOwnName();
|
||||
status.ownName = AuthGPG::getGPGOwnName();
|
||||
|
||||
// Details from PeerMgr.
|
||||
peerState pstate;
|
||||
|
@ -701,10 +701,10 @@ static bool checkAccount(const std::string &accountdir, AccountDetails &account,
|
||||
if(! RsAccounts::GetPGPLoginDetails(account.mPgpId, account.mPgpName, account.mPgpEmail))
|
||||
return false ;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->haveSecretKey(account.mPgpId))
|
||||
if(!AuthGPG::haveSecretKey(account.mPgpId))
|
||||
return false ;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->isKeySupported(account.mPgpId))
|
||||
if(!AuthGPG::isKeySupported(account.mPgpId))
|
||||
{
|
||||
std::string keystring = account.mPgpId.toStdString() + " " + account.mPgpName + "<" + account.mPgpEmail ;
|
||||
unsupported_keys[keystring].push_back("Location: " + account.mLocation + " (" + account.mSslId.toStdString() + ")") ;
|
||||
@ -851,8 +851,9 @@ static bool checkAccount(const std::string &accountdir, AccountDetails &account,
|
||||
|
||||
|
||||
/* Generating GPGme Account */
|
||||
int RsAccountsDetail::GetPGPLogins(std::list<RsPgpId> &pgpIds) {
|
||||
AuthGPG::getAuthGPG()->availableGPGCertificatesWithPrivateKeys(pgpIds);
|
||||
int RsAccountsDetail::GetPGPLogins(std::list<RsPgpId>& pgpIds)
|
||||
{
|
||||
AuthGPG::availableGPGCertificatesWithPrivateKeys(pgpIds);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -863,10 +864,10 @@ int RsAccountsDetail::GetPGPLoginDetails(const RsPgpId& id, std::string &na
|
||||
#endif
|
||||
|
||||
bool ok = true ;
|
||||
name = AuthGPG::getAuthGPG()->getGPGName(id,&ok);
|
||||
name = AuthGPG::getGPGName(id,&ok);
|
||||
if(!ok)
|
||||
return 0 ;
|
||||
email = AuthGPG::getAuthGPG()->getGPGEmail(id,&ok);
|
||||
email = AuthGPG::getGPGEmail(id,&ok);
|
||||
if(!ok)
|
||||
return 0 ;
|
||||
|
||||
@ -886,7 +887,7 @@ bool RsAccountsDetail::SelectPGPAccount(const RsPgpId& pgpId)
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
if (0 < AuthGPG::getAuthGPG() -> GPGInit(pgpId))
|
||||
if (0 < AuthGPG::GPGInit(pgpId))
|
||||
{
|
||||
retVal = true;
|
||||
#ifdef DEBUG_ACCOUNTS
|
||||
@ -906,7 +907,7 @@ bool RsAccountsDetail::SelectPGPAccount(const RsPgpId& pgpId)
|
||||
|
||||
bool RsAccountsDetail::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, keynumbits, errString);
|
||||
return AuthGPG::GeneratePGPCertificate(name, email, passwd, pgpId, keynumbits, errString);
|
||||
}
|
||||
|
||||
// PGP Support Functions.
|
||||
@ -918,24 +919,24 @@ void RsAccountsDetail::getUnsupportedKeys(std::map<std::string,std::vector<std::
|
||||
|
||||
bool RsAccountsDetail::exportIdentity(const std::string& fname,const RsPgpId& id)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->exportProfile(fname,id);
|
||||
return AuthGPG::exportProfile(fname,id);
|
||||
}
|
||||
|
||||
bool RsAccountsDetail::importIdentity(const std::string& fname,RsPgpId& id,std::string& import_error)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->importProfile(fname,id,import_error);
|
||||
return AuthGPG::importProfile(fname,id,import_error);
|
||||
}
|
||||
|
||||
bool RsAccountsDetail::importIdentityFromString(const std::string &data, RsPgpId &imported_pgp_id, std::string &import_error)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->importProfileFromString(data, imported_pgp_id, import_error);
|
||||
return AuthGPG::importProfileFromString(data, imported_pgp_id, import_error);
|
||||
}
|
||||
|
||||
bool RsAccountsDetail::exportIdentityToString(
|
||||
std::string& data, const RsPgpId& pgpId, bool includeSignatures,
|
||||
std::string& errorMsg )
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->exportIdentityToString(
|
||||
return AuthGPG::exportIdentityToString(
|
||||
data, pgpId, includeSignatures, errorMsg );
|
||||
}
|
||||
|
||||
@ -1020,7 +1021,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const s
|
||||
|
||||
int nbits = 4096;
|
||||
|
||||
//std::string pgp_name = AuthGPG::getAuthGPG()->getGPGName(pgp_id);
|
||||
//std::string pgp_name = AuthGPG::getGPGName(pgp_id);
|
||||
|
||||
// Create the filename .....
|
||||
// Temporary Directory for creating files....
|
||||
|
@ -510,7 +510,7 @@ RsInit::LoadCertificateStatus RsInit::LockAndLoadCertificates(
|
||||
if(!RsAccounts::GetAccountDetails(accountId, pgpId, pgpName, pgpEmail, location))
|
||||
throw RsInit::ERR_UNKNOWN; // invalid PreferredAccount;
|
||||
|
||||
if(0 == AuthGPG::getAuthGPG() -> GPGInit(pgpId))
|
||||
if(0 == AuthGPG::GPGInit(pgpId))
|
||||
throw RsInit::ERR_UNKNOWN; // PGP Error.
|
||||
|
||||
LoadCertificateStatus retVal =
|
||||
@ -910,8 +910,8 @@ int RsServer::StartupRetroShare()
|
||||
/* History Manager */
|
||||
mHistoryMgr = new p3HistoryMgr();
|
||||
mPeerMgr = new p3PeerMgrIMPL( AuthSSL::getAuthSSL()->OwnId(),
|
||||
AuthGPG::getAuthGPG()->getGPGOwnId(),
|
||||
AuthGPG::getAuthGPG()->getGPGOwnName(),
|
||||
AuthGPG::getGPGOwnId(),
|
||||
AuthGPG::getGPGOwnName(),
|
||||
AuthSSL::getAuthSSL()->getOwnLocation());
|
||||
mNetMgr = new p3NetMgrIMPL();
|
||||
mLinkMgr = new p3LinkMgrIMPL(mPeerMgr, mNetMgr);
|
||||
@ -1604,7 +1604,8 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
//mConfigMgr->addConfiguration("ftserver.cfg", ftserver);
|
||||
//
|
||||
mConfigMgr->addConfiguration("gpg_prefs.cfg" , AuthGPG::getAuthGPG());
|
||||
AuthGPG::registerToConfigMgr(std::string("gpg_prefs.cfg"),mConfigMgr);
|
||||
|
||||
mConfigMgr->addConfiguration("gxsnettunnel.cfg", mGxsNetTunnel);
|
||||
mConfigMgr->addConfiguration("peers.cfg" , mPeerMgr);
|
||||
mConfigMgr->addConfiguration("general.cfg" , mGeneralConfig);
|
||||
@ -1792,7 +1793,7 @@ int RsServer::StartupRetroShare()
|
||||
/* Add AuthGPG services */
|
||||
/**************************************************************************/
|
||||
|
||||
//AuthGPG::getAuthGPG()->addService(mDisc);
|
||||
//AuthGPG::addService(mDisc);
|
||||
|
||||
/**************************************************************************/
|
||||
/* Force Any Last Configuration Options */
|
||||
|
@ -60,8 +60,7 @@ bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ok = AuthGPG::getAuthGPG()->encryptTextToFile(
|
||||
ssl_passwd, getSSLPasswdFileName(ssl_id));
|
||||
bool ok = AuthGPG::encryptTextToFile( ssl_passwd, getSSLPasswdFileName(ssl_id));
|
||||
|
||||
if (!ok) std::cerr << "Encrypting went wrong !" << std::endl;
|
||||
|
||||
@ -90,7 +89,7 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string&
|
||||
#endif
|
||||
|
||||
std::string plain;
|
||||
if ( AuthGPG::getAuthGPG()->decryptTextFromFile( plain, getSSLPasswdFileName(ssl_id)) )
|
||||
if ( AuthGPG::decryptTextFromFile( plain, getSSLPasswdFileName(ssl_id)) )
|
||||
{
|
||||
sslPassword = plain;
|
||||
#ifdef DEBUG_RSLOGINHANDLER
|
||||
|
@ -1066,7 +1066,7 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
|
||||
if(params.isPgpLinked)
|
||||
{
|
||||
ssdata.pgp.pgpId = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
ssdata.pgp.pgpId = AuthGPG::getGPGOwnId();
|
||||
ssdata.pgp.lastCheckTs = time(nullptr);
|
||||
}
|
||||
|
||||
@ -3618,7 +3618,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(
|
||||
unsigned int sign_size = MAX_SIGN_SIZE;
|
||||
memset(signarray,0,MAX_SIGN_SIZE) ; // just in case.
|
||||
|
||||
int result = AuthGPG::getAuthGPG()->SignDataBin(
|
||||
int result = AuthGPG::SignDataBin(
|
||||
static_cast<const void*>(hash.toByteArray()),
|
||||
hash.SIZE_IN_BYTES, signarray, &sign_size,
|
||||
__PRETTY_FUNCTION__ )
|
||||
|
Loading…
Reference in New Issue
Block a user