mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-04 20:34:26 -04:00
Merge pull request #861 from RetroShare/v0.6-GxsTransport
V0.6 gxs transport
This commit is contained in:
commit
1ebcc6006b
58 changed files with 4372 additions and 1167 deletions
|
@ -359,7 +359,7 @@ bool GxsSecurity::getSignature(const char *data, uint32_t data_len, const RsTlvP
|
|||
ok &= EVP_SignUpdate(mdctx, data, data_len) == 1;
|
||||
|
||||
unsigned int siglen = EVP_PKEY_size(key_priv);
|
||||
unsigned char sigbuf[siglen];
|
||||
unsigned char sigbuf[siglen] = { 0 };
|
||||
ok &= EVP_SignFinal(mdctx, sigbuf, &siglen, key_priv) == 1;
|
||||
|
||||
// clean up
|
||||
|
|
|
@ -36,9 +36,10 @@
|
|||
|
||||
|
||||
/*!
|
||||
* This contains functionality for performing security
|
||||
* operations needed to validate data received in RsGenExchange
|
||||
* This contains functionality for performing basic security operations needed
|
||||
* in RsGenExchange operations.
|
||||
* Also has routine for creating security objects around msgs and groups
|
||||
* TODO: Those functions doesn't do param checking!
|
||||
*/
|
||||
class GxsSecurity
|
||||
{
|
||||
|
|
|
@ -29,41 +29,37 @@
|
|||
#include "util/rsthreads.h"
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* A little helper class, to manage callbacks from requests
|
||||
*
|
||||
*/
|
||||
|
||||
class GxsTokenQueueItem
|
||||
struct GxsTokenQueueItem
|
||||
{
|
||||
public:
|
||||
GxsTokenQueueItem(const uint32_t token, const uint32_t req_type)
|
||||
:mToken(token),mReqType(req_type) { return; }
|
||||
|
||||
GxsTokenQueueItem(): mToken(0), mReqType(0) { return; }
|
||||
GxsTokenQueueItem(const uint32_t token, const uint32_t req_type) :
|
||||
mToken(token), mReqType(req_type) {}
|
||||
|
||||
GxsTokenQueueItem(): mToken(0), mReqType(0) {}
|
||||
|
||||
uint32_t mToken;
|
||||
uint32_t mReqType;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A little helper class, to manage callbacks from requests
|
||||
*/
|
||||
class GxsTokenQueue
|
||||
{
|
||||
public:
|
||||
public:
|
||||
GxsTokenQueue(RsGenExchange *gxs) :
|
||||
mGenExchange(gxs), mQueueMtx("GxsTokenQueueMtx") {}
|
||||
|
||||
GxsTokenQueue(RsGenExchange *gxs)
|
||||
:mGenExchange(gxs), mQueueMtx("GxsTokenQueueMtx") { return; }
|
||||
bool queueRequest(uint32_t token, uint32_t req_type);
|
||||
bool queueRequest(uint32_t token, uint32_t req_type);
|
||||
void checkRequests(); /// must be called by
|
||||
|
||||
void checkRequests(); // must be called by
|
||||
protected:
|
||||
|
||||
protected:
|
||||
/// This must be overloaded to complete the functionality.
|
||||
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
||||
|
||||
// This must be overloaded to complete the functionality.
|
||||
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
||||
|
||||
private:
|
||||
private:
|
||||
RsGenExchange *mGenExchange;
|
||||
RsMutex mQueueMtx;
|
||||
std::list<GxsTokenQueueItem> mQueue;
|
||||
|
|
|
@ -85,9 +85,6 @@ RsGenExchange::RsGenExchange(RsGeneralDataService *gds, RsNetworkExchangeService
|
|||
mChecking(false),
|
||||
mLastCheck((int)time(NULL) - (int)(RSRandom::random_u32() % INTEGRITY_CHECK_PERIOD) + 120), // this helps unsynchronising the checks for the different services, with 2 min security to avoid checking right away before statistics come up.
|
||||
mIntegrityCheck(NULL),
|
||||
CREATE_FAIL(0),
|
||||
CREATE_SUCCESS(1),
|
||||
CREATE_FAIL_TRY_LATER(2),
|
||||
SIGN_MAX_WAITING_TIME(60),
|
||||
SIGN_FAIL(0),
|
||||
SIGN_SUCCESS(1),
|
||||
|
@ -1397,7 +1394,7 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
|
||||
bool RsGenExchange::getMsgData(uint32_t token, GxsMsgDataMap &msgItems)
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
NxsMsgDataResult msgResult;
|
||||
|
@ -1447,7 +1444,8 @@ bool RsGenExchange::getMsgData(const uint32_t &token, GxsMsgDataMap &msgItems)
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool RsGenExchange::getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap &msgItems)
|
||||
bool RsGenExchange::getMsgRelatedData( uint32_t token,
|
||||
GxsMsgRelatedDataMap &msgItems )
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx) ;
|
||||
NxsMsgRelatedDataResult msgResult;
|
||||
|
|
|
@ -338,11 +338,11 @@ public:
|
|||
* @param token token to be redeemed for message item retrieval
|
||||
* @param msgItems
|
||||
*/
|
||||
bool getMsgData(const uint32_t &token, GxsMsgDataMap& msgItems);
|
||||
bool getMsgData(uint32_t token, GxsMsgDataMap& msgItems);
|
||||
|
||||
template <class MsgType>
|
||||
bool getMsgDataT(const uint32_t &token, std::map<RsGxsGroupId,
|
||||
std::vector<MsgType*> >& msgItems)
|
||||
bool getMsgDataT( uint32_t token, std::map<RsGxsGroupId,
|
||||
std::vector<MsgType*> >& msgItems)
|
||||
{
|
||||
GxsMsgDataMap msgData;
|
||||
bool ok = getMsgData(token, msgData);
|
||||
|
@ -379,7 +379,7 @@ public:
|
|||
* @param token token to be redeemed for message item retrieval
|
||||
* @param msgItems
|
||||
*/
|
||||
bool getMsgRelatedData(const uint32_t &token, GxsMsgRelatedDataMap& msgItems);
|
||||
bool getMsgRelatedData(uint32_t token, GxsMsgRelatedDataMap& msgItems);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -732,18 +732,19 @@ private:
|
|||
*/
|
||||
uint8_t createGroup(RsNxsGrp* grp, RsTlvSecurityKeySet& keySet);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* This completes the creation of an instance on RsNxsMsg
|
||||
* by assigning it a groupId and signature via SHA1 and EVP_sign respectively
|
||||
* What signatures are calculated are based on the authentication policy
|
||||
* of the service
|
||||
* @param msg the Nxs message to create
|
||||
* CREATE_FAIL, CREATE_SUCCESS, CREATE_ID_SIGN_NOT_AVAIL
|
||||
* @return CREATE_SUCCESS for success, CREATE_FAIL for fail,
|
||||
* CREATE_FAIL_TRY_LATER for Id sign key not avail (but requested)
|
||||
*/
|
||||
int createMessage(RsNxsMsg* msg);
|
||||
|
||||
private:
|
||||
/*!
|
||||
* convenience function to create sign
|
||||
* @param signSet signatures are stored here
|
||||
|
@ -890,10 +891,10 @@ private:
|
|||
time_t mLastCheck;
|
||||
RsGxsIntegrityCheck* mIntegrityCheck;
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
enum CreateStatus { CREATE_FAIL, CREATE_SUCCESS, CREATE_FAIL_TRY_LATER };
|
||||
const uint8_t SIGN_MAX_WAITING_TIME;
|
||||
// TODO: cleanup this should be an enum!
|
||||
const uint8_t CREATE_FAIL, CREATE_SUCCESS, CREATE_FAIL_TRY_LATER, SIGN_MAX_WAITING_TIME;
|
||||
const uint8_t SIGN_FAIL, SIGN_SUCCESS, SIGN_FAIL_TRY_LATER;
|
||||
const uint8_t VALIDATE_FAIL, VALIDATE_SUCCESS, VALIDATE_FAIL_TRY_LATER, VALIDATE_MAX_WAITING_TIME;
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ typedef PGPIdType RsPgpId;
|
|||
class RsGixs
|
||||
{
|
||||
public:
|
||||
|
||||
// TODO: cleanup this should be an enum!
|
||||
static const uint32_t RS_GIXS_ERROR_NO_ERROR = 0x0000 ;
|
||||
static const uint32_t RS_GIXS_ERROR_UNKNOWN = 0x0001 ;
|
||||
static const uint32_t RS_GIXS_ERROR_KEY_NOT_AVAILABLE = 0x0002 ;
|
||||
|
@ -119,8 +119,17 @@ public:
|
|||
virtual bool signData(const uint8_t *data,uint32_t data_size,const RsGxsId& signer_id,RsTlvKeySignature& signature,uint32_t& signing_error) = 0 ;
|
||||
virtual bool validateData(const uint8_t *data,uint32_t data_size,const RsTlvKeySignature& signature,bool force_load,const RsIdentityUsage& info,uint32_t& signing_error) = 0 ;
|
||||
|
||||
virtual bool encryptData(const uint8_t *clear_data,uint32_t clear_data_size,uint8_t *& encrypted_data,uint32_t& encrypted_data_size,const RsGxsId& encryption_key_id,bool force_load,uint32_t& encryption_error) = 0 ;
|
||||
virtual bool decryptData(const uint8_t *encrypted_data,uint32_t encrypted_data_size,uint8_t *& clear_data,uint32_t& clear_data_size,const RsGxsId& encryption_key_id,uint32_t& encryption_error) = 0 ;
|
||||
virtual bool encryptData( const uint8_t *clear_data,
|
||||
uint32_t clear_data_size,
|
||||
uint8_t *& encrypted_data,
|
||||
uint32_t& encrypted_data_size,
|
||||
const RsGxsId& encryption_key_id,
|
||||
uint32_t& encryption_error, bool force_load) = 0 ;
|
||||
virtual bool decryptData( const uint8_t *encrypted_data,
|
||||
uint32_t encrypted_data_size,
|
||||
uint8_t *& clear_data, uint32_t& clear_data_size,
|
||||
const RsGxsId& encryption_key_id,
|
||||
uint32_t& encryption_error, bool force_load) = 0 ;
|
||||
|
||||
virtual bool getOwnIds(std::list<RsGxsId>& ids) = 0;
|
||||
virtual bool isOwnId(const RsGxsId& key_id) = 0 ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue