mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 23:36:59 -05:00
fixed bug related to opening cache hist file in text mode for windows
added cleaning of cipher context to authssl encrypt decrypt functions added header to trustview which caused compilation error git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4199 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fcee4ebc32
commit
00c1bfcf54
@ -1026,6 +1026,8 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen,
|
||||
// free encrypted key data
|
||||
free(ek);
|
||||
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
|
||||
outlen = out_offset;
|
||||
|
||||
#ifdef DISTRIB_DEBUG
|
||||
@ -1052,7 +1054,8 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
||||
int eklen = 0, net_ekl = 0;
|
||||
unsigned char *ek = NULL;
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH];
|
||||
ek = (unsigned char*)malloc(EVP_PKEY_size(mOwnPrivateKey));
|
||||
int ek_mkl = EVP_PKEY_size(mOwnPrivateKey);
|
||||
ek = (unsigned char*)malloc(ek_mkl);
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
|
||||
int in_offset = 0, out_currOffset = 0;
|
||||
@ -1085,7 +1088,7 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
||||
|
||||
const EVP_CIPHER* cipher = EVP_aes_128_cbc();
|
||||
|
||||
if(!EVP_OpenInit(&ctx, cipher, ek, eklen, iv, mOwnPrivateKey)) {
|
||||
if(0 == EVP_OpenInit(&ctx, cipher, ek, eklen, iv, mOwnPrivateKey)) {
|
||||
free(ek);
|
||||
return false;
|
||||
}
|
||||
@ -1114,6 +1117,8 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
||||
if(ek != NULL)
|
||||
free(ek);
|
||||
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
std::cerr << "AuthSSLimpl::decrypt() finished with outlen : " << outlen << std::endl;
|
||||
#endif
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
#define FAILED_CACHE_CONT "failedcachegrp" // cache id which have failed are stored under a node of this name/grpid
|
||||
#define HIST_CACHE_FNAME "grp_history.xml"
|
||||
#define ENABLE_CACHE_OPT
|
||||
|
||||
/*****
|
||||
* #define DISTRIB_DEBUG 1
|
||||
@ -786,7 +787,7 @@ void p3GroupDistrib::locked_getHistoryCacheData(const std::string& grpId, std::l
|
||||
bool p3GroupDistrib::locked_loadHistoryCacheFile()
|
||||
{
|
||||
std::string hFileName = mKeyBackUpDir + "/" + HIST_CACHE_FNAME;
|
||||
std::ifstream hFile(hFileName.c_str());
|
||||
std::ifstream hFile(hFileName.c_str(), std::ios::binary | std::ios::in);
|
||||
int fileLength;
|
||||
char* fileLoadBuffer = NULL;
|
||||
char* decryptedCacheFile = NULL;
|
||||
@ -812,6 +813,7 @@ bool p3GroupDistrib::locked_loadHistoryCacheFile()
|
||||
char* buffer = static_cast<char*>(pugi::get_memory_allocation_function()(outlen));
|
||||
|
||||
if(ok){
|
||||
|
||||
memcpy(buffer, decryptedCacheFile, outlen);
|
||||
|
||||
if(decryptedCacheFile != NULL)
|
||||
@ -834,7 +836,7 @@ bool p3GroupDistrib::locked_saveHistoryCacheFile()
|
||||
return false;
|
||||
|
||||
std::string hFileName = mKeyBackUpDir + "/" + HIST_CACHE_FNAME;
|
||||
std::ofstream hFile(hFileName.c_str());
|
||||
std::ofstream hFile(hFileName.c_str(), std::ios::binary | std::ios::out);
|
||||
std::ostringstream cacheStream;
|
||||
char* fileBuffer = NULL;
|
||||
int streamLength;
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <QTableView>
|
||||
#include "TrustView.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
TrustView::TrustView()
|
||||
|
Loading…
x
Reference in New Issue
Block a user