secblock.h and cryptopp-authenc.cpp dont compile

40 views
Skip to first unread message

Bob Devon

unread,
Apr 6, 2016, 2:54:34 PM4/6/16
to Crypto++ Users
I compiled and built Crypto++ Library 5.6.3 no problem !
I compiled and ran examples Serpent GCM, Twofish EAX no problem !

but, i failed to compile cryptopp-authenc.cpp

I'm using
g++ (SUSE Linux) 5.2.1 20150721 [gcc-5-branch revision 226027]
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

here the compile error:
g++ -g -O2 -DNDEBUG -I/usr/include/cryptopp cryptopp-authenc.cpp -o test -lcryptopp -lpthread
In file included from cryptopp-authenc.cpp:20:0:
/usr/include/cryptopp/secblock.h: In instantiation of ‘CryptoPP::SecBlock<T, A> CryptoPP::SecBlock<T, A>::operator+(const CryptoPP::SecBlock<T, A>&) [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup<unsigned char>]’:
cryptopp-authenc.cpp:156:114:   required from here
/usr/include/cryptopp/secblock.h:593:6: error: cannot convert ‘CryptoPP::SecBlock<T, A>::size<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char> >’ from type ‘CryptoPP::SecBlock<unsigned char>::size_type (CryptoPP::SecBlock<unsigned char>::)() const {aka long unsigned int (CryptoPP::SecBlock<unsigned char>::)() const}’ to type ‘bool’
   if(!t.size) return SecBlock(*this);
      ^
/usr/include/cryptopp/secblock.h:593:6: error: in argument to unary !

Any idea?

Jeffrey Walton

unread,
Apr 6, 2016, 3:08:25 PM4/6/16
to Crypto++ Users

here the compile error:
g++ -g -O2 -DNDEBUG -I/usr/include/cryptopp cryptopp-authenc.cpp -o test -lcryptopp -lpthread
In file included from cryptopp-authenc.cpp:20:0:
/usr/include/cryptopp/secblock.h: In instantiation of ‘CryptoPP::SecBlock<T, A> CryptoPP::SecBlock<T, A>::operator+(const CryptoPP::SecBlock<T, A>&) [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup<unsigned char>]’:
cryptopp-authenc.cpp:156:114:   required from here
/usr/include/cryptopp/secblock.h:593:6: error: cannot convert ‘CryptoPP::SecBlock<T, A>::size<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char> >’ from type ‘CryptoPP::SecBlock<unsigned char>::size_type (CryptoPP::SecBlock<unsigned char>::)() const {aka long unsigned int (CryptoPP::SecBlock<unsigned char>::)() const}’ to type ‘bool’
   if(!t.size) return SecBlock(*this);
      ^
/usr/include/cryptopp/secblock.h:593:6: error: in argument to unary !

Yeah, that's a typo we discovered after releasing 5.6.3. We missed it at the time because we did not have a test case for it.

You can change it to the following (from https://github.com/weidai11/cryptopp/blob/master/secblock.h#L598):

    assert((!m_ptr && !m_size) || (m_ptr && m_size));
    assert((!t.m_ptr && !t.m_size) || (t.m_ptr && t.m_size));
    if(!t.m_size) return SecBlock(*this);

We are getting ready for a 5.6.4 release to pick-up straggler bugs like this (there's been a handful of them), and to clear a potential CVE (https://github.com/weidai11/cryptopp/issues/146). I'm waiting to hear back if it should be submitted for a CVE assignment.

You can also work from Master by using Wei Dai's github. Master is stable, and not experimental:

    git clone https://github.com/weidai11/cryptopp.git
    cd cryptopp
    make static dynamic test
    sudo make install

Then, use the Crypto++ library at /usr/local instead of /usr.

Jeff

Bob Devon

unread,
Apr 6, 2016, 3:19:28 PM4/6/16
to Crypto++ Users

Thanks a lot! works fine... more fun to play now!

Jeffrey Walton

unread,
Apr 6, 2016, 3:28:44 PM4/6/16
to Crypto++ Users


On Wednesday, April 6, 2016 at 3:19:28 PM UTC-4, Bob Devon wrote:

Thanks a lot! works fine... more fun to play now!

Very good.

You might want to grab the entire secblock.h file from GitHub and overwrite Gentoo's version. There are two other fixes in there that may be helpful to you (IIRC). The files are completely compatible, and it does not break ABI. It may mess with line numbers of stack dumps when using Gentoo's precompiled library.

Jeff

Reply all
Reply to author
Forward
0 new messages