Reputation: 1292
I use this code to verify a message with 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() );
Now I would like to verify a signature I previously created for a file. The file is quite big (GB) and I don't want to load it to memory in one piece (to message variable).
Is there a way crypto++ can verify large file's signature?
Upvotes: 1
Views: 674
Reputation: 1292
This code does what I need:
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();
Upvotes: 1