What's the best way to compute SHA-256 digests for content in the cache?
I am thinking of using libgcrypt [1], can anyone comment on whether this
is a good choice, or offer advice?
To read the content, I am thinking of following the null transform
example, and whenever I copy from the input to the output buffer, update
the digest with this chunk of content. Is the null transform example the
best way to read the content, for the purpose of computing the digest?
Should I worry about tying up the event loop with calls to libgcrypt?
Here is a first attempt, on GitHub, at using libgcrypt and following the
null transform example [2]. I would love any feedback
My GSoC project is a plugin to exploit RFC 6249, Metalink/HTTP: Mirrors
and Hashes [3], and redirect clients to mirrors that are already cached.
So far it works just well enough that, given a response with a URL in
the "Location: ..." header that is not already cached and a URL in a
"Link: <...>; rel=duplicate" header that is already cached, it will
rewrite the "Location: ..." header with the cached URL. This should
redirect clients that are not Metalink aware to mirrors that are already
cached
I think the next step is for this plugin to check the digest of the
cached content:
If Instance Digests are not provided by the Metalink servers, the
Link header fields pertaining to this specification MUST be ignored.
So I plan to compute digests for content in the cache and check the
"Digest: ..." header against these. Does this sound like the right approach?
[1] http://directory.fsf.org/wiki/Libgcrypt
[2] https://github.com/jablko/dedup
[3] http://tools.ietf.org/html/rfc6249