From e8c93a5639a1c096df50de11cee21e08cbd11d00 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 23 Sep 2015 18:40:55 -0400 Subject: [PATCH] started with new crypto methods for multiple peers --- libretroshare/src/gxs/gxssecurity.cc | 141 +++++++++++++++++++++++++ libretroshare/src/gxs/rsgenexchange.cc | 6 +- 2 files changed, 144 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/gxs/gxssecurity.cc b/libretroshare/src/gxs/gxssecurity.cc index edd005fd9..d6c7b99a9 100644 --- a/libretroshare/src/gxs/gxssecurity.cc +++ b/libretroshare/src/gxs/gxssecurity.cc @@ -405,6 +405,147 @@ bool GxsSecurity::validateNxsMsg(const RsNxsMsg& msg, const RsTlvKeySignature& s } bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, uint32_t inlen, const RsTlvSecurityKey& key) +{ + // encrypting for a single security key. This is a proxy function. + + return encrypt(out,outlen,in,inlen,std::vector(1,key)) ; +} + +#ifdef TODO +bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, uint32_t inlen, const std::vector& keys) +{ +#ifdef DISTRIB_DEBUG + std::cerr << "GxsSecurity::encrypt() " << std::endl; +#endif + + if(keys.empty()) + return false ; + + // prepare an array of encrypted keys ek and public keys puk + + unsigned char ** ek = new unsigned char *[keys.size()] ; + EVP_PKEY **pubk = new EVP_PKEY *[keys.size()] ; + int * ekl = new int [keys.size()] ; + + memset(ek ,0,keys.size()*sizeof(unsigned char *)) ; + memset(pubk,0,keys.size()*sizeof(EVP_PKEY *)) ; + memset(ekl ,0,keys.size()*sizeof(int )) ; + + try + { + for(uint32_t i=0;i max_outlen) + { + free(out) ; + out = NULL ; + return false; + } + + // free encrypted key data + free(ek); + + outlen = out_offset; + return true; + } + catch(std::exception& e) + { + std::cerr << "(EE) GxsSecurity::encrypt(): ERROR: " << e.what() << std::endl; + return false ; + } +} +#endif + +bool GxsSecurity::encrypt_single(uint8_t *& out, uint32_t &outlen, const uint8_t *in, uint32_t inlen, const RsTlvSecurityKey& key) { #ifdef DISTRIB_DEBUG std::cerr << "GxsSecurity::encrypt() " << std::endl; diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index accba84fc..b150211c0 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -160,7 +160,7 @@ void RsGenExchange::tick() // Meta Changes should happen first. // This is important, as services want to change Meta, then get results. // Services shouldn't rely on this ordering - but some do. - processGrpMetaChanges(); + processGrpMetaChanges(); processMsgMetaChanges(); mDataAccess->processRequests(); @@ -173,9 +173,9 @@ void RsGenExchange::tick() processGroupDelete(); - processRecvdData(); + processRecvdData(); - processRoutingClues() ; + processRoutingClues() ; if(!mNotifications.empty()) {