使用cryptopp库进行编译时收到警告

Getting warning while compiling using cryptopp library

本文关键字:警告 编译 cryptopp 使用      更新时间:2023-10-16

我有一个在CBC模式下使用AES算法加密的文件。我有数据库中的密钥。我正在尝试使用cryptopp 5.6.2库编译以下代码。它是在没有-Wall标志的情况下编译的,但当我启用该标志时,会出现下面的警告。

#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;
}

获取以下启用-墙标志的错误

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

下面的代码使用cryptopp 5.6.2库。。。

5.6.2有点老了。我们正准备发布Crypto++5.6.5。


它是在没有-Wall标志的情况下编译的,但当我启用该标志时,会出现下面的警告。

./cryptopp_5.6.2/include/cryptopp/algparam.h:322: warning: unused variable ‘p’

这一警告在大约18个月前被解除。它首次出现在Crypto++5.6.3发布的版本中。另请参阅提交5f25c736:添加CRYPTOPP_UNUSED以帮助抑制未使用的变量警告。


获取以下启用-Wall标志时的错误。。。

Crypto++现在在GCC和兼容程序下的-Wall -Wextra上是干净的。它也在MSC下用CCD_ 2清洗。最后,它在Solaris的SunCC下进行了清理。

如果感兴趣,以下是发布过程和我们需要通过的安全门(来自发布过程|分析工具(:

  • 编译器警告
  • Clang和GCC消毒器
  • Valgrind
  • 企业分析
  • 隐蔽性

现在,Coverity的成绩是5.6.5。我们最近将Coverity覆盖范围扩展到Linux、Unix、OS X和Windows(以前仅限于Linux(。隐蔽性正在产生发现,我们正在研究这些发现。