Reputation: 603
I have a encrypted file using AES algorithm in CBC mode. I have key from database. I am trying to compile below code using cryptopp 5.6.2 library. It gets compiled without -Wall flag but when I enable that flag below warnings appears.
#include <iostream>
#include <fstream>
#include <exception>
#include <sstream>
#include "cryptopp/modes.h"
#include "cryptopp/aes.h"
#include "cryptopp/filters.h"
#include "cryptopp/cryptlib.h"
#include "cryptopp/hex.h"
#include "cryptopp/filters.h"
#include "cryptopp/aes.h"
#include "cryptopp/ccm.h"
#include "cryptopp/files.h"
using namespace std;
using namespace CryptoPP;
int main(int argc, char* argv[])
{
try
{
byte no[16] ;
byte noiv[16];
std::string out;
std::string fileName("./encrypted.txt");
CBC_Mode<AES>::Decryption d;
d.SetKeyWithIV(no, sizeof(no), noiv);
CryptoPP::FileSource(fileName.c_str(), true, new StreamTransformationFilter(d, new CryptoPP::FileSink("decrypted.txt"), CryptoPP::StreamTransformationFilter::PKCS_PADDING));
}
catch (CryptoPP::Exception& e)
{
std::cout << std::endl << e.what() << std::endl;
}
return 0;
}
Gets below errors on enabling -Wall flag
In file included from ./cryptopp_5.6.2/include/cryptopp/modes.h:12,
from poc.cpp:6:
./cryptopp_5.6.2/include/cryptopp/algparam.h: In constructor ‘CryptoPP::ConstByteArrayParameter::ConstByteArrayParameter(const T&, bool) [with T = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’:
./cryptopp_5.6.2/include/cryptopp/filters.h:793: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:26: warning: unused variable ‘cryptopp_assert_26’
In file included from ./cryptopp_5.6.2/include/cryptopp/modes.h:12,
from poc.cpp:6:
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = std::ostream*]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = const wchar_t*]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = const char*]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = std::istream*]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = const int*]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = unsigned char]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = const byte*]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/algparam.h: In member function ‘void CryptoPP::AlgorithmParametersTemplate<T>::MoveInto(void*) const [with T = CryptoPP::RandomNumberGenerator*]’:
poc.cpp:36: instantiated from here
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
./cryptopp_5.6.2/include/cryptopp/misc.h: At global scope:
./cryptopp_5.6.2/include/cryptopp/misc.h:548: warning: ‘std::string CryptoPP::StringNarrow(const wchar_t*, bool)’ defined but not used
Upvotes: 2
Views: 1243
Reputation: 102376
below code using cryptopp 5.6.2 library...
5.6.2 is kind of old. We are getting ready to release Crypto++ 5.6.5.
It gets compiled without -Wall flag but when I enable that flag below warnings appears.
./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’
The warning was cleared about 18 months ago. It was first seen in a release at Crypto++ 5.6.3. Also see Commit 5f25c736: Add CRYPTOPP_UNUSED to help supress unused variable warnings.
Gets below errors on enabling -Wall flag ...
Crypto++ is now clean at -Wall -Wextra
under GCC and compatibles. Its also clean under MSC with /W4
. Finally, its clean under Solaris' SunCC.
If interested, here is the release process and security gates we are required to pass through for a release (from Release Process | Analysis Tools):
Right now, Coverity is holding-up 5.6.5. We recently expanded Coverity coverage to Linux, Unix, OS X, and Windows (previously it was Linux only). Coverity is producing findings and we are working through them.
Upvotes: 2