Check put2 ef.Put2(data, length, -1, true); Also you cannot use a string like this in cryptopp (AFAIK) you need to use an unsigned char * (byte in this lib is unsigned char). therefore data would in fact be reinterpret_cast<char*>(pdata.data()) etc. (do not depend on implementation of char to be unsigned)
In general you could do this, but I think you need to look at cleaning up the code a little and not pass strings as cypherblock when it's only a string. I suggest getting your data into a secure container as soon as possible or at least encrypt it quickly without passing it around. Hope that helps I am rushing so cannot provide you code at the moment. The wiki has examples of put2 and read from stream functions in there. It is very good and requires a lot of study though. Best Regards David Irvine <http://maidsafe.net>maidsafe.net Limited is a limited liability company incorporated in Scotland with number SC297540. VAT Registered 889 0608 77. Registered Office: 72 Templehill, Troon, KA10 6BE. Telephone Scotland: +44 *1292 317311* On Wed, Mar 6, 2013 at 8:18 AM, matejk <[email protected]> wrote: > Dear Crypto++ users, > > I am working on a solution which included encryption of files of arbitrary > size (at least up to 2 GB) to be encrypted with AES CCM and uploaded to a > server. > > The files would need to be encrypted by blocks when uploading not to > impose a file size limit. Total size of the file can be queries before > encrypting the data. > > The examples on this mailing list and Crypto++ wiki only show hot to > encrypt the complete message in one call. Examples of AES CCM encryption > with OpenSSL are similar in that respect. > > Is it valid to encrypt large input plaintext (without AAD) block by block > like this (pseudo code)? > > CCM< AES, 8 >::Encryption e; > e.SetKeyWithIV( key, key.size(), iv, sizeof(iv) ); > > e.SpecifyDataLengths( 0, filesize, 0 ); > > std::string cipheblock; > > AuthenticatedEncryptionFilter ef( e, > new StringSink( cipherblock ) > ); // AuthenticatedEncryptionFilter > > do { > std::string pdata; > // read block of pdata here > > ef.ChannelPut( DEFAULT_CHANNEL, pdata.data(), pdata.size() ); > ef.ChannelMessageEnd(DEFAULT_CHANNEL); > > // upload cipherblock > > cipherblock.clear(); > } > > ef.MessageEnd(); > > // upload last cipherblock > > > Thank you very much for clarification. > > Best regards, > > Matej > > -- > -- > You received this message because you are subscribed to the "Crypto++ > Users" Google Group. > To unsubscribe, send an email to > [email protected]. > More information about Crypto++ and this group is available at > http://www.cryptopp.com. > --- > You received this message because you are subscribed to the Google Groups > "Crypto++ Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
