mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
Added RsTlvKeySignatureSet to rstlvkeys
- added test to test/serialiser - Updated all relevant gxs test (ran whole suite, added gxsdata_test, tests meta serilisation, to pro file) Updated flag in rsgxsflags to account for authentication and private types Changed msgId/grpId generation to sha1 hash removed photoservice VEG file from pro file git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5630 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b06214b779
commit
19e856c2a8
@ -48,7 +48,7 @@ RSA *GxsSecurity::extractPublicKey(RsTlvSecurityKey& key)
|
||||
}
|
||||
|
||||
|
||||
bool GxsSecurity::validateNxsMsg(RsNxsMsg *msg)
|
||||
bool GxsSecurity::validateNxsMsg(RsNxsMsg *msg, RsGxsGrpMetaData *grpMeta)
|
||||
{
|
||||
|
||||
return false;
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
* @param msg
|
||||
* @return false if verfication of signature is not passed
|
||||
*/
|
||||
static bool validateNxsMsg(RsNxsMsg *msg);
|
||||
static bool validateNxsMsg(RsNxsMsg *msg, RsGxsGrpMetaData* grpMeta);
|
||||
};
|
||||
|
||||
#endif // GXSSECURITY_H
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define KEY_NXS_IDENTITY std::string("identity")
|
||||
#define KEY_GRP_ID std::string("grpId")
|
||||
#define KEY_ORIG_GRP_ID std::string("origGrpId")
|
||||
#define KEY_IDENTITY_SIGN std::string("idSign")
|
||||
#define KEY_SIGN_SET std::string("signSet")
|
||||
#define KEY_TIME_STAMP std::string("timeStamp")
|
||||
#define KEY_NXS_FLAGS std::string("flags")
|
||||
#define KEY_NXS_META std::string("meta")
|
||||
@ -48,7 +48,6 @@
|
||||
|
||||
|
||||
// grp table columns
|
||||
#define KEY_ADMIN_SIGN std::string("adminSign")
|
||||
#define KEY_KEY_SET std::string("keySet")
|
||||
#define KEY_GRP_NAME std::string("grpName")
|
||||
#define KEY_GRP_SIGN_FLAGS std::string("signFlags")
|
||||
@ -62,7 +61,6 @@
|
||||
|
||||
|
||||
// msg table columns
|
||||
#define KEY_PUBLISH_SIGN std::string("publishSign")
|
||||
#define KEY_MSG_ID std::string("msgId")
|
||||
#define KEY_ORIG_MSG_ID std::string("origMsgId")
|
||||
#define KEY_MSG_PARENT_ID std::string("parentId")
|
||||
@ -90,34 +88,32 @@
|
||||
|
||||
// grp col numbers
|
||||
|
||||
#define COL_ADMIN_SIGN 5
|
||||
#define COL_KEY_SET 6
|
||||
#define COL_GRP_SUBCR_FLAG 7
|
||||
#define COL_GRP_POP 8
|
||||
#define COL_MSG_COUNT 9
|
||||
#define COL_GRP_STATUS 10
|
||||
#define COL_GRP_NAME 11
|
||||
#define COL_GRP_LAST_POST 12
|
||||
#define COL_ORIG_GRP_ID 13
|
||||
#define COL_GRP_SERV_STRING 14
|
||||
#define COL_GRP_SIGN_FLAGS 15
|
||||
#define COL_KEY_SET 5
|
||||
#define COL_GRP_SUBCR_FLAG 6
|
||||
#define COL_GRP_POP 7
|
||||
#define COL_MSG_COUNT 8
|
||||
#define COL_GRP_STATUS 9
|
||||
#define COL_GRP_NAME 10
|
||||
#define COL_GRP_LAST_POST 11
|
||||
#define COL_ORIG_GRP_ID 12
|
||||
#define COL_GRP_SERV_STRING 13
|
||||
#define COL_GRP_SIGN_FLAGS 14
|
||||
|
||||
// msg col numbers
|
||||
#define COL_PUBLISH_SIGN 5
|
||||
#define COL_MSG_ID 6
|
||||
#define COL_ORIG_MSG_ID 7
|
||||
#define COL_MSG_STATUS 8
|
||||
#define COL_CHILD_TS 9
|
||||
#define COL_PARENT_ID 10
|
||||
#define COL_THREAD_ID 11
|
||||
#define COL_MSG_NAME 12
|
||||
#define COL_MSG_SERV_STRING 13
|
||||
#define COL_MSG_ID 5
|
||||
#define COL_ORIG_MSG_ID 6
|
||||
#define COL_MSG_STATUS 7
|
||||
#define COL_CHILD_TS 8
|
||||
#define COL_PARENT_ID 9
|
||||
#define COL_THREAD_ID 10
|
||||
#define COL_MSG_NAME 11
|
||||
#define COL_MSG_SERV_STRING 12
|
||||
|
||||
// generic meta shared col numbers
|
||||
#define COL_GRP_ID 0
|
||||
#define COL_TIME_STAMP 1
|
||||
#define COL_NXS_FLAGS 2
|
||||
#define COL_IDENTITY_SIGN 3
|
||||
#define COL_SIGN_SET 3
|
||||
#define COL_IDENTITY 4
|
||||
|
||||
#define RS_DATA_SERVICE_DEBUG
|
||||
@ -138,7 +134,7 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
|
||||
// for retrieving msg meta
|
||||
msgMetaColumns.push_back(KEY_GRP_ID); msgMetaColumns.push_back(KEY_TIME_STAMP); msgMetaColumns.push_back(KEY_NXS_FLAGS);
|
||||
msgMetaColumns.push_back(KEY_IDENTITY_SIGN); msgMetaColumns.push_back(KEY_NXS_IDENTITY); msgMetaColumns.push_back(KEY_PUBLISH_SIGN);
|
||||
msgMetaColumns.push_back(KEY_SIGN_SET); msgMetaColumns.push_back(KEY_NXS_IDENTITY);
|
||||
msgMetaColumns.push_back(KEY_MSG_ID); msgMetaColumns.push_back(KEY_ORIG_MSG_ID); msgMetaColumns.push_back(KEY_MSG_STATUS);
|
||||
msgMetaColumns.push_back(KEY_CHILD_TS); msgMetaColumns.push_back(KEY_MSG_PARENT_ID); msgMetaColumns.push_back(KEY_MSG_THREAD_ID);
|
||||
msgMetaColumns.push_back(KEY_MSG_NAME); msgMetaColumns.push_back(KEY_NXS_SERV_STRING);
|
||||
@ -149,7 +145,7 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
|
||||
// for retrieving grp meta data
|
||||
grpMetaColumns.push_back(KEY_GRP_ID); grpMetaColumns.push_back(KEY_TIME_STAMP); grpMetaColumns.push_back(KEY_NXS_FLAGS);
|
||||
grpMetaColumns.push_back(KEY_IDENTITY_SIGN); grpMetaColumns.push_back(KEY_NXS_IDENTITY); grpMetaColumns.push_back(KEY_ADMIN_SIGN);
|
||||
grpMetaColumns.push_back(KEY_SIGN_SET); grpMetaColumns.push_back(KEY_NXS_IDENTITY);
|
||||
grpMetaColumns.push_back(KEY_KEY_SET); grpMetaColumns.push_back(KEY_GRP_SUBCR_FLAG); grpMetaColumns.push_back(KEY_GRP_POP);
|
||||
grpMetaColumns.push_back(KEY_MSG_COUNT); grpMetaColumns.push_back(KEY_GRP_STATUS); grpMetaColumns.push_back(KEY_GRP_NAME);
|
||||
grpMetaColumns.push_back(KEY_GRP_LAST_POST); grpMetaColumns.push_back(KEY_ORIG_GRP_ID); grpMetaColumns.push_back(KEY_NXS_SERV_STRING);
|
||||
@ -177,9 +173,8 @@ void RsDataService::initialise(){
|
||||
KEY_NXS_FLAGS + " INT," +
|
||||
KEY_ORIG_MSG_ID + " TEXT," +
|
||||
KEY_TIME_STAMP + " INT," +
|
||||
KEY_PUBLISH_SIGN + " BLOB," +
|
||||
KEY_NXS_IDENTITY + " TEXT," +
|
||||
KEY_IDENTITY_SIGN + " BLOB," +
|
||||
KEY_SIGN_SET + " BLOB," +
|
||||
KEY_NXS_FILE + " TEXT,"+
|
||||
KEY_NXS_FILE_OFFSET + " INT," +
|
||||
KEY_MSG_STATUS + " INT," +
|
||||
@ -195,7 +190,6 @@ void RsDataService::initialise(){
|
||||
mDb->execSQL("CREATE TABLE " + GRP_TABLE_NAME + "(" +
|
||||
KEY_GRP_ID + " TEXT," +
|
||||
KEY_TIME_STAMP + " INT," +
|
||||
KEY_ADMIN_SIGN + " BLOB," + " BLOB," +
|
||||
KEY_NXS_FILE + " TEXT," +
|
||||
KEY_NXS_FILE_OFFSET + " INT," +
|
||||
KEY_KEY_SET + " BLOB," +
|
||||
@ -212,7 +206,7 @@ void RsDataService::initialise(){
|
||||
KEY_NXS_SERV_STRING + " TEXT," +
|
||||
KEY_NXS_FLAGS + " INT," +
|
||||
KEY_GRP_SIGN_FLAGS + " INT," +
|
||||
KEY_IDENTITY_SIGN + " BLOB);");
|
||||
KEY_SIGN_SET + " BLOB);");
|
||||
|
||||
}
|
||||
|
||||
@ -243,18 +237,7 @@ RsGxsGrpMetaData* RsDataService::getGrpMeta(RetroCursor &c)
|
||||
grpMeta->mPublishTs = c.getInt32(COL_TIME_STAMP);
|
||||
grpMeta->mGroupFlags = c.getInt32(COL_NXS_FLAGS);
|
||||
|
||||
// identity if any
|
||||
if(!grpMeta->mAuthorId.empty() && ok){
|
||||
offset = 0;
|
||||
data = (char*)c.getData(COL_IDENTITY_SIGN, data_len);
|
||||
if(data)
|
||||
grpMeta->idSign.GetTlv(data, data_len, &offset);
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
data = (char*)c.getData(COL_ADMIN_SIGN, data_len);
|
||||
if(data)
|
||||
grpMeta->adminSign.GetTlv(data, data_len, &offset);
|
||||
|
||||
|
||||
offset = 0; data = NULL; data_len = 0;
|
||||
@ -355,25 +338,16 @@ RsGxsMsgMetaData* RsDataService::getMsgMeta(RetroCursor &c)
|
||||
c.getString(COL_MSG_NAME, msgMeta->mMsgName);
|
||||
c.getString(COL_MSG_SERV_STRING, msgMeta->mServiceString);
|
||||
|
||||
if(!msgMeta->mAuthorId.empty()){
|
||||
offset = 0;
|
||||
data = (char*)c.getData(COL_IDENTITY_SIGN, data_len);
|
||||
msgMeta->idSign.GetTlv(data, data_len, &offset);
|
||||
}
|
||||
offset = 0;
|
||||
data = (char*)c.getData(COL_SIGN_SET, data_len);
|
||||
msgMeta->signSet.GetTlv(data, data_len, &offset);
|
||||
|
||||
|
||||
msgMeta->mMsgFlags = c.getInt32(COL_NXS_FLAGS);
|
||||
msgMeta->mPublishTs = c.getInt32(COL_TIME_STAMP);
|
||||
|
||||
offset = 0; data_len = 0;
|
||||
|
||||
if(ok){
|
||||
|
||||
data = (char*)c.getData(COL_PUBLISH_SIGN, data_len);
|
||||
if(data)
|
||||
msgMeta->pubSign.GetTlv(data, data_len, &offset);
|
||||
|
||||
}
|
||||
|
||||
// thread and parent id
|
||||
c.getString(COL_THREAD_ID, msgMeta->mThreadId);
|
||||
c.getString(COL_PARENT_ID, msgMeta->mParentId);
|
||||
@ -467,20 +441,15 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
|
||||
cv.put(KEY_MSG_ID, msgMetaPtr->mMsgId);
|
||||
cv.put(KEY_GRP_ID, msgMetaPtr->mGroupId);
|
||||
cv.put(KEY_NXS_SERV_STRING, msgMetaPtr->mServiceString);
|
||||
char pubSignData[msgMetaPtr->pubSign.TlvSize()];
|
||||
|
||||
|
||||
char signSetData[msgMetaPtr->signSet.TlvSize()];
|
||||
offset = 0;
|
||||
msgMetaPtr->pubSign.SetTlv(pubSignData, msgMetaPtr->pubSign.TlvSize(), &offset);
|
||||
cv.put(KEY_PUBLISH_SIGN, msgMetaPtr->pubSign.TlvSize(), pubSignData);
|
||||
msgMetaPtr->signSet.SetTlv(signSetData, msgMetaPtr->signSet.TlvSize(), &offset);
|
||||
cv.put(KEY_SIGN_SET, msgMetaPtr->signSet.TlvSize(), signSetData);
|
||||
cv.put(KEY_NXS_IDENTITY, msgMetaPtr->mAuthorId);
|
||||
|
||||
|
||||
if(! (msgMetaPtr->mAuthorId.empty()) ){
|
||||
char idSignData[msgMetaPtr->idSign.TlvSize()];
|
||||
offset = 0;
|
||||
msgMetaPtr->idSign.SetTlv(idSignData, msgMetaPtr->idSign.TlvSize(), &offset);
|
||||
cv.put(KEY_IDENTITY_SIGN, msgMetaPtr->idSign.TlvSize(), idSignData);
|
||||
cv.put(KEY_NXS_IDENTITY, msgMetaPtr->mAuthorId);
|
||||
}
|
||||
|
||||
cv.put(KEY_NXS_FLAGS, (int32_t) msgMetaPtr->mMsgFlags);
|
||||
cv.put(KEY_TIME_STAMP, (int32_t) msgMetaPtr->mPublishTs);
|
||||
|
||||
@ -562,20 +531,8 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
|
||||
if(! (grpMetaPtr->mAuthorId.empty()) ){
|
||||
cv.put(KEY_NXS_IDENTITY, grpMetaPtr->mAuthorId);
|
||||
|
||||
char idSignData[grpMetaPtr->idSign.TlvSize()];
|
||||
offset = 0;
|
||||
grpMetaPtr->idSign.SetTlv(idSignData, grpMetaPtr->idSign.TlvSize(), &offset);
|
||||
cv.put(KEY_IDENTITY_SIGN, grpMetaPtr->idSign.TlvSize(), idSignData);
|
||||
std::string wat(idSignData, grpMetaPtr->idSign.TlvSize());
|
||||
std::cerr << wat << std::endl;
|
||||
}
|
||||
|
||||
char adminSignData[grpMetaPtr->adminSign.TlvSize()];
|
||||
offset = 0;
|
||||
grpMetaPtr->adminSign.SetTlv(adminSignData, grpMetaPtr->adminSign.TlvSize(), &offset);
|
||||
cv.put(KEY_ADMIN_SIGN, grpMetaPtr->adminSign.TlvSize(), adminSignData);
|
||||
|
||||
offset = 0;
|
||||
char keySetData[grpMetaPtr->keys.TlvSize()];
|
||||
grpMetaPtr->keys.SetTlv(keySetData, grpMetaPtr->keys.TlvSize(), &offset);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
#include "pqi/pqihash.h"
|
||||
#include "rsgenexchange.h"
|
||||
#include "gxssecurity.h"
|
||||
#include "util/contentvalue.h"
|
||||
@ -166,7 +167,11 @@ void RsGenExchange::createGroup(RsNxsGrp *grp)
|
||||
meta->keys.keys[pubKey.keyId] = pubKey;
|
||||
meta->keys.keys[privPubKey.keyId] = privPubKey;
|
||||
|
||||
meta->mGroupId = adminKey.keyId;
|
||||
pqihash hash;
|
||||
|
||||
// get hash of msg data to create msg id
|
||||
hash.addData(grp->grp.bin_data, grp->grp.bin_len);
|
||||
hash.Complete(meta->mGroupId);
|
||||
grp->grpId = meta->mGroupId;
|
||||
|
||||
adminKey.TlvClear();
|
||||
@ -235,11 +240,19 @@ bool RsGenExchange::createMessage(RsNxsMsg* msg)
|
||||
unsigned char sigbuf[siglen];
|
||||
ok = EVP_SignFinal(mdctx, sigbuf, &siglen, key_pub) == 1;
|
||||
|
||||
//place signature in msg meta
|
||||
RsGxsMsgMetaData &meta = *(msg->metaData);
|
||||
meta.pubSign.signData.setBinData(sigbuf, siglen);
|
||||
meta.pubSign.keyId = pubKey->keyId;
|
||||
RsTlvKeySignatureSet& signSet = meta.signSet;
|
||||
RsTlvKeySignature pubSign = signSet.keySignSet[GXS_SERV::FLAG_AUTHEN_PUBLISH];
|
||||
pubSign.signData.setBinData(sigbuf, siglen);
|
||||
pubSign.keyId = pubKey->keyId;
|
||||
|
||||
msg->metaData->mMsgId = msg->msgId = GxsSecurity::getBinDataSign(sigbuf, siglen);
|
||||
// get hash of msg data to create msg id
|
||||
pqihash hash;
|
||||
hash.addData(msg->msg.bin_data, msg->msg.bin_len);
|
||||
hash.Complete(msg->msgId);
|
||||
|
||||
msg->metaData->mMsgId = msg->msgId;
|
||||
|
||||
// clean up
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
|
@ -44,10 +44,9 @@ uint32_t RsGxsGrpMetaData::serial_size()
|
||||
s += 4;
|
||||
s += GetTlvStringSize(mAuthorId);
|
||||
s += GetTlvStringSize(mServiceString);
|
||||
|
||||
s += adminSign.TlvSize();
|
||||
s += signSet.TlvSize();
|
||||
s += keys.TlvSize();
|
||||
s += idSign.TlvSize();
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -66,10 +65,9 @@ void RsGxsGrpMetaData::clear(){
|
||||
mGroupStatus = 0;
|
||||
mLastPost = 0;
|
||||
mSubscribeFlags = 0;
|
||||
|
||||
adminSign.TlvClear();
|
||||
signSet.TlvClear();
|
||||
keys.TlvClear();
|
||||
idSign.TlvClear();
|
||||
|
||||
}
|
||||
|
||||
bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
||||
@ -103,10 +101,9 @@ bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mPublishTs);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 0, mAuthorId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 0, mServiceString);
|
||||
|
||||
ok &= adminSign.SetTlv(data, tlvsize, &offset);
|
||||
ok &= signSet.SetTlv(data, tlvsize, &offset);
|
||||
ok &= keys.SetTlv(data, tlvsize, &offset);
|
||||
ok &= idSign.SetTlv(data, tlvsize, &offset);
|
||||
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -130,10 +127,9 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mPublishTs);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mAuthorId);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mServiceString);
|
||||
|
||||
ok &= adminSign.GetTlv(data, pktsize, &offset);
|
||||
ok &= signSet.GetTlv(data, pktsize, &offset);
|
||||
ok &= keys.GetTlv(data, pktsize, &offset);
|
||||
ok &= idSign.GetTlv(data, pktsize, &offset);
|
||||
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -155,8 +151,7 @@ uint32_t RsGxsMsgMetaData::serial_size()
|
||||
s += GetTlvStringSize(mAuthorId);
|
||||
s += GetTlvStringSize(mServiceString);
|
||||
|
||||
s += pubSign.TlvSize();
|
||||
s += idSign.TlvSize();
|
||||
s += signSet.TlvSize();
|
||||
s += GetTlvStringSize(mMsgName);
|
||||
s += 4;
|
||||
s += 4;
|
||||
@ -175,9 +170,7 @@ void RsGxsMsgMetaData::clear()
|
||||
mMsgName.clear();
|
||||
mServiceString.clear();
|
||||
|
||||
pubSign.TlvClear();
|
||||
idSign.TlvClear();
|
||||
|
||||
signSet.TlvClear();
|
||||
mPublishTs = 0;
|
||||
mMsgFlags = 0;
|
||||
mMsgStatus = 0;
|
||||
@ -215,8 +208,7 @@ bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
|
||||
ok &= SetTlvString(data, *size, &offset, 0, mAuthorId);
|
||||
ok &= SetTlvString(data, *size, &offset, 0, mServiceString);
|
||||
|
||||
ok &= pubSign.SetTlv(data, *size, &offset);
|
||||
ok &= idSign.SetTlv(data, *size, &offset);
|
||||
ok &= signSet.SetTlv(data, *size, &offset);
|
||||
ok &= SetTlvString(data, *size, &offset, 0, mMsgName);
|
||||
ok &= setRawUInt32(data, *size, &offset, mPublishTs);
|
||||
ok &= setRawUInt32(data, *size, &offset, mMsgFlags);
|
||||
@ -244,8 +236,7 @@ bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size)
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mAuthorId);
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mServiceString);
|
||||
|
||||
ok &= pubSign.GetTlv(data, *size, &offset);
|
||||
ok &= idSign.GetTlv(data, *size, &offset);
|
||||
ok &= signSet.GetTlv(data, *size, &offset);
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mMsgName);
|
||||
uint32_t t;
|
||||
ok &= getRawUInt32(data, *size, &offset, &t);
|
||||
|
@ -60,9 +60,8 @@ public:
|
||||
std::string mAuthorId;
|
||||
|
||||
|
||||
RsTlvKeySignature adminSign;
|
||||
RsTlvKeySignatureSet signSet;
|
||||
RsTlvSecurityKeySet keys;
|
||||
RsTlvKeySignature idSign;
|
||||
|
||||
std::string mServiceString;
|
||||
|
||||
@ -100,8 +99,7 @@ public:
|
||||
RsGxsMessageId mOrigMsgId;
|
||||
std::string mAuthorId;
|
||||
|
||||
RsTlvKeySignature pubSign;
|
||||
RsTlvKeySignature idSign;
|
||||
RsTlvKeySignatureSet signSet;
|
||||
|
||||
std::string mServiceString;
|
||||
|
||||
|
@ -8,56 +8,51 @@
|
||||
namespace GXS_SERV {
|
||||
|
||||
|
||||
/*** GROUP FLAGS ***/
|
||||
|
||||
/* type of group */
|
||||
/** privacy **/
|
||||
|
||||
static const uint32_t FLAG_GRP_TYPE_MASK = 0;
|
||||
static const uint32_t FLAG_PRIVACY_MASK = 0x0000000f;
|
||||
|
||||
// pub key encrypted
|
||||
static const uint32_t FLAG_GRP_TYPE_PRIVATE = 0;
|
||||
static const uint32_t FLAG_PRIVACY_PRIVATE = 0x00000001;
|
||||
|
||||
// single publisher, read only
|
||||
static const uint32_t FLAG_GRP_TYPE_RESTRICTED = 0;
|
||||
// publish private key needed to publish
|
||||
static const uint32_t FLAG_PRIVACY_RESTRICTED = 0x00000002;
|
||||
|
||||
// anyone can publish
|
||||
static const uint32_t FLAG_GRP_TYPE_PUBLIC = 0;
|
||||
// anyone can publish, publish key pair not needed
|
||||
static const uint32_t FLAG_PRIVACY_PUBLIC = 0x00000004;
|
||||
|
||||
/** privacy **/
|
||||
|
||||
/* type of msgs allowed */
|
||||
/** authentication **/
|
||||
|
||||
static const uint32_t FLAG_MSG_TYPE_MASK = 0;
|
||||
static const uint32_t FLAG_AUTHEN_MASK = 0x000000f0;
|
||||
|
||||
// only signee can edit, and sign required
|
||||
static const uint32_t FLAG_MSG_TYPE_SIGNED = 0;
|
||||
// identity
|
||||
static const uint32_t FLAG_AUTHEN_IDENTITY = 0x000000010;
|
||||
|
||||
// no sign required, but signee can edit if signed
|
||||
static const uint32_t FLAG_MSG_TYPE_ANON = 0;
|
||||
// publish key
|
||||
static const uint32_t FLAG_AUTHEN_PUBLISH = 0x000000020;
|
||||
|
||||
// anyone can mod but sign must be provided (needed for wikis)
|
||||
static const uint32_t FLAG_MSG_TYPE_SIGNED_SHARED = 0;
|
||||
// admin key
|
||||
static const uint32_t FLAG_AUTHEN_ADMIN = 0x00000040;
|
||||
|
||||
/*** GROUP FLAGS ***/
|
||||
// pgp sign identity
|
||||
static const uint32_t FLAG_AUTHEN_PGP_IDENTITY = 0x00000080;
|
||||
|
||||
|
||||
|
||||
/*** MESSAGE FLAGS ***/
|
||||
|
||||
// indicates message edits an existing message
|
||||
static const uint32_t FLAG_MSG_EDIT = 0;
|
||||
|
||||
// indicates msg is id signed
|
||||
static const uint32_t FLAG_MSG_ID_SIGNED = 0;
|
||||
|
||||
/*** MESSAGE FLAGS ***/
|
||||
/** authentication **/
|
||||
|
||||
|
||||
// Subscription Flags. (LOCAL)
|
||||
|
||||
static const uint32_t GROUP_SUBSCRIBE_ADMIN = 0x00000001;
|
||||
|
||||
static const uint32_t GROUP_SUBSCRIBE_PUBLISH = 0x00000002;
|
||||
|
||||
static const uint32_t GROUP_SUBSCRIBE_SUBSCRIBED = 0x00000004;
|
||||
static const uint32_t GROUP_SUBSCRIBE_MONITOR = 0x00000008;
|
||||
|
||||
static const uint32_t GROUP_SUBSCRIBE_NOT_SUBSCRIBED = 0x00000008;
|
||||
|
||||
static const uint32_t GROUP_SUBSCRIBE_MASK = 0x0000000f;
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ CONFIG += test_voip
|
||||
|
||||
# GXS Stuff.
|
||||
CONFIG += newcache
|
||||
#CONFIG += newservices
|
||||
CONFIG += newservices
|
||||
|
||||
# Beware: All data of the stripped services are lost
|
||||
DEFINES *= PQI_DISABLE_TUNNEL
|
||||
@ -588,7 +588,7 @@ HEADERS += retroshare/rsgame.h \
|
||||
}
|
||||
|
||||
newservices {
|
||||
HEADERS += services/p3photoserviceVEG.h \
|
||||
HEADERS += services/p3photoserviceV2.h \
|
||||
retroshare/rsphotoVEG.h \
|
||||
services/p3gxsserviceVEG.h \
|
||||
retroshare/rsidentityVEG.h \
|
||||
@ -600,15 +600,12 @@ HEADERS += retroshare/rsgame.h \
|
||||
retroshare/rsforumsVEG.h \
|
||||
services/p3forumsVEG.h \
|
||||
retroshare/rspostedVEG.h \
|
||||
services/p3postedVEG.h \
|
||||
services/p3photoserviceV2VEG.h \
|
||||
retroshare/rsphotoVEG.h
|
||||
services/p3postedVEG.h
|
||||
|
||||
# Do I need this?
|
||||
#serialiser/rsphotoitemsVEG.h \
|
||||
|
||||
SOURCES += services/p3photoserviceVEG.cc \
|
||||
services/p3gxsserviceVEG.cc \
|
||||
SOURCES += services/p3gxsserviceVEG.cc \
|
||||
services/p3wikiserviceVEG.cc \
|
||||
services/p3wireVEG.cc \
|
||||
services/p3idserviceVEG.cc \
|
||||
|
@ -207,6 +207,8 @@ const uint16_t TLV_TYPE_SECURITYKEY = 0x1040;
|
||||
const uint16_t TLV_TYPE_SECURITYKEYSET= 0x1041;
|
||||
|
||||
const uint16_t TLV_TYPE_KEYSIGNATURE = 0x1050;
|
||||
const uint16_t TLV_TYPE_KEYSIGNATURESET = 0x1051;
|
||||
const uint16_t TLV_TYPE_KEYSIGNATURETYPE = 0x1052;
|
||||
|
||||
const uint16_t TLV_TYPE_IMAGE = 0x1060;
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
//#define TLV_DEBUG 1
|
||||
#define TLV_DEBUG 1
|
||||
|
||||
/************************************* RsTlvSecurityKey ************************************/
|
||||
|
||||
@ -520,3 +520,170 @@ std::ostream &RsTlvKeySignature::print(std::ostream &out, uint16_t indent)
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/************************************* RsTlvKeySignatureSet ************************************/
|
||||
|
||||
RsTlvKeySignatureSet::RsTlvKeySignatureSet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::ostream &RsTlvKeySignatureSet::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printBase(out, "RsTlvKeySignatureSet", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
|
||||
std::map<SignType, RsTlvKeySignature>::iterator mit = keySignSet.begin();
|
||||
|
||||
for(; mit != keySignSet.end(); mit++)
|
||||
{
|
||||
out << "SignType: " << mit->first << std::endl;
|
||||
RsTlvKeySignature& sign = mit->second;
|
||||
sign.print(out, indent);
|
||||
}
|
||||
|
||||
out << std::endl;
|
||||
|
||||
printEnd(out, "RsTlvKeySignatureSet", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
void RsTlvKeySignatureSet::TlvClear()
|
||||
{
|
||||
keySignSet.clear();
|
||||
}
|
||||
|
||||
bool RsTlvKeySignatureSet::SetTlv(void *data, uint32_t size, uint32_t *offset)
|
||||
{
|
||||
|
||||
/* must check sizes */
|
||||
uint32_t tlvsize = TlvSize();
|
||||
uint32_t tlvend = *offset + tlvsize;
|
||||
|
||||
if (size < tlvend)
|
||||
{
|
||||
#ifdef TLV_DEBUG
|
||||
std::cerr << "RsTlvKeySignatureSet::SetTlv() Failed not enough space";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return false; /* not enough space */
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* start at data[offset] */
|
||||
ok &= SetTlvBase(data, tlvend, offset, TLV_TYPE_KEYSIGNATURESET , tlvsize);
|
||||
|
||||
|
||||
if(!keySignSet.empty())
|
||||
{
|
||||
std::map<SignType, RsTlvKeySignature>::iterator it;
|
||||
|
||||
for(it = keySignSet.begin(); it != keySignSet.end() ; ++it)
|
||||
{
|
||||
ok &= SetTlvUInt32(data, size, offset, TLV_TYPE_KEYSIGNATURETYPE, it->first);
|
||||
ok &= (it->second).SetTlv(data, size, offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RsTlvKeySignatureSet::GetTlv(void *data, uint32_t size, uint32_t *offset)
|
||||
{
|
||||
if (size < *offset + TLV_HEADER_SIZE)
|
||||
return false;
|
||||
|
||||
uint16_t tlvtype = GetTlvType( &(((uint8_t *) data)[*offset]) );
|
||||
uint32_t tlvsize = GetTlvSize( &(((uint8_t *) data)[*offset]) );
|
||||
uint32_t tlvend = *offset + tlvsize;
|
||||
|
||||
if (size < tlvend) /* check size */
|
||||
return false; /* not enough space */
|
||||
|
||||
if (tlvtype != TLV_TYPE_KEYSIGNATURESET) /* check type */
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
TlvClear();
|
||||
|
||||
/* skip the header */
|
||||
(*offset) += TLV_HEADER_SIZE;
|
||||
|
||||
SignType sign_type = 0;
|
||||
|
||||
/* while there is TLV */
|
||||
while((*offset) + 2 < tlvend)
|
||||
{
|
||||
|
||||
/* get the next type */
|
||||
uint16_t tlvsubtype = GetTlvType( &(((uint8_t *) data)[*offset]) );
|
||||
SignType currType;
|
||||
|
||||
switch(tlvsubtype)
|
||||
{
|
||||
case TLV_TYPE_KEYSIGNATURE:
|
||||
{
|
||||
RsTlvKeySignature sign;
|
||||
ok &= sign.GetTlv(data, size, offset);
|
||||
if (ok)
|
||||
{
|
||||
keySignSet[currType] = sign;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TLV_TYPE_KEYSIGNATURETYPE:
|
||||
{
|
||||
ok = GetTlvUInt32(data, size, offset, TLV_TYPE_KEYSIGNATURETYPE, &sign_type);
|
||||
|
||||
if(ok)
|
||||
currType = sign_type;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ok &= SkipUnknownTlv(data, tlvend, offset);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* NB: extra components could be added (for future expansion of the type).
|
||||
* or be present (if this code is reading an extended version).
|
||||
*
|
||||
* We must chew up the extra characters to conform with TLV specifications
|
||||
***************************************************************************/
|
||||
if (*offset != tlvend)
|
||||
{
|
||||
#ifdef TLV_DEBUG
|
||||
std::cerr << "RsTlvKeySignatureSet::GetTlv() Warning extra bytes at end of item";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
*offset = tlvend;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
uint32_t RsTlvKeySignatureSet::TlvSize()
|
||||
{
|
||||
uint32_t s = TLV_HEADER_SIZE; // header size
|
||||
std::map<SignType, RsTlvKeySignature>::iterator it;
|
||||
|
||||
for(it = keySignSet.begin(); it != keySignSet.end() ; ++it)
|
||||
{
|
||||
s += GetTlvUInt32Size(); // sign type
|
||||
s += it->second.TlvSize(); // signature
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ const uint32_t RSTLV_KEY_TYPE_SHARED = 0x0004;
|
||||
const uint32_t RSTLV_KEY_DISTRIB_PUBLIC = 0x0010;
|
||||
const uint32_t RSTLV_KEY_DISTRIB_PRIVATE = 0x0020;
|
||||
const uint32_t RSTLV_KEY_DISTRIB_ADMIN = 0x0040;
|
||||
const uint32_t RSTLV_KEY_DISTRIB_IDENTITY = 0x0080;
|
||||
|
||||
|
||||
class RsTlvSecurityKey: public RsTlvItem
|
||||
@ -98,6 +99,21 @@ virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
// NO Certificates in Signatures... add as separate data type.
|
||||
};
|
||||
|
||||
typedef uint32_t SignType;
|
||||
|
||||
class RsTlvKeySignatureSet : public RsTlvItem
|
||||
{
|
||||
public:
|
||||
RsTlvKeySignatureSet();
|
||||
virtual ~RsTlvKeySignatureSet() { return; }
|
||||
virtual uint32_t TlvSize();
|
||||
virtual void TlvClear();
|
||||
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset); /* serialise */
|
||||
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset); /* deserialise */
|
||||
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
|
||||
std::map<SignType, RsTlvKeySignature> keySignSet; // mandatory
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -88,7 +88,9 @@ p3PhotoServiceV2::p3PhotoServiceV2(RsGeneralDataService* gds, RsNetworkExchangeS
|
||||
RsGxsPhotoAlbumItem* item1 = new RsGxsPhotoAlbumItem(), *item2 = new RsGxsPhotoAlbumItem();
|
||||
|
||||
item1->meta.mGroupName = "Dummy Album 1";
|
||||
item1->album.mCaption = "Dummy 1";
|
||||
item2->meta.mGroupName = "Dummy Album 2";
|
||||
item2->album.mCaption = "Dummy 2";
|
||||
|
||||
createDummyGroup(item1);
|
||||
createDummyGroup(item2);
|
||||
|
@ -62,9 +62,8 @@ void init_item(RsGxsGrpMetaData* metaGrp)
|
||||
randString(SHORT_STR, metaGrp->mAuthorId);
|
||||
randString(SHORT_STR, metaGrp->mGroupName);
|
||||
|
||||
init_item(metaGrp->adminSign);
|
||||
init_item(metaGrp->signSet);
|
||||
init_item(metaGrp->keys);
|
||||
init_item(metaGrp->idSign);
|
||||
|
||||
metaGrp->mPublishTs = rand()%3452;
|
||||
metaGrp->mGroupFlags = rand()%43;
|
||||
@ -87,8 +86,7 @@ void init_item(RsGxsMsgMetaData* metaMsg)
|
||||
randString(SHORT_STR, metaMsg->mOrigMsgId);
|
||||
randString(SHORT_STR, metaMsg->mMsgName);
|
||||
|
||||
init_item(metaMsg->pubSign);
|
||||
init_item(metaMsg->idSign);
|
||||
init_item(metaMsg->signSet);
|
||||
|
||||
metaMsg->mPublishTs = rand()%313;
|
||||
metaMsg->mMsgFlags = rand()%224;
|
||||
|
@ -10,13 +10,14 @@ QT += core network
|
||||
|
||||
QT -= gui
|
||||
|
||||
CONFIG += dstore_target #gen_exchange_target # #nxs_net_test
|
||||
CONFIG += gen_exchange_target
|
||||
#CONFIG += nxs_net_test
|
||||
#CONFIG += dstore_target
|
||||
#CONFIG += gxsdata_target
|
||||
|
||||
|
||||
dstore_target {
|
||||
|
||||
TARGET = rs_dstore_test
|
||||
|
||||
}
|
||||
|
||||
gen_exchange_target {
|
||||
|
||||
@ -30,6 +31,12 @@ TARGET = nxs_net_test
|
||||
|
||||
}
|
||||
|
||||
gxsdata_target {
|
||||
|
||||
TARGET = gxsdata_test
|
||||
|
||||
}
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
@ -161,53 +168,66 @@ install_rs {
|
||||
binary_rs.files = ./RetroShare
|
||||
}
|
||||
|
||||
dstore_target {
|
||||
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
rsdataservice_test.cc \
|
||||
data_support.cc
|
||||
|
||||
HEADERS += support.h \
|
||||
rsdataservice_test.h \
|
||||
data_support.h
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
gen_exchange_target {
|
||||
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
genexchangetester.cpp \
|
||||
genexchangetestservice.cpp \
|
||||
rsdummyservices.cc \
|
||||
rsgenexchange_test.cc
|
||||
|
||||
HEADERS += support.h \
|
||||
rsdataservice_test.h \
|
||||
rsdummyservices.h \
|
||||
data_support.h
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
genexchangetester.cpp \
|
||||
genexchangetestservice.cpp \
|
||||
rsdummyservices.cc \
|
||||
rsgenexchange_test.cc
|
||||
|
||||
HEADERS += support.h \
|
||||
rsdataservice_test.h \
|
||||
rsdummyservices.h \
|
||||
data_support.h
|
||||
|
||||
|
||||
}
|
||||
|
||||
nxs_net_test {
|
||||
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
nxstesthub.cc \
|
||||
rsgxsnetservice_test.cc \
|
||||
nxstestscenario.cc \
|
||||
data_support.cc
|
||||
|
||||
|
||||
HEADERS += support.h \
|
||||
nxstesthub.h \
|
||||
rsgxsnetservice_test.h \
|
||||
nxstestscenario.h \
|
||||
data_support.h
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
nxstesthub.cc \
|
||||
rsgxsnetservice_test.cc \
|
||||
nxstestscenario.cc \
|
||||
data_support.cc
|
||||
|
||||
|
||||
HEADERS += support.h \
|
||||
nxstesthub.h \
|
||||
rsgxsnetservice_test.h \
|
||||
nxstestscenario.h \
|
||||
data_support.h
|
||||
}
|
||||
|
||||
|
||||
dstore_target {
|
||||
TARGET = rs_dstore_test
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
rsdataservice_test.cc \
|
||||
data_support.cc
|
||||
|
||||
HEADERS += support.h \
|
||||
rsdataservice_test.h \
|
||||
data_support.h
|
||||
|
||||
|
||||
}
|
||||
|
||||
gxsdata_target {
|
||||
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
data_support.cc \
|
||||
rsgxsdata_test.cc
|
||||
|
||||
HEADERS += \
|
||||
support.h \
|
||||
rsgxsdata_test.h
|
||||
}
|
||||
|
||||
INCLUDEPATH += ../../
|
||||
|
@ -339,8 +339,7 @@ void tearDown(){
|
||||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
{
|
||||
if(!(l.adminSign == r.adminSign)) return false;
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(!(l.keys == r.keys)) return false;
|
||||
if(l.mGroupFlags != r.mGroupFlags) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
@ -358,8 +357,7 @@ bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r)
|
||||
{
|
||||
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.pubSign == r.pubSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mParentId != r.mParentId) return false;
|
||||
|
@ -14,14 +14,14 @@ int main()
|
||||
{
|
||||
GenExchangeTester tester;
|
||||
|
||||
// CHECK(tester.testMsgSubmissionRetrieval()); REPORT("testMsgSubmissionRetrieval()");
|
||||
CHECK(tester.testMsgSubmissionRetrieval()); REPORT("testMsgSubmissionRetrieval()");
|
||||
// CHECK(tester.testSpecificMsgMetaRetrieval()); REPORT("testSpecificMsgMetaRetrieval()");
|
||||
// CHECK(tester.testMsgIdRetrieval()); REPORT("tester.testMsgIdRetrieval()");
|
||||
// CHECK(tester.testMsgIdRetrieval_OptParents()); REPORT("tester.testRelatedMsgIdRetrieval_Parents()");
|
||||
// CHECK(tester.testMsgIdRetrieval_OptOrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()");
|
||||
// CHECK(tester.testMsgIdRetrieval_OptLatest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()");
|
||||
// CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
|
||||
// CHECK(tester.testMsgChildRetrieval()); REPORT("tester.testMsgMetaModRequest()");
|
||||
CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
|
||||
CHECK(tester.testMsgChildRetrieval()); REPORT("tester.testMsgMetaModRequest()");
|
||||
|
||||
CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()");
|
||||
CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");
|
||||
|
@ -49,8 +49,7 @@ int main()
|
||||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
{
|
||||
if(!(l.adminSign == r.adminSign)) return false;
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(!(l.keys == r.keys)) return false;
|
||||
if(l.mGroupFlags != r.mGroupFlags) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
@ -64,8 +63,7 @@ bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r)
|
||||
{
|
||||
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.pubSign == r.pubSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mParentId != r.mParentId) return false;
|
||||
|
@ -103,6 +103,30 @@ bool operator==(const RsTlvSecurityKey& sk1, const RsTlvSecurityKey& sk2)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvKeySignatureSet& kss1, const RsTlvKeySignatureSet& kss2)
|
||||
{
|
||||
const std::map<SignType, RsTlvKeySignature>& set1 = kss1.keySignSet,
|
||||
&set2 = kss2.keySignSet;
|
||||
|
||||
if(set1.size() != set2.size()) return false;
|
||||
|
||||
std::map<SignType, RsTlvKeySignature>::const_iterator it1 = set1.begin(), it2;
|
||||
|
||||
for(; it1 != set1.end(); it1++)
|
||||
{
|
||||
SignType st1 = it1->first;
|
||||
|
||||
if( (it2 =set2.find(st1)) == set2.end())
|
||||
return false;
|
||||
|
||||
if(!(it1->second == it2->second))
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvKeySignature& ks1, const RsTlvKeySignature& ks2)
|
||||
{
|
||||
|
||||
@ -138,6 +162,19 @@ void init_item(RsTlvImage& im)
|
||||
return;
|
||||
}
|
||||
|
||||
void init_item(RsTlvKeySignatureSet &kss)
|
||||
{
|
||||
int numSign = rand()%21;
|
||||
|
||||
for(int i=0; i < numSign; i++)
|
||||
{
|
||||
RsTlvKeySignature sign;
|
||||
SignType sType = rand()%2452;
|
||||
init_item(sign);
|
||||
kss.keySignSet.insert(std::make_pair(sType, sign));
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvBinaryData& bd1, const RsTlvBinaryData& bd2)
|
||||
{
|
||||
if(bd1.tlvtype != bd2.tlvtype) return false;
|
||||
|
@ -56,6 +56,7 @@ void randString(const uint32_t, std::wstring&);
|
||||
|
||||
void init_item(RsTlvSecurityKey&);
|
||||
void init_item(RsTlvKeySignature&);
|
||||
void init_item(RsTlvKeySignatureSet&);
|
||||
void init_item(RsTlvBinaryData&);
|
||||
void init_item(RsTlvFileItem&);
|
||||
void init_item(RsTlvFileSet&);
|
||||
@ -74,6 +75,7 @@ bool operator==(const RsTlvHashSet&, const RsTlvHashSet&);
|
||||
bool operator==(const RsTlvImage&, const RsTlvImage& );
|
||||
bool operator==(const RsTlvPeerIdSet& , const RsTlvPeerIdSet& );
|
||||
bool operator==(const RsTlvSecurityKeySet& , const RsTlvSecurityKeySet& );
|
||||
bool operator==(const RsTlvKeySignatureSet& , const RsTlvKeySignatureSet& );
|
||||
|
||||
|
||||
|
||||
|
@ -81,6 +81,30 @@ bool operator==(const RsTlvKeySignature& ks1, const RsTlvKeySignature& ks2)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvKeySignatureSet& kss1, const RsTlvKeySignatureSet& kss2)
|
||||
{
|
||||
const std::map<SignType, RsTlvKeySignature>& set1 = kss1.keySignSet,
|
||||
&set2 = kss2.keySignSet;
|
||||
|
||||
if(set1.size() != set2.size()) return false;
|
||||
|
||||
std::map<SignType, RsTlvKeySignature>::const_iterator it1 = set1.begin(), it2;
|
||||
|
||||
for(; it1 != set1.end(); it1++)
|
||||
{
|
||||
SignType st1 = it1->first;
|
||||
|
||||
if( (it2 =set2.find(st1)) == set2.end())
|
||||
return false;
|
||||
|
||||
if(!(it1->second == it2->second))
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvPeerIdSet& pids1, const RsTlvPeerIdSet& pids2)
|
||||
{
|
||||
std::list<std::string>::const_iterator it1 = pids1.ids.begin(),
|
||||
@ -153,6 +177,18 @@ void init_item(RsTlvKeySignature& ks)
|
||||
|
||||
return;
|
||||
}
|
||||
void init_item(RsTlvKeySignatureSet &kss)
|
||||
{
|
||||
int numSign = rand()%21;
|
||||
|
||||
for(int i=0; i < numSign; i++)
|
||||
{
|
||||
RsTlvKeySignature sign;
|
||||
SignType sType = rand()%2452;
|
||||
init_item(sign);
|
||||
kss.keySignSet.insert(std::make_pair(sType, sign));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const RsTlvImage& img1, const RsTlvImage& img2)
|
||||
|
@ -56,6 +56,7 @@ void randString(const uint32_t, std::wstring&);
|
||||
|
||||
void init_item(RsTlvSecurityKey&);
|
||||
void init_item(RsTlvKeySignature&);
|
||||
void init_item(RsTlvKeySignatureSet&);
|
||||
void init_item(RsTlvBinaryData&);
|
||||
void init_item(RsTlvFileItem&);
|
||||
void init_item(RsTlvFileSet&);
|
||||
@ -72,6 +73,7 @@ bool operator==(const RsTlvFileSet&, const RsTlvFileSet& );
|
||||
bool operator==(const RsTlvHashSet&, const RsTlvHashSet&);
|
||||
bool operator==(const RsTlvImage&, const RsTlvImage& );
|
||||
bool operator==(const RsTlvPeerIdSet& , const RsTlvPeerIdSet& );
|
||||
bool operator==(const RsTlvKeySignatureSet& , const RsTlvKeySignatureSet& );
|
||||
|
||||
|
||||
|
||||
|
36
libretroshare/src/tests/serialiser/tlvkey_test.cc
Normal file
36
libretroshare/src/tests/serialiser/tlvkey_test.cc
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
#include "support.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
|
||||
INITTEST();
|
||||
|
||||
bool test_RsTlvKeySignatureSet();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_RsTlvKeySignatureSet(); REPORT("test_RsTlvKeySignatureSet()");
|
||||
|
||||
FINALREPORT("RsTlvKey Test");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool test_RsTlvKeySignatureSet()
|
||||
{
|
||||
RsTlvKeySignatureSet set;
|
||||
|
||||
init_item(set);
|
||||
|
||||
char data[set.TlvSize()];
|
||||
uint32_t offset = 0;
|
||||
set.SetTlv(data, set.TlvSize(), &offset);
|
||||
|
||||
RsTlvKeySignatureSet setConfirm;
|
||||
|
||||
offset = 0;
|
||||
setConfirm.GetTlv(data, set.TlvSize(), &offset);
|
||||
|
||||
CHECK(setConfirm == set);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user