我使用以下代码通过crypto ++验证消息:

CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>::Verifier verifier(key);
bool result = verifier.VerifyMessage( (const CryptoPP::byte*)message.data(), message.length(), (const CryptoPP::byte*)signature.data(), signature.length() );

现在,我想验证我先前为文件创建的签名。该文件很大(GB),我不想将它一次加载到内存中(消息变量)。

crypto ++有没有办法验证大文件的签名?

最佳答案

这段代码满足了我的需要:

 CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>::PublicKey key; key.Load(queue);
 CryptoPP::ECDSA<CryptoPP::ECP, CryptoPP::SHA256>::Verifier verifier(key);

 CryptoPP::SignatureVerificationFilter verificationFilter(verifier, NULL, CryptoPP::SignatureVerificationFilter::SIGNATURE_AT_BEGIN);
 CryptoPP::FileSource fileSource( file, false, new CryptoPP::Redirector(verificationFilter));
 CryptoPP::StringSource signatureSource( (const CryptoPP::byte*)signature.data(), signature.length(), false, new CryptoPP::Redirector(verificationFilter));
 signatureSource.Pump(signature.length());
 fileSource.PumpAll();

 return verificationFilter.GetLastResult();

关于c++ - Crypto++验证大文件签名,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52966938/

10-09 09:02