mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 02:44:20 -05:00
made sure encrypted messages are stored in cache and signature
creation and verification done correctly in this case git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3163 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
37adbea543
commit
ba45933138
@ -631,18 +631,23 @@ void p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, std::string src, bool l
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *temp_ptr = newMsg->packet.bin_data;
|
||||||
|
int temp_len = newMsg->packet.bin_len;
|
||||||
|
|
||||||
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
|
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
|
||||||
|
|
||||||
void *out_data = NULL;
|
void *out_data = NULL;
|
||||||
int outlen = 0;
|
int out_len = 0;
|
||||||
|
|
||||||
|
if(decrypt(out_data, out_len, newMsg->packet.bin_data, newMsg->packet.bin_len, newMsg->grpId)){
|
||||||
|
newMsg->packet.TlvShallowClear();
|
||||||
|
newMsg->packet.setBinData(out_data, out_len);
|
||||||
|
delete[] (unsigned char*) out_data;
|
||||||
|
|
||||||
if(decrypt(out_data, outlen, newMsg->packet.bin_data, newMsg->packet.bin_len, newMsg->grpId)){
|
|
||||||
newMsg->packet.TlvClear();
|
|
||||||
newMsg->packet.setBinData(out_data, outlen);
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
if((out_data != NULL) && (outlen != 0))
|
if((out_data != NULL) && (out_len != 0))
|
||||||
delete[] out_data;
|
delete[] (unsigned char*) out_data;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -694,6 +699,12 @@ void p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, std::string src, bool l
|
|||||||
std::cerr << "p3GroupDistrib::loadMsg() To be Published!";
|
std::cerr << "p3GroupDistrib::loadMsg() To be Published!";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(git->second.grpFlags & RS_DISTRIB_ENCRYPTED){
|
||||||
|
newMsg->packet.TlvClear();
|
||||||
|
newMsg->packet.setBinData(temp_ptr, temp_len);
|
||||||
|
}
|
||||||
|
|
||||||
locked_toPublishMsg(newMsg);
|
locked_toPublishMsg(newMsg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2128,7 +2139,7 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
|||||||
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
|
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
|
||||||
|
|
||||||
EVP_SignInit(mdctx, EVP_sha1());
|
EVP_SignInit(mdctx, EVP_sha1());
|
||||||
EVP_SignUpdate(mdctx, out_data, size);
|
EVP_SignUpdate(mdctx, out_data, out_size);
|
||||||
|
|
||||||
unsigned int siglen = EVP_PKEY_size(publishKey);
|
unsigned int siglen = EVP_PKEY_size(publishKey);
|
||||||
unsigned char sigbuf[siglen];
|
unsigned char sigbuf[siglen];
|
||||||
@ -2142,7 +2153,7 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
|||||||
{
|
{
|
||||||
unsigned int siglen = EVP_PKEY_size(publishKey);
|
unsigned int siglen = EVP_PKEY_size(publishKey);
|
||||||
unsigned char sigbuf[siglen];
|
unsigned char sigbuf[siglen];
|
||||||
if (AuthSSL::getAuthSSL()->SignDataBin(out_data, size, sigbuf, &siglen))
|
if (AuthSSL::getAuthSSL()->SignDataBin(out_data, out_size, sigbuf, &siglen))
|
||||||
{
|
{
|
||||||
signedMsg->personalSignature.signData.setBinData(sigbuf, siglen);
|
signedMsg->personalSignature.signData.setBinData(sigbuf, siglen);
|
||||||
signedMsg->personalSignature.keyId = AuthSSL::getAuthSSL()->OwnId();
|
signedMsg->personalSignature.keyId = AuthSSL::getAuthSSL()->OwnId();
|
||||||
|
Loading…
Reference in New Issue
Block a user