我使用以下代码通过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 ++是否可以验证大文件的签名?
答案 0 :(得分:0)
这段代码可以满足我的需求:
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();