I wanted to write a factory method to initialize CBC_Mode<AES>::Encryption 
object like that

> CBC_Mode<AES>::Encryption GetEncryption(const SecByteBlock &key) {
>   CBC_Mode<AES>::Encryption encryption;
>   auto iv = GetIV();  // this is constant IV for entire application
>   encryption.SetKeyWithIV(key.data(), key.size(), iv.data(), iv.size());
>   return encryption;
> }

But when I use returned object in StreamTransformationFilter I get an 
address access violation in CryptoPP code
> CryptoPP::BlockOrientedCipherModeBase::IsForwardTransformation() 
modes.h:259

Is it a CryptoPP bug (move-ctors are not implemented correctly) or 
Encryption objects cannot be moved for some security reasons? Or that is 
kind of impossible to implement move-ctor for a template class?

Seems that I should rather implement 
> template <class T>
> vector<byte> Encrypt(const T& text, const SecByteBlock& key) { ... }

but still curious about that 'move' issue.

CryptoPP library version 8.7.0
Test code is here 
https://wandbox.org/permlink/OeWKeOs9ERWYZKpr

This is a stack trace when address access violation happened
> CryptoPP::BlockOrientedCipherModeBase::IsForwardTransformation() 
modes.h:259
> 
CryptoPP::StreamTransformationFilter::LastBlockSize(CryptoPP::StreamTransformation
 
&, BlockPaddingScheme) filters.cpp:630
> 
CryptoPP::StreamTransformationFilter::InitializeDerivedAndReturnNewSizes(const 
CryptoPP::NameValuePairs &, unsigned int &, unsigned int &, unsigned int &) 
filters.cpp:658
> CryptoPP::FilterWithBufferedInput::IsolatedInitialize(const 
CryptoPP::NameValuePairs &) filters.cpp:332
> 
CryptoPP::StreamTransformationFilter::StreamTransformationFilter(CryptoPP::StreamTransformation
 
&, CryptoPP::BufferedTransformation *, BlockPaddingScheme) filters.cpp:598
> Test2() main.cpp:67
> main() main.cpp:81
> invoke_main() 0x00000000007b3873
> __scrt_common_main_seh() 0x00000000007b36f7
> __scrt_common_main() 0x00000000007b358d
> mainCRTStartup(void *) 0x00000000007b38f8
> <unknown> 0x00000000774cfa29
> <unknown> 0x0000000077817a9e
> <unknown> 0x0000000077817a6e

-- 
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 cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/2b12271a-be6b-4d9c-86b7-645bddcebfe7n%40googlegroups.com.

Reply via email to