2008-01-25 01:36:40 -05:00
|
|
|
/*
|
|
|
|
* libretroshare/src/pqi: p3authmgr.cc
|
|
|
|
*
|
|
|
|
* 3P/PQI network interface for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2007-2008 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-12-23 11:23:54 -05:00
|
|
|
#include <iostream>
|
2008-01-25 01:36:40 -05:00
|
|
|
#include "pqi/p3authmgr.h"
|
|
|
|
|
|
|
|
pqiAuthDetails::pqiAuthDetails()
|
2009-05-25 07:38:47 -04:00
|
|
|
:trustLvl(0), validLvl(0), ownsign(false), trusted(false)
|
2008-01-25 01:36:40 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
p3DummyAuthMgr::p3DummyAuthMgr()
|
|
|
|
{
|
|
|
|
/* for the truely dummy option */
|
|
|
|
mOwnId = "OWNID";
|
|
|
|
|
|
|
|
pqiAuthDetails ownDetails;
|
|
|
|
ownDetails.id = mOwnId;
|
|
|
|
ownDetails.name = "Youself";
|
|
|
|
ownDetails.email = "me@me.com";
|
|
|
|
ownDetails.location = "here";
|
|
|
|
ownDetails.org = "me.com";
|
|
|
|
|
|
|
|
ownDetails.trustLvl = 6;
|
|
|
|
ownDetails.ownsign = true;
|
|
|
|
ownDetails.trusted = true;
|
|
|
|
|
|
|
|
/* ignoring fpr and signers */
|
|
|
|
|
|
|
|
mPeerList[mOwnId] = ownDetails;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-12-23 11:23:54 -05:00
|
|
|
bool p3DummyAuthMgr::isTrustingMe(std::string id)
|
|
|
|
{
|
|
|
|
std::cerr << "isTrustingMe is not implemented in p3DummyAuthMgr. Look into authxpgp.cc." << std::endl ;
|
|
|
|
return false ;
|
|
|
|
}
|
|
|
|
void p3DummyAuthMgr::addTrustingPeer(std::string id)
|
|
|
|
{
|
|
|
|
std::cerr << "addTrustingPeer is not implemented in p3DummyAuthMgr. Look into authxpgp.cc." << std::endl ;
|
|
|
|
}
|
|
|
|
|
2008-01-25 01:36:40 -05:00
|
|
|
p3DummyAuthMgr::p3DummyAuthMgr(std::string ownId, std::list<pqiAuthDetails> peers)
|
|
|
|
{
|
|
|
|
mOwnId = ownId;
|
|
|
|
bool addedOwn = false;
|
|
|
|
|
|
|
|
std::list<pqiAuthDetails>::iterator it;
|
|
|
|
for(it = peers.begin(); it != peers.end(); it++)
|
|
|
|
{
|
|
|
|
mPeerList[it->id] = (*it);
|
|
|
|
if (it->id == ownId)
|
|
|
|
{
|
|
|
|
addedOwn = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!addedOwn)
|
|
|
|
{
|
|
|
|
pqiAuthDetails ownDetails;
|
|
|
|
ownDetails.id = mOwnId;
|
|
|
|
ownDetails.name = "Youself";
|
|
|
|
ownDetails.email = "me@me.com";
|
|
|
|
ownDetails.location = "here";
|
|
|
|
ownDetails.org = "me.com";
|
|
|
|
|
|
|
|
ownDetails.trustLvl = 6;
|
|
|
|
ownDetails.ownsign = true;
|
|
|
|
ownDetails.trusted = true;
|
|
|
|
|
|
|
|
/* ignoring fpr and signers */
|
|
|
|
|
|
|
|
mPeerList[mOwnId] = ownDetails;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr:: active()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int p3DummyAuthMgr::InitAuth(const char *srvr_cert, const char *priv_key,
|
|
|
|
const char *passwd)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::CloseAuth()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-02-07 11:18:34 -05:00
|
|
|
int p3DummyAuthMgr::setConfigDirectories(std::string confFile, std::string neighDir)
|
2008-01-25 01:36:40 -05:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string p3DummyAuthMgr::OwnId()
|
|
|
|
{
|
|
|
|
return mOwnId;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::getAllList(std::list<std::string> &ids)
|
|
|
|
{
|
|
|
|
std::map<std::string, pqiAuthDetails>::iterator it;
|
|
|
|
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
|
|
|
|
{
|
|
|
|
ids.push_back(it->first);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::getAuthenticatedList(std::list<std::string> &ids)
|
|
|
|
{
|
|
|
|
std::map<std::string, pqiAuthDetails>::iterator it;
|
|
|
|
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
|
|
|
|
{
|
|
|
|
if (it->second.trustLvl > 3)
|
|
|
|
{
|
|
|
|
ids.push_back(it->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::getUnknownList(std::list<std::string> &ids)
|
|
|
|
{
|
|
|
|
std::map<std::string, pqiAuthDetails>::iterator it;
|
|
|
|
for(it = mPeerList.begin(); it != mPeerList.end(); it++)
|
|
|
|
{
|
|
|
|
if (it->second.trustLvl <= 3)
|
|
|
|
{
|
|
|
|
ids.push_back(it->first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::isValid(std::string id)
|
|
|
|
{
|
|
|
|
std::map<std::string, pqiAuthDetails>::iterator it;
|
|
|
|
return (mPeerList.end() != mPeerList.find(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::isAuthenticated(std::string id)
|
|
|
|
{
|
|
|
|
std::map<std::string, pqiAuthDetails>::iterator it;
|
|
|
|
if (mPeerList.end() != (it = mPeerList.find(id)))
|
|
|
|
{
|
|
|
|
return (it->second.trustLvl > 3);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string p3DummyAuthMgr::getName(std::string id)
|
|
|
|
{
|
|
|
|
std::map<std::string, pqiAuthDetails>::iterator it;
|
|
|
|
if (mPeerList.end() != (it = mPeerList.find(id)))
|
|
|
|
{
|
|
|
|
return it->second.name;
|
|
|
|
}
|
|
|
|
std::string empty("");
|
|
|
|
return empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::getDetails(std::string id, pqiAuthDetails &details)
|
|
|
|
{
|
|
|
|
std::map<std::string, pqiAuthDetails>::iterator it;
|
|
|
|
if (mPeerList.end() != (it = mPeerList.find(id)))
|
|
|
|
{
|
|
|
|
details = it->second;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-08 07:39:40 -05:00
|
|
|
bool p3DummyAuthMgr::FinalSaveCertificates()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::CheckSaveCertificates()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-07 11:18:34 -05:00
|
|
|
bool p3DummyAuthMgr::saveCertificates()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::loadCertificates()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-25 01:36:40 -05:00
|
|
|
bool p3DummyAuthMgr::LoadCertificateFromString(std::string pem, std::string &id)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string p3DummyAuthMgr::SaveCertificateToString(std::string id)
|
|
|
|
{
|
|
|
|
std::string dummy("CERT STRING");
|
|
|
|
return dummy;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::LoadCertificateFromFile(std::string filename, std::string &id)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::SaveCertificateToFile(std::string id, std::string filename)
|
2008-02-03 01:29:02 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool p3DummyAuthMgr::LoadCertificateFromBinary(const uint8_t *ptr, uint32_t len, std::string &id)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::SaveCertificateToBinary(std::string id, uint8_t **ptr, uint32_t *len)
|
2008-01-25 01:36:40 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Signatures */
|
2008-02-03 01:17:33 -05:00
|
|
|
bool p3DummyAuthMgr::AuthCertificate(std::string id)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-25 01:36:40 -05:00
|
|
|
bool p3DummyAuthMgr::SignCertificate(std::string id)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::RevokeCertificate(std::string id)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::TrustCertificate(std::string id, bool trust)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-08 07:39:40 -05:00
|
|
|
bool p3DummyAuthMgr::SignData(std::string input, std::string &sign)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::SignData(const void *data, const uint32_t len, std::string &sign)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-05 19:23:43 -05:00
|
|
|
bool p3DummyAuthMgr::SignDataBin(std::string input,
|
|
|
|
unsigned char *sign, unsigned int *signlen)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::SignDataBin(const void *data, const uint32_t len,
|
|
|
|
unsigned char *sign, unsigned int *signlen)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool p3DummyAuthMgr::VerifySignBin(std::string pid,
|
|
|
|
const void *data, const uint32_t len,
|
|
|
|
unsigned char *sign, unsigned int signlen)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-08 07:39:40 -05:00
|
|
|
|