make it compile

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2002 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-13 20:58:58 +00:00
parent c23407cae3
commit a0a64fb588
17 changed files with 188 additions and 191 deletions

View File

@ -832,7 +832,7 @@ bool CacheStrapper::loadList(std::list<RsItem *> load)
CacheData cd;
cd.pid = rscc->pid;
cd.pname = getAuthSSL()->getName(cd.pid);
cd.pname = AuthSSL::getAuthSSL()->getName(cd.pid);
cd.cid.type = rscc->cachetypeid;
cd.cid.subid = rscc->cachesubid;
cd.path = rscc->path;

View File

@ -858,7 +858,7 @@ bool ftServer::handleCacheData()
data.name = ci->file.name;
data.path = ci->file.path;
data.pid = ci->PeerId();
data.pname = getAuthSSL()->getName(ci->PeerId());
data.pname = AuthSSL::getAuthSSL()->getName(ci->PeerId());
mCacheStrapper->recvCacheResponse(data, time(NULL));
delete ci;

View File

@ -1,5 +1,5 @@
/*
* libretroshare/src gpgauthmgr.cc
* libretroshare/src AuthGPG.cc
*
* GnuPG/GPGme interface for RetroShare.
*
@ -39,7 +39,7 @@
*
* GPG Functions:
* ValidateCertificate() calls,
* bool GPGAuthMgr::AuthX509(X509 *x509)
* bool AuthGPG::AuthX509(X509 *x509)
* VerifySignature()
*
* VerifyX509Callback()
@ -120,7 +120,12 @@ gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passp
static char *PgpPassword = NULL;
bool GPGAuthMgr::setPGPPassword_locked(std::string pwd)
AuthGPG *AuthGPG::getAuthGPG()
{
return &instance_gpgroot;
}
bool AuthGPG::setPGPPassword_locked(std::string pwd)
{
/* reset it while we change it */
gpgme_set_passphrase_cb(CTX, NULL, NULL);
@ -131,14 +136,14 @@ bool GPGAuthMgr::setPGPPassword_locked(std::string pwd)
memcpy(PgpPassword, pwd.c_str(), pwd.length());
PgpPassword[pwd.length()] = '\0';
fprintf(stderr, "GPGAuthMgr::setPGPPassword_locked() called\n");
fprintf(stderr, "AuthGPG::setPGPPassword_locked() called\n");
gpgme_set_passphrase_cb(CTX, pgp_pwd_callback, (void *) PgpPassword);
return true;
}
GPGAuthMgr::GPGAuthMgr()
AuthGPG::AuthGPG()
:gpgmeInit(false)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -216,13 +221,13 @@ GPGAuthMgr::GPGAuthMgr()
updateTrustAllKeys_locked();
}
bool GPGAuthMgr::getPGPEngineFileName(std::string &fileName)
bool AuthGPG::getPGPEngineFileName(std::string &fileName)
{
if (!INFO) {
return false;
} else {
fileName = std::string(INFO->file_name);
std :: cerr << "GPGAuthMgr::getPGPEngineFileName() : " << fileName << std::endl;
std :: cerr << "AuthGPG::getPGPEngineFileName() : " << fileName << std::endl;
return true;
}
}
@ -235,7 +240,7 @@ bool GPGAuthMgr::getPGPEngineFileName(std::string &fileName)
* returns false if GnuPG is not available.
*/
bool GPGAuthMgr::availablePGPCertificates(std::list<std::string> &ids)
bool AuthGPG::availablePGPCertificates(std::list<std::string> &ids)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -265,12 +270,12 @@ bool GPGAuthMgr::availablePGPCertificates(std::list<std::string> &ids)
if (KEY->subkeys)
{
ids.push_back(KEY->subkeys->keyid);
std::cerr << "GPGAuthMgr::availablePGPCertificates() Added: "
std::cerr << "AuthGPG::availablePGPCertificates() Added: "
<< KEY->subkeys->keyid << std::endl;
}
else
{
std::cerr << "GPGAuthMgr::availablePGPCertificates() Missing subkey"
std::cerr << "AuthGPG::availablePGPCertificates() Missing subkey"
<< std::endl;
}
}
@ -282,7 +287,7 @@ bool GPGAuthMgr::availablePGPCertificates(std::list<std::string> &ids)
return false;
}
std::cerr << "GPGAuthMgr::availablePGPCertificates() Secret Key Count: " << i << std::endl;
std::cerr << "AuthGPG::availablePGPCertificates() Secret Key Count: " << i << std::endl;
/* return false if there are no private keys */
return (i > 0);
@ -295,7 +300,7 @@ bool GPGAuthMgr::availablePGPCertificates(std::list<std::string> &ids)
* This function must be called successfully (return == 1)
* before anything else can be done. (except above fn).
*/
int GPGAuthMgr::GPGInit(std::string ownId)
int AuthGPG::GPGInit(std::string ownId)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -334,7 +339,7 @@ int GPGAuthMgr::GPGInit(std::string ownId)
return true;
}
int GPGAuthMgr::GPGInit(std::string name, std::string comment,
int AuthGPG::GPGInit(std::string name, std::string comment,
std::string email, std::string inPassphrase)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -377,11 +382,11 @@ int GPGAuthMgr::GPGInit(std::string name, std::string comment,
return 1;
}
GPGAuthMgr::~GPGAuthMgr()
AuthGPG::~AuthGPG()
{
}
int GPGAuthMgr::LoadGPGPassword(std::string pwd)
int AuthGPG::LoadGPGPassword(std::string pwd)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -398,9 +403,9 @@ int GPGAuthMgr::LoadGPGPassword(std::string pwd)
// store all keys in map mKeyList to avoid callin gpgme exe repeatedly
bool GPGAuthMgr::storeAllKeys_locked()
bool AuthGPG::storeAllKeys_locked()
{
std::cerr << "GPGAuthMgr::storeAllKeys_locked()";
std::cerr << "AuthGPG::storeAllKeys_locked()";
std::cerr << std::endl;
gpg_error_t ERR;
@ -411,7 +416,7 @@ bool GPGAuthMgr::storeAllKeys_locked()
return false;
}
std::cerr << "GPGAuthMgr::storeAllKeys_locked() clearing existing ones";
std::cerr << "AuthGPG::storeAllKeys_locked() clearing existing ones";
std::cerr << std::endl;
mKeyList.clear();
@ -557,7 +562,7 @@ bool GPGAuthMgr::storeAllKeys_locked()
}
// update trust on all available keys.
bool GPGAuthMgr::updateTrustAllKeys_locked()
bool AuthGPG::updateTrustAllKeys_locked()
{
gpg_error_t ERR;
if (!gpgmeInit)
@ -628,7 +633,7 @@ bool GPGAuthMgr::updateTrustAllKeys_locked()
return true;
}
bool GPGAuthMgr::printAllKeys_locked()
bool AuthGPG::printAllKeys_locked()
{
certmap::const_iterator it;
@ -671,7 +676,7 @@ bool GPGAuthMgr::printAllKeys_locked()
return true;
}
bool GPGAuthMgr::printOwnKeys_locked()
bool AuthGPG::printOwnKeys_locked()
{
certmap::iterator it;
@ -691,7 +696,7 @@ bool GPGAuthMgr::printOwnKeys_locked()
return true;
}
bool GPGAuthMgr::printKeys()
bool AuthGPG::printKeys()
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
printAllKeys_locked();
@ -750,13 +755,13 @@ void print_pgpme_verify_summary(unsigned int summary)
}
bool GPGAuthMgr::DoOwnSignature_locked(const void *data, unsigned int datalen, void *buf_sigout, unsigned int *outl)
bool AuthGPG::DoOwnSignature_locked(const void *data, unsigned int datalen, void *buf_sigout, unsigned int *outl)
{
/* setup signers */
gpgme_signers_clear(CTX);
if (GPG_ERR_NO_ERROR != gpgme_signers_add(CTX, mOwnGpgCert.key))
{
std::cerr << "GPGAuthMgr::DoOwnSignature() Error Adding Signer";
std::cerr << "AuthGPG::DoOwnSignature() Error Adding Signer";
std::cerr << std::endl;
}
@ -782,7 +787,7 @@ bool GPGAuthMgr::DoOwnSignature_locked(const void *data, unsigned int datalen, v
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_sign(CTX,gpgmeData, gpgmeSig, mode)))
{
ProcessPGPmeError(ERR);
std::cerr << "GPGAuthMgr::Sign FAILED ERR: " << ERR;
std::cerr << "AuthGPG::Sign FAILED ERR: " << ERR;
std::cerr << std::endl;
return false;
}
@ -802,13 +807,13 @@ bool GPGAuthMgr::DoOwnSignature_locked(const void *data, unsigned int datalen, v
gpgme_new_signature_t sg = res->signatures;
while(ik != NULL)
{
fprintf(stderr, "GPGAuthMgr::Sign, Invalid by: %s\n", ik->fpr);
fprintf(stderr, "AuthGPG::Sign, Invalid by: %s\n", ik->fpr);
ik = ik->next;
}
while(sg != NULL)
{
fprintf(stderr, "GPGAuthMgr::Signed by: %s\n", sg->fpr);
fprintf(stderr, "AuthGPG::Signed by: %s\n", sg->fpr);
sg = sg->next;
}
@ -817,7 +822,7 @@ bool GPGAuthMgr::DoOwnSignature_locked(const void *data, unsigned int datalen, v
int len2 = len;
gpgme_data_write (gpgmeSig, "", 1); // to be able to convert it into a string
char *export_sig = gpgme_data_release_and_get_mem(gpgmeSig, &len);
fprintf(stderr, "GPGAuthMgr::Signature len: %d \n", len2);
fprintf(stderr, "AuthGPG::Signature len: %d \n", len2);
if (len < *outl)
{
*outl = len;
@ -832,7 +837,7 @@ bool GPGAuthMgr::DoOwnSignature_locked(const void *data, unsigned int datalen, v
/* import to GnuPG and other Certificates */
bool GPGAuthMgr::VerifySignature_locked(const void *data, int datalen, const void *sig, unsigned int siglen)
bool AuthGPG::VerifySignature_locked(const void *data, int datalen, const void *sig, unsigned int siglen)
{
gpgme_data_t gpgmeSig;
gpgme_data_t gpgmeData;
@ -860,7 +865,7 @@ bool GPGAuthMgr::VerifySignature_locked(const void *data, int datalen, const voi
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL)))
{
ProcessPGPmeError(ERR);
std::cerr << "GPGAuthMgr::Verify FAILED";
std::cerr << "AuthGPG::Verify FAILED";
std::cerr << std::endl;
}
@ -881,12 +886,12 @@ bool GPGAuthMgr::VerifySignature_locked(const void *data, int datalen, const voi
while(sg != NULL)
{
fprintf(stderr, "GPGAuthMgr::Verify Sig by: %s, Result: %d\n", sg->fpr, sg->summary);
fprintf(stderr, "AuthGPG::Verify Sig by: %s, Result: %d\n", sg->fpr, sg->summary);
print_pgpme_verify_summary(sg->summary);
if (sg->summary & GPGME_SIGSUM_VALID)
{
fprintf(stderr, "GPGAuthMgr::VerifySignature() OK\n");
fprintf(stderr, "AuthGPG::VerifySignature() OK\n");
valid = true;
}
@ -899,7 +904,7 @@ bool GPGAuthMgr::VerifySignature_locked(const void *data, int datalen, const voi
/* extract id(s)! */
if (!valid)
{
fprintf(stderr, "GPGAuthMgr::VerifySignature() FAILED\n");
fprintf(stderr, "AuthGPG::VerifySignature() FAILED\n");
}
@ -909,27 +914,27 @@ bool GPGAuthMgr::VerifySignature_locked(const void *data, int datalen, const voi
bool GPGAuthMgr::active()
bool AuthGPG::active()
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
return ((gpgmeInit) && (gpgmeKeySelected) && (gpgmeX509Selected));
}
int GPGAuthMgr::InitAuth()
int AuthGPG::InitAuth()
{
gpgmeX509Selected = true;
return 1;
}
bool GPGAuthMgr::CloseAuth()
bool AuthGPG::CloseAuth()
{
return true;
}
#if 0 /**** no saving here! let AuthSSL store directories! ****/
int GPGAuthMgr::setConfigDirectories(std::string confFile, std::string neighDir)
int AuthGPG::setConfigDirectories(std::string confFile, std::string neighDir)
{
return 1;
}
@ -937,7 +942,7 @@ int GPGAuthMgr::setConfigDirectories(std::string confFile, std::string neigh
#endif
/**** These Two are common */
std::string GPGAuthMgr::getPGPName(GPG_id id)
std::string AuthGPG::getPGPName(GPG_id id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -949,7 +954,7 @@ std::string GPGAuthMgr::getPGPName(GPG_id id)
}
/**** These Two are common */
std::string GPGAuthMgr::getPGPEmail(GPG_id id)
std::string AuthGPG::getPGPEmail(GPG_id id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -962,14 +967,14 @@ std::string GPGAuthMgr::getPGPEmail(GPG_id id)
/**** GPG versions ***/
std::string GPGAuthMgr::PGPOwnId()
std::string AuthGPG::PGPOwnId()
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
return mOwnId;
}
bool GPGAuthMgr::getPGPAllList(std::list<std::string> &ids)
bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -982,14 +987,14 @@ bool GPGAuthMgr::getPGPAllList(std::list<std::string> &ids)
return true;
}
bool GPGAuthMgr::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
bool AuthGPG::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
gpgme_set_armor (CTX, 1);
gpg_error_t ERR;
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
{
ProcessPGPmeError(ERR);
std::cerr << "GPGAuthMgr::decryptText() Error decrypting text.";
std::cerr << "AuthGPG::decryptText() Error decrypting text.";
std::cerr << std::endl;
return false;
}
@ -997,7 +1002,7 @@ bool GPGAuthMgr::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
return true;
}
bool GPGAuthMgr::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
bool AuthGPG::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
gpgme_encrypt_flags_t* flags = new gpgme_encrypt_flags_t();
@ -1007,7 +1012,7 @@ bool GPGAuthMgr::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_encrypt(CTX, keys, *flags, PLAIN, CIPHER)))
{
ProcessPGPmeError(ERR);
std::cerr << "GPGAuthMgr::encryptText() Error encrypting text.";
std::cerr << "AuthGPG::encryptText() Error encrypting text.";
std::cerr << std::endl;
return false;
}
@ -1015,7 +1020,7 @@ bool GPGAuthMgr::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
return true;
}
bool GPGAuthMgr::getPGPAuthenticatedList(std::list<std::string> &ids)
bool AuthGPG::getPGPAuthenticatedList(std::list<std::string> &ids)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -1030,7 +1035,7 @@ bool GPGAuthMgr::getPGPAuthenticatedList(std::list<std::string> &ids)
return true;
}
bool GPGAuthMgr::getPGPUnknownList(std::list<std::string> &ids)
bool AuthGPG::getPGPUnknownList(std::list<std::string> &ids)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -1046,7 +1051,7 @@ bool GPGAuthMgr::getPGPUnknownList(std::list<std::string> &ids)
}
bool GPGAuthMgr::isPGPValid(GPG_id id)
bool AuthGPG::isPGPValid(GPG_id id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -1055,7 +1060,7 @@ bool GPGAuthMgr::isPGPValid(GPG_id id)
}
bool GPGAuthMgr::isPGPAuthenticated(GPG_id id)
bool AuthGPG::isPGPAuthenticated(GPG_id id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -1081,22 +1086,22 @@ bool GPGAuthMgr::isPGPAuthenticated(GPG_id id)
#if 0
bool GPGAuthMgr::FinalSaveCertificates()
bool AuthGPG::FinalSaveCertificates()
{
return false;
}
bool GPGAuthMgr::CheckSaveCertificates()
bool AuthGPG::CheckSaveCertificates()
{
return false;
}
bool GPGAuthMgr::saveCertificates()
bool AuthGPG::saveCertificates()
{
return false;
}
bool GPGAuthMgr::loadCertificates()
bool AuthGPG::loadCertificates()
{
return false;
}
@ -1113,11 +1118,11 @@ bool GPGAuthMgr::loadCertificates()
/* SKTAN : do not know how to use std::string id */
std::string GPGAuthMgr::SaveCertificateToString(std::string id)
std::string AuthGPG::SaveCertificateToString(std::string id)
{
if (!isPGPValid(id)) {
std::cerr << "GPGAuthMgr::SaveCertificateToString() unknown ID" << std::endl;
std::cerr << "AuthGPG::SaveCertificateToString() unknown ID" << std::endl;
std::string emptystr;
return emptystr;
}
@ -1163,7 +1168,7 @@ std::string GPGAuthMgr::SaveCertificateToString(std::string id)
}
/* import to GnuPG and other Certificates */
bool GPGAuthMgr::LoadCertificateFromString(std::string str)
bool AuthGPG::LoadCertificateFromString(std::string str)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -1181,7 +1186,7 @@ bool GPGAuthMgr::LoadCertificateFromString(std::string str)
if (GPG_ERR_NO_ERROR != gpgme_op_import (CTX,gpgmeData))
{
std::cerr << "GPGAuthMgr::Error Importing Certificate";
std::cerr << "AuthGPG::Error Importing Certificate";
std::cerr << std::endl;
return false ;
}
@ -1221,7 +1226,7 @@ bool GPGAuthMgr::LoadCertificateFromString(std::string str)
/*************************************/
/* Auth takes SSL Certificate */
bool GPGAuthMgr::AuthCertificate(GPG_id pgpid)
bool AuthGPG::AuthCertificate(GPG_id pgpid)
{
if (isPGPAuthenticated(pgpid))
{
@ -1237,10 +1242,10 @@ bool GPGAuthMgr::AuthCertificate(GPG_id pgpid)
}
/* These take PGP Ids */
bool GPGAuthMgr::SignCertificate(GPG_id id)
bool AuthGPG::SignCertificate(GPG_id id)
{
std::cerr << "GPGAuthMgr::SignCertificate(" << id << ")";
std::cerr << "AuthGPG::SignCertificate(" << id << ")";
std::cerr << std::endl;
@ -1257,48 +1262,48 @@ bool GPGAuthMgr::SignCertificate(GPG_id id)
return true;
}
bool GPGAuthMgr::RevokeCertificate(std::string id)
bool AuthGPG::RevokeCertificate(std::string id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
std::cerr << "GPGAuthMgr::RevokeCertificate(" << id << ")";
std::cerr << "AuthGPG::RevokeCertificate(" << id << ")";
std::cerr << std::endl;
return false;
}
bool GPGAuthMgr::TrustCertificate(std::string id, bool trust)
bool AuthGPG::TrustCertificate(std::string id, bool trust)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
std::cerr << "GPGAuthMgr::TrustCertificate(" << id << "," << trust << ")";
std::cerr << "AuthGPG::TrustCertificate(" << id << "," << trust << ")";
std::cerr << std::endl;
return false;
}
bool GPGAuthMgr::SignData(std::string input, std::string &sign)
bool AuthGPG::SignData(std::string input, std::string &sign)
{
return false;
}
bool GPGAuthMgr::SignData(const void *data, const uint32_t len, std::string &sign)
bool AuthGPG::SignData(const void *data, const uint32_t len, std::string &sign)
{
return false;
}
bool GPGAuthMgr::SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen)
bool AuthGPG::SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen)
{
return false;
}
bool GPGAuthMgr::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen) {
bool AuthGPG::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen) {
return DoOwnSignature_locked(data, datalen,
sign, signlen);
}
bool GPGAuthMgr::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen) {
bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen) {
return VerifySignature_locked(data, datalen,
sign, signlen);
}
@ -1306,7 +1311,7 @@ bool GPGAuthMgr::VerifySignBin(const void *data, uint32_t datalen, unsigned char
/* Sign/Trust stuff */
int GPGAuthMgr::privateSignCertificate(std::string id)
int AuthGPG::privateSignCertificate(std::string id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
@ -1349,20 +1354,20 @@ int GPGAuthMgr::privateSignCertificate(std::string id)
}
/* revoke the signature on Certificate */
int GPGAuthMgr::privateRevokeCertificate(std::string id)
int AuthGPG::privateRevokeCertificate(std::string id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
return 0;
}
int GPGAuthMgr::privateTrustCertificate(std::string id, int trustlvl)
int AuthGPG::privateTrustCertificate(std::string id, int trustlvl)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
/* The certificate should be in Peers list ??? */
if(!isAuthenticated(id)) {
if(!isPGPAuthenticated(id)) {
std::cerr << "Invalid Certificate" << std::endl;
return 0;
}
@ -1387,7 +1392,7 @@ int GPGAuthMgr::privateTrustCertificate(std::string id, int trustlvl)
/* This function to print Data */
void GPGAuthMgr::showData(gpgme_data_t dh)
void AuthGPG::showData(gpgme_data_t dh)
{
#define BUF_SIZE 512
char buf[BUF_SIZE + 1];
@ -1420,7 +1425,7 @@ void GPGAuthMgr::showData(gpgme_data_t dh)
* Create a number of friends and add them to the Map of "others" -- people who
* are known but are not allowed to access retroshare
*/
void GPGAuthMgr::createDummyFriends()
void AuthGPG::createDummyFriends()
{
const unsigned int DUMMY_KEY_LEN = 2048;

View File

@ -40,8 +40,6 @@
#define GPG_id std::string
class AuthGPG;
/* gpgcert is the identifier for a person.
* It is a wrapper class for a GPGme OpenPGP certificate.
*/
@ -76,7 +74,7 @@ class gpgcert
*/
typedef std::map<std::string, gpgcert> certmap;
class GPGAuthMgr
class AuthGPG
{
private:
@ -99,8 +97,10 @@ class GPGAuthMgr
public:
GPGAuthMgr();
~GPGAuthMgr();
AuthGPG();
~AuthGPG();
static AuthGPG *getAuthGPG();
bool availablePGPCertificates(std::list<std::string> &ids);
@ -154,7 +154,6 @@ class GPGAuthMgr
****/
/* get Details from the Certificates */
bool isAuthenticated(std::string id);
std::string getPGPName(GPG_id pgp_id);
std::string getPGPEmail(GPG_id pgp_id);
@ -224,7 +223,6 @@ class GPGAuthMgr
bool checkSignature(std::string id, std::string hash, std::string signature);
private:
RsMutex pgpMtx;
@ -248,13 +246,7 @@ bool checkSignature(std::string id, std::string hash, std::string signature);
};
// the single instance of this
static GPGAuthMgr instance_gpgroot;
GPGAuthMgr *getAuthGPG()
{
return &instance_gpgroot;
}
static AuthGPG instance_gpgroot;
/* Sign a key */

View File

@ -32,6 +32,7 @@
#include "cleanupxpgp.h"
#include "pqinetwork.h"
#include "authgpg.h"
/******************** notify of new Cert **************************/
#include "pqinotify.h"
@ -64,6 +65,12 @@ sslcert::sslcert(X509 *x509, std::string pid)
authed = false;
}
sslcert::sslcert()
{
email = "";
authed = false;
}
X509_REQ *GenerateX509Req(
std::string pkey_file, std::string passwd,
std::string name, std::string email, std::string org,
@ -394,6 +401,12 @@ AuthSSL::AuthSSL()
{
}
AuthSSL *AuthSSL::getAuthSSL()
{
return &instance_sslroot;
//return NULL;
}
bool AuthSSL::active()
{
return init;
@ -1899,7 +1912,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
std::cerr << "Digest Applied: len: " << hashoutl << std::endl;
/* NOW Sign via GPG Functions */
if (!getAuthGPG()->SignDataBin(buf_hashout, hashoutl, buf_sigout, (unsigned int *) &sigoutl))
if (!AuthGPG::getAuthGPG()->SignDataBin(buf_hashout, hashoutl, buf_sigout, (unsigned int *) &sigoutl))
{
sigoutl = 0;
goto err;
@ -2011,7 +2024,7 @@ bool AuthSSL::AuthX509(X509 *x509)
memmove(buf_sigout, signature->data, sigoutl);
/* NOW Sign via GPG Functions */
if (!getAuthGPG()->VerifySignBin(buf_hashout, hashoutl, buf_sigout, (unsigned int) sigoutl))
if (!AuthGPG::getAuthGPG()->VerifySignBin(buf_hashout, hashoutl, buf_sigout, (unsigned int) sigoutl))
{
sigoutl = 0;
goto err;
@ -2131,7 +2144,7 @@ int pem_passwd_cb(char *buf, int size, int rwflag, void *password)
static int verify_x509_callback(int preverify_ok, X509_STORE_CTX *ctx)
{
return getAuthSSL()->VerifyX509Callback(preverify_ok, ctx);
return AuthSSL::getAuthSSL()->VerifyX509Callback(preverify_ok, ctx);
}
@ -2243,7 +2256,7 @@ int LoadCheckX509andGetName(const char *cert_file, std::string &userName, std::s
bool valid = false;
if (x509)
{
valid = getAuthSSL()->ValidateCertificate(x509, userId);
valid =AuthSSL::getAuthSSL()->ValidateCertificate(x509, userId);
}
if (valid)
@ -2296,7 +2309,7 @@ int LoadCheckX509andGetIssuerName(const char *cert_file, std::string &issuerName
bool valid = false;
if (x509)
{
valid = getAuthSSL()->ValidateCertificate(x509, userId);
valid = AuthSSL::getAuthSSL()->ValidateCertificate(x509, userId);
}
if (valid)

View File

@ -48,8 +48,6 @@
#include <string>
#include <map>
#include "authgpg.h"
#include "util/rsthreads.h"
#include "pqi/pqi_base.h"
@ -89,6 +87,9 @@ class AuthSSL
{
public:
// the single instance of this
static AuthSSL *getAuthSSL();
/* Initialisation Functions (Unique) */
AuthSSL();
bool validateOwnCertificate(X509 *x509, EVP_PKEY *pkey);
@ -115,7 +116,7 @@ virtual bool isValid(std::string id);
virtual bool isAuthenticated(std::string id);
virtual std::string getName(std::string id);
virtual std::string getIssuerName(std::string id);
virtual GPG_id getGPGId(SSL_id id);
virtual std::string getGPGId(SSL_id id);
virtual bool getCertDetails(std::string id, sslcert &cert);
/* first party trust info (dummy) */
@ -185,11 +186,9 @@ bool CheckCertificate(std::string peerId, X509 *x509); /* check that they are e
bool loadCertificates(bool &oldFormat, std::map<std::string, std::string> &keyValueMap);
private:
/* Helper Functions */
bool ProcessX509(X509 *x509, std::string &id);
X509 * loadX509FromPEM(std::string pem);
@ -222,15 +221,9 @@ bool locked_FindCert(std::string id, sslcert **cert);
};
// the single instance of this, but only when SSL Only
// the single instance of this
static AuthSSL instance_sslroot;
AuthSSL *getAuthSSL()
{
return &instance_sslroot;
}
X509_REQ *GenerateX509Req(
std::string pkey_file, std::string passwd,
std::string name, std::string email, std::string org,
@ -249,12 +242,6 @@ std::string getX509OrgString(X509_NAME *name);
std::string getX509LocString(X509_NAME *name);
std::string getX509CountryString(X509_NAME *name);
#if 0
std::list<std::string> getXPGPsigners(XPGP *cert);
std::string getXPGPAuthCode(XPGP *xpgp);
#endif
std::string getX509Info(X509 *cert);
bool getX509id(X509 *x509, std::string &xid);

View File

@ -160,7 +160,7 @@ void p3ConfigMgr::saveConfiguration()
/* sign data */
std::string signature;
getAuthSSL()->SignData(membio->memptr(), membio->memsize(), signature);
AuthSSL::getAuthSSL()->SignData(membio->memptr(), membio->memsize(), signature);
#ifdef CONFIG_DEBUG
std::cerr << "p3ConfigMgr::saveConfiguration() MetaFile Signature:";
@ -274,7 +274,7 @@ void p3ConfigMgr::loadConfiguration()
/* get signature */
std::string signature;
getAuthSSL()->SignData(membio->memptr(), membio->memsize(), signature);
AuthSSL::getAuthSSL()->SignData(membio->memptr(), membio->memsize(), signature);
#ifdef CONFIG_DEBUG
std::cerr << "p3ConfigMgr::loadConfiguration() New MetaFile Signature:";

View File

@ -135,8 +135,8 @@ p3ConnectMgr::p3ConnectMgr()
mStatusChanged(false)
{
/* setup basics of own state */
ownState.id = getAuthSSL()->OwnId();
ownState.name = getAuthSSL()->getName(ownState.id);
ownState.id = AuthSSL::getAuthSSL()->OwnId();
ownState.name = AuthSSL::getAuthSSL()->getName(ownState.id);
ownState.netMode = RS_NET_MODE_UDP;
//use_extr_addr_finder = true ;
@ -1342,7 +1342,7 @@ void p3ConnectMgr::tickMonitors()
const std::string p3ConnectMgr::getOwnId()
{
return getAuthSSL()->OwnId();
return AuthSSL::getAuthSSL()->OwnId();
}
@ -1374,7 +1374,7 @@ bool p3ConnectMgr::isOnline(std::string id)
else
{
#ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::isOnline(" << id << ") is Not Friend" << std::endl << "p3ConnectMgr::isOnline() OwnId: " << getAuthSSL()->OwnId() << std::endl;
std::cerr << "p3ConnectMgr::isOnline(" << id << ") is Not Friend" << std::endl << "p3ConnectMgr::isOnline() OwnId: " << AuthSSL::getAuthSSL()->OwnId() << std::endl;
#endif
/* not a friend */
}
@ -2014,7 +2014,7 @@ bool p3ConnectMgr::addFriend(std::string id, uint32_t netMode, uint32_t visState
}
/* check with the AuthMgr if its authorised */
if (!getAuthSSL()->isAuthenticated(id))
if (!AuthSSL::getAuthSSL()->isAuthenticated(id))
{
#ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::addFriend() Failed Authentication" << std::endl;
@ -2065,7 +2065,7 @@ bool p3ConnectMgr::addFriend(std::string id, uint32_t netMode, uint32_t visState
/* get details from AuthMgr */
sslcert detail;
if (!getAuthSSL()->getCertDetails(id, detail))
if (!AuthSSL::getAuthSSL()->getCertDetails(id, detail))
{
#ifdef CONN_DEBUG
std::cerr << "p3ConnectMgr::addFriend() Failed to get Details" << std::endl;
@ -2174,7 +2174,7 @@ bool p3ConnectMgr::addNeighbour(std::string id)
}
/* check with the AuthMgr if its valid */
if (!getAuthSSL()->isValid(id))
if (!AuthSSL::getAuthSSL()->isValid(id))
{
/* no auth */
return false;
@ -2182,7 +2182,7 @@ bool p3ConnectMgr::addNeighbour(std::string id)
/* get details from AuthMgr */
sslcert detail;
if (!getAuthSSL()->getCertDetails(id, detail))
if (!AuthSSL::getAuthSSL()->getCertDetails(id, detail))
{
/* no details */
return false;
@ -2459,7 +2459,7 @@ bool p3ConnectMgr::retryConnectNotify(std::string id)
bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr)
{
if (id == getAuthSSL()->OwnId())
if (id == AuthSSL::getAuthSSL()->OwnId())
{
{
RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/
@ -2509,7 +2509,7 @@ bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr)
bool p3ConnectMgr::setExtAddress(std::string id, struct sockaddr_in addr)
{
if (id == getAuthSSL()->OwnId())
if (id == AuthSSL::getAuthSSL()->OwnId())
{
if (ownState.currentserveraddr.sin_addr.s_addr != addr.sin_addr.s_addr ||
ownState.currentserveraddr.sin_port != addr.sin_port) {
@ -2609,7 +2609,7 @@ bool p3ConnectMgr::setAddressList(std::string id, std::list<IpAddressTimed> I
bool p3ConnectMgr::setNetworkMode(std::string id, uint32_t netMode)
{
if (id == getAuthSSL()->OwnId())
if (id == AuthSSL::getAuthSSL()->OwnId())
{
uint32_t visState = ownState.visState;
setOwnNetConfig(netMode, visState);
@ -2639,7 +2639,7 @@ bool p3ConnectMgr::setNetworkMode(std::string id, uint32_t netMode)
bool p3ConnectMgr::setVisState(std::string id, uint32_t visState)
{
if (id == getAuthSSL()->OwnId())
if (id == AuthSSL::getAuthSSL()->OwnId())
{
uint32_t netMode = ownState.netMode;
setOwnNetConfig(netMode, visState);

View File

@ -103,8 +103,8 @@ int RsServer::UpdateAllConfig()
RsConfig &config = iface.mConfig;
config.ownId = getAuthSSL()->OwnId();
config.ownName = getAuthSSL()->getName(config.ownId);
config.ownId = AuthSSL::getAuthSSL()->OwnId();
config.ownName = AuthSSL::getAuthSSL()->getName(config.ownId);
peerConnectState pstate;
mConnMgr->getOwnNetStatus(pstate);
@ -157,7 +157,7 @@ void RsServer::ConfigFinalSave()
/* force saving of transfers TODO */
//ftserver->saveFileTransferStatus();
getAuthSSL()->FinalSaveCertificates();
AuthSSL::getAuthSSL()->FinalSaveCertificates();
mConfigMgr->completeConfiguration();
}

View File

@ -245,7 +245,7 @@ void RsServer::run()
//ftserver->saveFileTransferStatus();
/* see if we need to resave certs */
getAuthSSL()->CheckSaveCertificates();
AuthSSL::getAuthSSL()->CheckSaveCertificates();
/* hour loop */
if (++min >= 60)

View File

@ -156,7 +156,7 @@ bool p3Msgs::getNewChat(std::list<ChatInfo> &chats)
void p3Msgs::initRsChatInfo(RsChatMsgItem *c, ChatInfo &i)
{
i.rsid = c -> PeerId();
i.name = getAuthSSL()->getName(i.rsid);
i.name = AuthSSL::getAuthSSL()->getName(i.rsid);
i.chatflags = 0 ;
i.msg = c -> message;

View File

@ -27,6 +27,7 @@
#include "rsserver/p3face.h"
#include "pqi/p3connmgr.h"
#include "pqi/authssl.h"
#include "pqi/authgpg.h"
#include <rsiface/rsinit.h>
#include <iostream>
@ -202,7 +203,7 @@ std::string p3Peers::getOwnId()
std::cerr << std::endl;
#endif
return getAuthSSL()->OwnId();
return AuthSSL::getAuthSSL()->OwnId();
}
bool p3Peers::getOnlineList(std::list<std::string> &ids)
@ -237,7 +238,7 @@ bool p3Peers::getOthersList(std::list<std::string> &ids)
#endif
/* get from mAuthMgr */
getAuthSSL()->getAllList(ids);
AuthSSL::getAuthSSL()->getAllList(ids);
return true;
}
@ -260,7 +261,7 @@ bool p3Peers::isOnline(std::string id)
bool p3Peers::isTrustingMe(std::string id) const
{
return getAuthSSL()->isTrustingMe(id) ;
return AuthSSL::getAuthSSL()->isTrustingMe(id) ;
}
bool p3Peers::isFriend(std::string id)
@ -302,7 +303,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
/* get from mAuthMgr (first) */
sslcert authDetail;
if (!getAuthSSL()->getCertDetails(id, authDetail))
if (!AuthSSL::getAuthSSL()->getCertDetails(id, authDetail))
{
return false;
}
@ -317,7 +318,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
d.issuer = authDetail.issuer;
d.trusted = getAuthGPG()->isPGPAuthenticated(getAuthSSL()->getGPGId(id));
d.trusted = AuthGPG::getAuthGPG()->isPGPAuthenticated(AuthSSL::getAuthSSL()->getGPGId(id));
/* generate */
@ -326,7 +327,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
/* get from mConnectMgr */
peerConnectState pcs;
if (id == getAuthSSL()->OwnId())
if (id == AuthSSL::getAuthSSL()->OwnId())
{
mConnMgr->getOwnNetStatus(pcs);
}
@ -470,7 +471,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
std::string p3Peers::getPeerPGPName(std::string id)
{
/* get from mAuthMgr as it should have more peers? */
return getAuthSSL()->getIssuerName(id);
return AuthSSL::getAuthSSL()->getIssuerName(id);
}
std::string p3Peers::getPeerName(std::string id)
@ -481,7 +482,7 @@ std::string p3Peers::getPeerName(std::string id)
#endif
/* get from mAuthMgr as it should have more peers? */
return getAuthSSL()->getName(id);
return AuthSSL::getAuthSSL()->getName(id);
}
@ -501,7 +502,7 @@ bool p3Peers::getPGPFriendList(std::list<std::string> &ids)
for(it = certids.begin(); it != certids.end(); it++)
{
sslcert detail;
if (!getAuthSSL()->getCertDetails(*it, detail))
if (!AuthSSL::getAuthSSL()->getCertDetails(*it, detail))
{
continue;
}
@ -544,7 +545,7 @@ bool p3Peers::getPGPAllList(std::list<std::string> &ids)
#endif
/* get from mAuthMgr */
getAuthGPG()->getPGPAllList(ids);
AuthGPG::getAuthGPG()->getPGPAllList(ids);
return true;
}
@ -556,7 +557,7 @@ std::string p3Peers::getPGPOwnId()
#endif
/* get from mAuthMgr */
return getAuthGPG()->PGPOwnId();
return AuthGPG::getAuthGPG()->PGPOwnId();
}
@ -734,12 +735,12 @@ p3Peers::GetRetroshareInvite()
std::cerr << "p3Peers::GetRetroshareInvite()";
std::cerr << std::endl;
std::string ownId = getAuthSSL()->OwnId();
std::string certstr = getAuthSSL()->SaveCertificateToString(ownId);
std::string name = getAuthSSL()->getName(ownId);
std::string ownId = AuthSSL::getAuthSSL()->OwnId();
std::string certstr = AuthSSL::getAuthSSL()->SaveCertificateToString(ownId);
std::string name = AuthSSL::getAuthSSL()->getName(ownId);
std::string pgpownId = getAuthGPG()->PGPOwnId();
std::string pgpcertstr = getAuthGPG()->SaveCertificateToString(pgpownId);
std::string pgpownId = AuthGPG::getAuthGPG()->PGPOwnId();
std::string pgpcertstr = AuthGPG::getAuthGPG()->SaveCertificateToString(pgpownId);
std::cerr << "p3Peers::GetRetroshareInvite() SSL Cert:";
std::cerr << std::endl;
@ -768,7 +769,7 @@ bool p3Peers::LoadCertificateFromFile(std::string fname, std::string &id)
std::cerr << std::endl;
#endif
return getAuthSSL()->LoadCertificateFromFile(fname, id);
return AuthSSL::getAuthSSL()->LoadCertificateFromFile(fname, id);
}
@ -833,14 +834,14 @@ bool p3Peers::LoadCertificateFromString(std::string cert, std::string &id)
std::cerr << "pgpcert .... " << std::endl;
std::cerr << pgpcert << std::endl;
ret = getAuthGPG()->LoadCertificateFromString(pgpcert);
ret = AuthGPG::getAuthGPG()->LoadCertificateFromString(pgpcert);
}
if (sslcert != "")
{
std::cerr << "sslcert .... " << std::endl;
std::cerr << sslcert << std::endl;
ret = getAuthSSL()->LoadCertificateFromString(sslcert, id);
ret = AuthSSL::getAuthSSL()->LoadCertificateFromString(sslcert, id);
}
}
@ -860,7 +861,7 @@ bool p3Peers::SaveCertificateToFile(std::string id, std::string fname)
ensureExtension(fname, "pqi");
return getAuthSSL()->SaveCertificateToFile(id, fname);
return AuthSSL::getAuthSSL()->SaveCertificateToFile(id, fname);
}
std::string p3Peers::SaveCertificateToString(std::string id)
@ -870,7 +871,7 @@ std::string p3Peers::SaveCertificateToString(std::string id)
std::cerr << std::endl;
#endif
return getAuthSSL()->SaveCertificateToString(id);
return AuthSSL::getAuthSSL()->SaveCertificateToString(id);
}
bool p3Peers::AuthCertificate(std::string id, std::string code)
@ -880,7 +881,7 @@ bool p3Peers::AuthCertificate(std::string id, std::string code)
std::cerr << std::endl;
#endif
if (getAuthSSL()->AuthCertificate(id))
if (AuthSSL::getAuthSSL()->AuthCertificate(id))
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::AuthCertificate() OK ... Adding as Friend";
@ -900,7 +901,7 @@ bool p3Peers::SignCertificate(std::string id)
std::cerr << std::endl;
#endif
return getAuthSSL()->SignCertificate(id);
return AuthSSL::getAuthSSL()->SignCertificate(id);
}
bool p3Peers::TrustCertificate(std::string id, bool trust)
@ -910,7 +911,7 @@ bool p3Peers::TrustCertificate(std::string id, bool trust)
std::cerr << std::endl;
#endif
return getAuthSSL()->TrustCertificate(id, trust);
return AuthSSL::getAuthSSL()->TrustCertificate(id, trust);
}

View File

@ -469,7 +469,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored)
* 2) Get List of Available Accounts.
* 4) Get List of GPG Accounts.
*/
getAuthSSL() -> InitAuth(NULL, NULL, NULL);
AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL);
// first check config directories, and set bootstrap values.
setupBaseDir();
@ -767,12 +767,12 @@ static bool checkAccount(std::string accountdir, accountId &id)
/* Generating GPGme Account */
int RsInit::GetPGPLogins(std::list<std::string> &pgpIds) {
getAuthGPG()->availablePGPCertificates(pgpIds);
AuthGPG::getAuthGPG()->availablePGPCertificates(pgpIds);
return 1;
}
bool RsInit::getPGPEngineFileName(std::string &fileName) {
return getAuthGPG()->getPGPEngineFileName(fileName);
return AuthGPG::getAuthGPG()->getPGPEngineFileName(fileName);
}
int RsInit::GetPGPLoginDetails(std::string id, std::string &name, std::string &email)
@ -780,8 +780,8 @@ int RsInit::GetPGPLoginDetails(std::string id, std::string &name, std::stri
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"";
std::cerr << std::endl;
name = getAuthGPG()->getPGPName(getAuthSSL()->getGPGId(id));
email = getAuthGPG()->getPGPEmail(getAuthSSL()->getGPGId(id));
name = AuthGPG::getAuthGPG()->getPGPName(AuthSSL::getAuthSSL()->getGPGId(id));
email = AuthGPG::getAuthGPG()->getPGPEmail(AuthSSL::getAuthSSL()->getGPGId(id));
if (name != "") {
return 1;
} else {
@ -798,8 +798,7 @@ bool RsInit::SelectGPGAccount(std::string id)
std::string gpgId = id;
std::string name = id;
GPGAuthMgr *gpgAuthMgr = getAuthGPG();
if (0 < gpgAuthMgr -> GPGInit(gpgId))
if (0 < AuthGPG::getAuthGPG() -> GPGInit(gpgId))
{
ok = true;
std::cerr << "PGP Auth Success!";
@ -818,10 +817,9 @@ bool RsInit::SelectGPGAccount(std::string id)
bool RsInit::LoadGPGPassword(std::string inPGPpasswd)
{
GPGAuthMgr *gpgAuthMgr =getAuthGPG();
bool ok = false;
if (0 < gpgAuthMgr -> LoadGPGPassword(inPGPpasswd))
if (0 < AuthGPG::getAuthGPG() -> LoadGPGPassword(inPGPpasswd))
{
ok = true;
std::cerr << "PGP LoadPwd Success!";
@ -994,7 +992,7 @@ bool RsInit::GenerateSSLCertificate(std::string name, std::string org, std::
nbits, errString);
long days = 3000;
X509 *x509 = getAuthSSL()->SignX509Req(req, days);
X509 *x509 = AuthSSL::getAuthSSL()->SignX509Req(req, days);
X509_REQ_free(req);
if (x509 == NULL) {
@ -1216,7 +1214,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
gpgme_data_t plain;
gpgme_data_new_from_mem(&plain, sslPassword, strlen(sslPassword), 1);
gpgme_data_new_from_stream (&cipher, sslPassphraseFile);
if (0 < getAuthGPG()->encryptText(plain, cipher)) {
if (0 < AuthGPG::getAuthGPG()->encryptText(plain, cipher)) {
std::cerr << "Encrypting went ok !" << std::endl;
}
gpgme_data_release (cipher);
@ -1237,7 +1235,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
gpgme_data_t plain;
gpgme_data_new (&plain);
gpgme_error_t error_reading_file = gpgme_data_new_from_stream (&cipher, sslPassphraseFile);
if (0 < getAuthGPG()->decryptText(cipher, plain)) {
if (0 < AuthGPG::getAuthGPG()->decryptText(cipher, plain)) {
std::cerr << "Decrypting went ok !" << std::endl;
gpgme_data_write (plain, "", 1);
sslPassword = gpgme_data_release_and_get_mem(plain, NULL);
@ -1253,7 +1251,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
std::cerr << "RsInitConfig::load_key.c_str() : " << RsInitConfig::load_key.c_str() << std::endl;
std::cerr << "sslPassword : " << sslPassword << std::endl;;
if (0 < getAuthSSL() -> InitAuth(RsInitConfig::load_cert.c_str(), RsInitConfig::load_key.c_str(), sslPassword))
if (0 < AuthSSL::getAuthSSL() -> InitAuth(RsInitConfig::load_cert.c_str(), RsInitConfig::load_key.c_str(), sslPassword))
{
ok = true;
}
@ -1828,7 +1826,7 @@ int RsServer::StartupRetroShare()
/* (1) Load up own certificate (DONE ALREADY) - just CHECK */
/**************************************************************************/
if (1 != getAuthSSL() -> InitAuth(NULL, NULL, NULL))
if (1 != AuthSSL::getAuthSSL() -> InitAuth(NULL, NULL, NULL))
{
std::cerr << "main() - Fatal Error....." << std::endl;
std::cerr << "Invalid Certificate configuration!" << std::endl;
@ -1836,7 +1834,7 @@ int RsServer::StartupRetroShare()
exit(1);
}
std::string ownId = getAuthSSL()->OwnId();
std::string ownId = AuthSSL::getAuthSSL()->OwnId();
/**************************************************************************/
/* Any Initial Configuration (Commandline Options) */
@ -1881,9 +1879,9 @@ int RsServer::StartupRetroShare()
bool oldFormat = false;
std::map<std::string, std::string> oldConfigMap;
getAuthSSL() -> setConfigDirectories(certConfigFile, certNeighDir);
AuthSSL::getAuthSSL() -> setConfigDirectories(certConfigFile, certNeighDir);
getAuthSSL() -> loadCertificates();
AuthSSL::getAuthSSL() -> loadCertificates();
/**************************************************************************/
/* setup classes / structures */

View File

@ -91,7 +91,7 @@ p3disc::p3disc(p3ConnectMgr *cm, pqipersongrp *pqih)
lastSentHeartbeatTime = 0;
//add own version to versions map
versions[getAuthSSL()->OwnId()] = RsUtil::retroshareVersion();
versions[AuthSSL::getAuthSSL()->OwnId()] = RsUtil::retroshareVersion();
return;
}
@ -516,7 +516,7 @@ void p3disc::sendPeerDetails(std::string to, std::string about)
unsigned char **binptr = (unsigned char **) &(di -> certDER.bin_data);
getAuthSSL()->SaveCertificateToBinary(about, binptr, &certLen);
AuthSSL::getAuthSSL()->SaveCertificateToBinary(about, binptr, &certLen);
#ifdef P3DISC_DEBUG
std::cerr << "Saved certificate to binary in p3discReply. Length=" << certLen << std::endl ;
#endif
@ -565,7 +565,7 @@ void p3disc::sendPeerIssuer(std::string to, std::string about)
#endif
}
std::string aboutIssuerId = getAuthSSL()->getIssuerName(about);
std::string aboutIssuerId = AuthSSL::getAuthSSL()->getIssuerName(about);
if (aboutIssuerId == "")
{
/* major error! */
@ -579,7 +579,7 @@ void p3disc::sendPeerIssuer(std::string to, std::string about)
// Set Target as input cert.
di -> PeerId(to);
di -> issuerCert = getAuthSSL()->SaveCertificateToString(aboutIssuerId);
di -> issuerCert = AuthSSL::getAuthSSL()->SaveCertificateToString(aboutIssuerId);
#ifdef P3DISC_DEBUG
std::cerr << "Saved certificate to string in RsDiscIssuer. " << std::endl ;
@ -719,7 +719,7 @@ void p3disc::recvPeerFriendMsg(RsDiscReply *item)
uint8_t *certptr = (uint8_t *) item->certDER.bin_data;
uint32_t len = item->certDER.bin_len;
bool loaded = getAuthSSL()->LoadCertificateFromBinary(certptr, len, peerId);
bool loaded = AuthSSL::getAuthSSL()->LoadCertificateFromBinary(certptr, len, peerId);
uint32_t type = 0;
uint32_t flags = 0;
@ -732,7 +732,7 @@ void p3disc::recvPeerFriendMsg(RsDiscReply *item)
{
std::cerr << " Found a peer that trust me: " << peerId << " (" << rsPeers->getPeerName(peerId) << ")" << std::endl ;
flags |= RS_NET_FLAGS_TRUSTS_ME;
getAuthSSL()->addTrustingPeer(peerId) ;
AuthSSL::getAuthSSL()->addTrustingPeer(peerId) ;
}
/* generate type */
@ -804,7 +804,7 @@ void p3disc::recvPeerIssuerMsg(RsDiscIssuer *item)
/* load certificate */
std::string peerId;
bool loaded = getAuthSSL()->LoadCertificateFromString(item->issuerCert, peerId);
bool loaded = AuthSSL::getAuthSSL()->LoadCertificateFromString(item->issuerCert, peerId);
/* cleanup (handled by caller) */

View File

@ -35,6 +35,7 @@
#include "pqi/pqinotify.h"
#include "pqi/pqibin.h"
#include "pqi/authssl.h"
#include "pqi/authgpg.h"
/*****
* #define DISTRIB_DEBUG 1
@ -66,7 +67,7 @@ p3GroupDistrib::p3GroupDistrib(uint16_t subtype,
/* force publication of groups (cleared if local cache file found) */
mGroupsRepublish = true;
mOwnId = getAuthSSL()->OwnId();
mOwnId = AuthSSL::getAuthSSL()->OwnId();
return;
}
@ -1728,10 +1729,10 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
{
unsigned int siglen = EVP_PKEY_size(publishKey);
unsigned char sigbuf[siglen];
if (getAuthGPG()->SignDataBin(data, size, sigbuf, &siglen))
if (AuthGPG::getAuthGPG()->SignDataBin(data, size, sigbuf, &siglen))
{
signedMsg->personalSignature.signData.setBinData(sigbuf, siglen);
signedMsg->personalSignature.keyId = getAuthGPG()->PGPOwnId();
signedMsg->personalSignature.keyId = AuthGPG::getAuthGPG()->PGPOwnId();
}
}
@ -2450,7 +2451,7 @@ bool p3GroupDistrib::locked_validateDistribSignedMsg(
std::cerr << std::endl;
#endif
if (getAuthGPG()->isPGPValid(newMsg->personalSignature.keyId))
if (AuthGPG::getAuthGPG()->isPGPValid(newMsg->personalSignature.keyId))
{
#ifdef DISTRIB_DEBUG
std::cerr << "p3GroupDistrib::locked_validateDistribSignedMsg() Peer Known";

View File

@ -297,7 +297,7 @@ std::string p3Forums::createForumMsg(std::string fId, std::string pId,
fmsg->msg = msg;
if (signIt)
{
fmsg->srcId = getAuthSSL()->OwnId();
fmsg->srcId = AuthSSL::getAuthSSL()->OwnId();
}
fmsg->timestamp = time(NULL);

View File

@ -55,7 +55,7 @@ p3PhotoService::p3PhotoService(uint16_t type, CacheStrapper *cs, CacheTransfer *
{ RsStackMutex stack(mPhotoMtx); /********** STACK LOCKED MTX ******/
mOwnId = getAuthSSL()->OwnId();
mOwnId = AuthSSL::getAuthSSL()->OwnId();
}
// createDummyData();