I have to verify the signature on a file that may be as large as 2Gb, and I want to do so in a way that is as memory-efficient as possible. For various reasons, the file will already be loaded completely into memory, and is accessed using an InputStream
by the application. I would like to verify the signature using the stream interface, but the JCA Signature
class' update
method only accepts byte[]
and related classes.
How can I do this efficiently? I don't want to load the beast into a second byte array, otherwise we'll be seeing some seriously high memory use, but the interface doesn't seem to support it otherwise.
Update
If it matters, the signing algorithm is SHA-1