Re: [cryptopp-users] HMACs of files
Okay. However, when I looked at the information provided in this link: https://www.cryptopp.com/wiki/HashVerificationFilter#String_and_File_Sources, it appears that the method suggested to avoid memory usage doesn't actually achieve that goal, as the line FileSource fs("zero.dat", true); in the verification step is performing as intended. Unfortunately, I am unable to use FileSource fs("zero.dat", false, new HashVerificationFilter(sha256, new StringSink(digest))); or FileSource fs("zero.dat", true... either, because it's unclear how to associate the digest with the input file. On Saturday, May 20, 2023 at 6:48:40 PM UTC-4 Jeffrey Walton wrote: > On Sat, May 20, 2023 at 4:45 PM Jeffrey Walton wrote: > > > > On Sat, May 20, 2023 at 3:00 PM Tom wrote: > > > > > > calling `FileSource fs("zero.dat", true);` seems to allocate the > memory. > > > > Try the overload which takes a std::istream reference: > > https://www.cryptopp.com/wiki/FileSource > > I took another look... The issue is you passed 'true' for 'pumpAll'. > That reads the entire file, and puts it in an output buffer for the > next filter. > > Use 'false' instead, and then call 'PumpAll()' manually. Something > like the example. Something like this should suffice: > > FileSource fs("zero.dat", false, new Filter(..., new Sink(...))); > fs.PumpAll(); > > It should pump in 4k blocks. > > Jeff > -- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/7af8a6f5-5cc2-47d2-b35b-21c131bbf774n%40googlegroups.com.
Re: [cryptopp-users] HMACs of files
On Sat, May 20, 2023 at 4:45 PM Jeffrey Walton wrote: > > On Sat, May 20, 2023 at 3:00 PM Tom wrote: > > > > calling `FileSource fs("zero.dat", true);` seems to allocate the memory. > > Try the overload which takes a std::istream reference: > https://www.cryptopp.com/wiki/FileSource I took another look... The issue is you passed 'true' for 'pumpAll'. That reads the entire file, and puts it in an output buffer for the next filter. Use 'false' instead, and then call 'PumpAll()' manually. Something like the example. Something like this should suffice: FileSource fs("zero.dat", false, new Filter(..., new Sink(...))); fs.PumpAll(); It should pump in 4k blocks. Jeff -- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8k7u3f7PdhAHhACPEHVoYhEOfBM3WGP25ADZTd26PocZg%40mail.gmail.com.
Re: [cryptopp-users] HMACs of files
On Sat, May 20, 2023 at 3:00 PM Tom wrote: > > calling `FileSource fs("zero.dat", true);` seems to allocate the memory. Try the overload which takes a std::istream reference: https://www.cryptopp.com/wiki/FileSource Jeff > On Wednesday, September 8, 2021 at 7:24:28 PM UTC-4 Jeffrey Walton wrote: >> >> On Wed, Sep 8, 2021 at 6:46 AM Jeffrey Walton wrote: >> > >> > On Tue, Sep 7, 2021 at 7:45 AM Tom wrote: >> > > >> > > I can create HMACs of files using pipelines via filesources but... I >> > > can't seem to figure out to verify the HMAC without throwing the file >> > > into a string in memory. >> > > >> > > like this: >> > > >> > > StringSource(plain + mac, true, new HashVerificationFilter(hmac, NULL, >> > > flags) ); // StringSource >> > > >> > > Is there a way to use a FileSource without loading the file fully into >> > > memory? >> > > >> > > I think its possible but do I append the hmac if I use a file? >> > >> > Yeah, that's a problem. We should have some documentation covering it. >> >> Here is the documentation: >> https://www.cryptopp.com/wiki/HashVerificationFilter#String_and_File_Sources >> -- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8kjCAayyejfQtnMLVcZ9NGSheCYPb%2BHTQQCn5%3DxMbLruw%40mail.gmail.com.
Re: [cryptopp-users] HMACs of files
calling `FileSource fs("zero.dat", true);` seems to allocate the memory. On Wednesday, September 8, 2021 at 7:24:28 PM UTC-4 Jeffrey Walton wrote: > On Wed, Sep 8, 2021 at 6:46 AM Jeffrey Walton wrote: > > > > On Tue, Sep 7, 2021 at 7:45 AM Tom wrote: > > > > > > I can create HMACs of files using pipelines via filesources but... I > can't seem to figure out to verify the HMAC without throwing the file into > a string in memory. > > > > > > like this: > > > > > > StringSource(plain + mac, true, new HashVerificationFilter(hmac, NULL, > flags) ); // StringSource > > > > > > Is there a way to use a FileSource without loading the file fully into > memory? > > > > > > I think its possible but do I append the hmac if I use a file? > > > > Yeah, that's a problem. We should have some documentation covering it. > > Here is the documentation: > > https://www.cryptopp.com/wiki/HashVerificationFilter#String_and_File_Sources > > Jeff > -- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/4d2be937-ba8a-4125-99bb-b6abba00b9bcn%40googlegroups.com.