Experiencing Segfault in CryptoPP::StreamTransformationFilter in Linux build

Sunandan Nandi <[email protected]>
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <[email protected]>
Hi,

I am experiencing Segfault inside CryptoPP::StreamTransformationFilter.

*Overview:*
I have downloaded and built CryptoPP as an external CMake module. 
*Problem:*
This segfault is happening only in Linux(Ubuntu 18.04.05LTS) *Release build*
.
64-bit,compiler clang 6.0

*GDB BT*
Thread 9 "***" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffdb7fe700 (LWP 5835)]
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  *0x0000000000b7559d in 
CryptoPP::StreamTransformationFilter::StreamTransformationFilter 
(this=0x7fffdb7fd1c0, c=..., attachment=<optimized out>,*
    *padding=<optimized out>) at filters.cpp:593*
#2  0x00000000004ff4fd in 
***::AESEncryptDecryptUtility::decrypt(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&) ()

*Trials to resolve this issue:*
If I build my target where I am using CryptoPP( static lib) with *optimization 
level O1 or less, then no segfault observed. But this issue is with 
optimization level O2 or more.*

*Code snippet:*
std::string AESEncryptDecryptUtility::decrypt(const std::string& 
encrypted_text) { std::string decrypted_text; CryptoPP::AES::Decryption 
aesDecryption(key_.data(), KEY_LENGTH); 
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, 
iv_.data()); CryptoPP::*StreamTransformationFilter *stfDecryptor(cbcDecryption, 
new CryptoPP::StringSink(decrypted_text)); 
stfDecryptor.Put(reinterpret_cast<const unsigned 
char*>(encrypted_text.c_str()), encrypted_text.size()); 
stfDecryptor.MessageEnd(); return decrypted_text; 

Inside *StreamTransformationFilter() *where it's crashing, the line 
highlighted in Red is pointing in GDB as the last point before the 
crash(segfault)

StreamTransformationFilter::StreamTransformationFilter(StreamTransformation 
&c, BufferedTransformation *attachment, BlockPaddingScheme padding)
    
: FilterWithBufferedInput(attachment), m_cipher(c), m_padding(DEFAULT_PADDING)
{
    CRYPTOPP_ASSERT(c.MinLastBlockSize() == 0 || c.MinLastBlockSize() 
> c.MandatoryBlockSize());

    const bool authenticatedFilter 
= dynamic_cast<AuthenticatedSymmetricCipher *>(&c) != NULLPTR;
    if (authenticatedFilter)
        throw InvalidArgument("StreamTransformationFilter: please use 
AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for 
AuthenticatedSymmetricCipher");

    // InitializeDerivedAndReturnNewSizes may override some of these
    m_mandatoryBlockSize = m_cipher.MandatoryBlockSize();

Please let me know if any other information needed.

Regards,
Sunandan

 

-- 
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].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/e6c860f6-1e74-4372-b4de-691e0692747bn%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.