updated values for min/normal partial packet size to 1MB, so that we do not create partial packets for everyday use. We will have to properly extend openpgp-sdk to support parsing of partial packets if we want to PGP-encrypt chunks larger than 1MB.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6553 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-08-04 12:44:57 +00:00
parent ab68f1d123
commit c34ede4b1c
5 changed files with 26 additions and 9 deletions

View File

@ -299,6 +299,10 @@ int main(int argc,char *argv[])
PGPIdType key_id(key_id_string) ;
std::string outfile = "crypted_toto.pgp" ;
std::string text_to_encrypt = "this is a secret message" ;
std::string text = "fhdsjfhskfhdsjhfskhfkdsfskfhsdhdsj" ;
for(int i=0;i<2;++i)
text_to_encrypt += text ;
std::cerr << "Checking encrypted file creation: streaming chain \"" << text_to_encrypt << "\" to file " << outfile << " with key " << key_id.toStdString() << std::endl;
@ -333,7 +337,7 @@ int main(int argc,char *argv[])
if(key_id_string.empty())
key_id_string = askForKeyId(pgph) ;
static const int MEM_TO_ENCRYPT_SIZE = 10000 ;
static const int MEM_TO_ENCRYPT_SIZE = 20000 ;
PGPIdType key_id(key_id_string) ;
@ -353,6 +357,11 @@ int main(int argc,char *argv[])
CHECK(res) ;
// dump to a file
FILE *f = fopen("crypted_toto.bin","w") ;
fwrite(encrypted_mem_block,encrypted_mem_size,1,f) ;
fclose(f) ;
if(!res)
std::cerr << "Encryption failed" << std::endl;
else
@ -368,10 +377,10 @@ int main(int argc,char *argv[])
CHECK(res) ;
if(!res)
std::cerr << "Decryption failed" << std::endl;
else
if(res && decrypted_mem_size == MEM_TO_ENCRYPT_SIZE)
std::cerr << "Decryption success" << std::endl;
else
std::cerr << "Decryption failed" << std::endl;
Sha1CheckSum decrypted_sha1 = RsDirUtil::sha1sum(decrypted_mem,decrypted_mem_size) ;

View File

@ -26,6 +26,16 @@
#include "types.h"
#include "writer.h"
// (Cyril) Originally 2048. But for the moment openpgp-sdk cannot read partial packets, so in order
// to allow to PGP-encrypt messages of reasonnable size, I had to turn it into larger value.
//
#define PARTIAL_PACKET_SIZE 1048576
// (Cyril) Originally 512. But for the moment openpgp-sdk cannot read partial packets, so in order
// to allow to PGP-encrypt messages of reasonnable size, I had to turn it into larger value.
//
#define MIN_PARTIAL_DATA_LENGTH 1048576
/**
* Function that writes out a packet header. See
* ops_writer_push_partial

View File

@ -34,7 +34,7 @@
#include <openpgpsdk/literal.h>
#include <openpgpsdk/partial.h>
#define MIN_PARTIAL_DATA_LENGTH 512
//#define MIN_PARTIAL_DATA_LENGTH 512 // now defined in partial.h
#define MAX_PARTIAL_DATA_LENGTH 1073741824

View File

@ -40,8 +40,6 @@
static const int debug = 0;
#define PACKET_SIZE 2048
#define MIN_PARTIAL_DATA_LENGTH 512
#define MAX_PARTIAL_DATA_LENGTH 1073741824
typedef struct
@ -349,7 +347,7 @@ void ops_writer_push_partial_with_trailer(
void *trailer_data)
{
if (packet_size == 0)
packet_size = PACKET_SIZE;
packet_size = MIN_PARTIAL_DATA_LENGTH;
assert(packet_size >= MIN_PARTIAL_DATA_LENGTH);
// Verify that the packet size is a valid power of 2.
assert(ops_calc_partial_data_length(packet_size) == packet_size);

View File

@ -118,7 +118,7 @@ void ops_writer_push_stream_encrypt_se_ip(ops_create_info_t *cinfo,
// This is a streaming writer, so we don't know the length in
// advance. Use a partial writer to handle the partial body
// packet lengths.
ops_writer_push_partial(2048, cinfo, OPS_PTAG_CT_SE_IP_DATA,
ops_writer_push_partial(PARTIAL_PACKET_SIZE, cinfo, OPS_PTAG_CT_SE_IP_DATA,
write_encrypt_se_ip_header, arg);
// And push encryption writer on stack