SHA256 from file descriptor

Dridi Boukelmoune dridi at varni.sh
Wed May 22 07:52:59 UTC 2024


> > > What's the usecase ?
> > >
> > > If regular file:  Why not mmap and save the kernel/userland copies ?
> >
> > Because the code from which I extracted this function was doing a copy
> > while computing the checksum on the fly, so I didn't consider mmap
> > when I extracted the read part of the code.
>
> But what is the use-case ?

My bad, in my mind replying about mmap implied that this was indeed
about having a convenience functtion to compute the hash of a regular
file.

Would the attached patch be welcome?

Slightly off topic, why have both definitions?

    #define VSHA256_LEN             32
    #define VSHA256_DIGEST_LENGTH   32

Dridi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sha256_fd_with_mmap.diff
Type: text/x-patch
Size: 1354 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20240522/473f6516/attachment.bin>


More information about the varnish-dev mailing list