fixed bug that would erase private publish key when a group update is received

This commit is contained in:
csoler 2018-02-28 22:40:04 +01:00
parent 165b241341
commit 29ab0e9913
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 13 additions and 2 deletions

View File

@ -2580,7 +2580,11 @@ void RsGenExchange::publishGrps()
ggps.mKeys = fullKeySet;
}
else
{
// We should just merge the keys instead of overwriting them, because the update may not contain private parts.
fullKeySet = ggps.mKeys;
}
// find private admin key
RsTlvPrivateRSAKey privAdminKey;
@ -3216,6 +3220,13 @@ void RsGenExchange::performUpdateValidation()
gu.newGrp->metaData->mSubscribeFlags = gu.oldGrpMeta->mSubscribeFlags ;
// Also keep private keys if present
if(!gu.newGrp->metaData->keys.private_keys.empty())
std::cerr << "(EE) performUpdateValidation() group " <<gu.newGrp->metaData->mGroupId << " has been received with private keys. This is very unexpected!" << std::endl;
else
gu.newGrp->metaData->keys.private_keys = gu.oldGrpMeta->keys.private_keys ;
grps.push_back(gu.newGrp);
}
else
@ -3254,7 +3265,7 @@ void RsGenExchange::performUpdateValidation()
mGroupUpdates.clear();
}
bool RsGenExchange::updateValid(const RsGxsGrpMetaData& oldGrpMeta, RsNxsGrp& newGrp) const
bool RsGenExchange::updateValid(const RsGxsGrpMetaData& oldGrpMeta, const RsNxsGrp& newGrp) const
{
std::map<SignType, RsTlvKeySignature>& signSet = newGrp.metaData->signSet.keySignSet;
std::map<SignType, RsTlvKeySignature>::iterator mit = signSet.find(INDEX_AUTHEN_ADMIN);

View File

@ -835,7 +835,7 @@ private:
* @param newGrp the new group that updates the old group (must have meta data member initialised)
* @return
*/
bool updateValid(const RsGxsGrpMetaData& oldGrp, RsNxsGrp& newGrp) const;
bool updateValid(const RsGxsGrpMetaData& oldGrp, const RsNxsGrp& newGrp) const;
/*!
* convenience function for checking private publish and admin keys are present