使用cryptopp库进行编译时收到警告
Getting warning while compiling using cryptopp library
我有一个在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(。隐蔽性正在产生发现,我们正在研究这些发现。
相关文章:
- 关于std::move的使用,是否有编译警告
- 示例C++项目编译中的警告
- Steam 回调在 Linux / GCC 编译期间触发警告
- C++警告:编译指示在主文件中一次
- 如何在类成员函数中获得类似printf中的编译警告
- 编译按位 OR 时出现警告 C4805
- C++编译新的警告过滤器
- GCC 编译时出现警告:未知转义序列:"\040"
- 使用预编译的标题接近时,大量的QT警告
- 编译时收到未初始化的内存警告
- 警告:不能解析.gnu_debugdata部分;LZMA支持在编译时被禁用
- 编译错误:(警告:控制到达非空函数 [-wreturn 类型] 的末尾)
- clang:警告:编译期间未使用的参数:"-stdlib=libc++"
- 如何修复未知编译指示 gcc 警告
- 有没有办法自定义编译错误/警告消息
- 窄转换编译警告.如何解决它
- C++就地析构函数编译警告
- 如何在 ubuntu 12.10 中隐藏 g++ c++11 编译警告
- 在Ubuntu中使用OpenCV进行编译警告
- 警告:编译到.so时找不到入口符号start-