* Added the basics of GxsCircles service to libretroshare.

- Defined the control group stuff.
  	- Background task to determine friend membership.
	- Caching of Circle info,
	- Added GXS interface class to gxs/rsgixs.h
 	- TODO: Serialiser is incomplete.
	- TODO: SubCircles to be done in Phase 2.

 * Improvements to RsMemCache:
	- Added Value& ref(Key) to avoid data copying.
	- Added Statistics to check cache performance.
	- Fixed up bugs in tracking membership.

 * Improvements to RsTickEvent:
	- Added additional string parameter for more specificity.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5910 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-11-29 22:48:28 +00:00
parent baa949eaac
commit 5a55c1b5d6
18 changed files with 2353 additions and 427 deletions

View file

@ -58,6 +58,8 @@ bool queueRequest(uint32_t token, uint32_t req_type);
void checkRequests(); // must be called by
protected:
// This must be overloaded to complete the functionality.
virtual void handleResponse(uint32_t token, uint32_t req_type);

View file

@ -29,6 +29,8 @@
#include "gxs/rsgxs.h"
#include "gxs/rsgenexchange.h"
#include "retroshare/rsgxscircles.h"
#include "serialiser/rstlvkeys.h"
/*!
@ -94,9 +96,9 @@
* as these will be used very frequently.
*****/
//typedef std::string GxsId;
typedef std::string PeerId;
typedef std::string PeerId; // SHOULD BE REMOVED => RsPeerId (SSLID)
typedef std::string RsPgpId;
typedef std::string RsGxsId;
//
//// External Interface -
@ -119,7 +121,6 @@ typedef std::string PeerId;
/* Identity Interface for GXS Message Verification.
*/
typedef std::string RsGxsId;
class RsGixs
{
public:
@ -185,8 +186,8 @@ class RsGxsIdExchange:
public RsGixs
{
public:
RsGxsIdExchange(RsGeneralDataService* gds, RsNetworkExchangeService* ns, RsSerialType* serviceSerialiser, uint16_t mServType)
:RsGenExchange(gds,ns,serviceSerialiser,mServType, this) { return; }
RsGxsIdExchange(RsGeneralDataService* gds, RsNetworkExchangeService* ns, RsSerialType* serviceSerialiser, uint16_t mServType)
:RsGenExchange(gds,ns,serviceSerialiser,mServType, this) { return; }
virtual ~RsGxsIdExchange() { return; }
};
@ -194,180 +195,31 @@ virtual ~RsGxsIdExchange() { return; }
/* For Circles Too */
// BELOW IS OLD - WILL DELETE SHORTLY
#if 0
/*!
* Storage class for private and public publish keys
*
*/
class GixsKey
class RsGcxs
{
KeyRef mKeyId;
public:
/// public key
EVP_PKEY *mPubKey;
/// NULL if non-existant */
EVP_PKEY *mPrivKey;
};
/*!
*
*
*/
class KeyRef {
std::string refId;
/* GXS Interface - for working out who can receive */
virtual bool isLoaded(const RsGxsCircleId &circleId) = 0;
virtual bool loadCircle(const RsGxsCircleId &circleId) = 0;
virtual int canSend(const RsGxsCircleId &circleId, const RsPgpId &id) = 0;
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist) = 0;
};
class KeyRefSet {
std::set<KeyRef> mKeyRefSet;
};
class SignatureSet {
std::set<RsGxsSignature> mSignatureSet;
};
/*!
*
*
*/
class RsGxsSignature {
KeyRef mKeyRef;
};
/*!
* This is the actual identity \n
* In a sense the group description with the GixsKey the "message"
*/
class RsGixsProfile {
public:
KeyRef mKeyRef;
std::string name;
/// may be superseded by newer timestamps
time_t mTimeStamp;
uint32_t mProfileType;
// TODO: add permissions members
RsGxsSignature mSignature;
};
/*!
* Retroshare general identity exchange service
*
* Purpose: \n
* Provides a means to distribute identities among peers \n
* Also provides encyption, decryption, verification, \n
* and signing functionality using any created or received identities \n
*
* This may best be implemented as a singleton like current AuthGPG? \n
*
*/
class RsIdentityExchangeService : RsGxsService
class RsGxsCircleExchange: public RsGenExchange, public RsGcxs
{
public:
enum IdentityType { Pseudonym, Signed, Anonymous };
RsGixs();
/*!
* creates gixs profile and shares it
* @param profile
* @param type the type of profile to create, self signed, anonymous, and GPG signed
*/
virtual bool createKey(RsGixsProfile& profile, uint32_t type) = 0; /* fills in mKeyId, and signature */
/*!
* Use to query a whether given key is available by its key reference
* @param keyref the keyref of key that is being checked for
* @return true if available, false otherwise
*/
virtual bool haveKey(const KeyRef& keyref) = 0;
/*!
* Use to query whether private key member of the given key reference is available
* @param keyref the KeyRef of the key being checked for
* @return true if private key is held here, false otherwise
*/
virtual bool havePrivateKey(const KeyRef& keyref) = 0;
/*!
* Use to request a given key reference
* @param keyref the KeyRef of the key being requested
* @return will
*/
virtual bool requestKey(const KeyRef& keyref) = 0;
/*!
* Retrieves a key identity
* @param keyref
* @return a pointer to a valid profile if successful, otherwise NULL
*
*/
virtual RsGixsProfile* getProfile(const KeyRef& keyref) = 0;
/*** process data ***/
/*!
* Use to sign data with a given key
* @param keyref the key to sign the data with
* @param data the data to be signed
* @param dataLen the length of the data
* @param signature is set with the signature from signing with keyref
* @return false if signing failed, true otherwise
*/
virtual bool sign(const KeyRef& keyref, unsigned char* data, uint32_t dataLen, std::string& signature) = 0;
/*!
* Verify that the data is signed by the key owner
* @param keyref
* @param data
* @param dataLen
* @param signature
* @return false if verification failed, false otherwise
*/
virtual bool verify(const KeyRef& keyref, unsigned char* data, int dataLen, std::string& signature) = 0;
/*!
* Attempt to decrypt data with a given key
* @param keyref
* @param data data to be decrypted
* @param dataLen length of data
* @param decryptedData decrypted data
* @param decryptDataLen length of decrypted data
* @return false
*/
virtual bool decrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
unsigned char*& decryptedData, uint32_t& decyptDataLen) = 0;
/*!
* Attempt to encrypt data with a given key
* @param keyref
* @param data data to be encrypted
* @param dataLen length of data
* @param encryptedData encrypted data
* @param encryptDataLen length of encrypted data
*/
virtual bool encrypt(const KeyRef& keyref, unsigned char* data, int dataLen,
unsigned char*& encryptedData, uint32_t& encryptDataLen) = 0;
RsGxsCircleExchange(RsGeneralDataService* gds, RsNetworkExchangeService* ns, RsSerialType* serviceSerialiser,
uint16_t mServType, RsGixs* gixs, uint32_t authenPolicy)
:RsGenExchange(gds,ns,serviceSerialiser,mServType, gixs, authenPolicy) { return; }
virtual ~RsGxsCircleExchange() { return; }
};
#endif // END OF #if 0
#endif // RSGIXS_H