- rename "digester" vars that shadowed package-level digester type
- rename "hexdigestbytes" to be properly camelCase
- use "errors.Is()" instead of straight comparing errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use sub-tests to not fail early if an algorithm fails.
With this change:
=== RUN TestFroms
=== RUN TestFroms/sha256
=== RUN TestFroms/sha384
=== RUN TestFroms/sha512
--- PASS: TestFroms (0.02s)
--- PASS: TestFroms/sha256 (0.01s)
--- PASS: TestFroms/sha384 (0.00s)
--- PASS: TestFroms/sha512 (0.00s)
PASS
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Keep the linters happy:
- fix an unhandled error (but unlikely to happen)
- fix some variables being shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This makes sure that the expected algorithms are registered when
using this package.
Currently, the consumer of the package must import these, otherwise it's
not registered, resultig in "unsupported digest algorithm" errors.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This adds a new interface to go-digest allowing for it to act as a registry
for various hash implementations. It includes the new "CryptoHash" interface
which hashers must implement. By default the SHA variants that were
historically available are available.
The cryptoHash interface mimics crypto.Hash, but is a subset of the methods
that we require. crypto.Hash is a concrete type that makes it hard to bring
new hash function implementations in.
The primary impetus is to allow for out-of-tree hash implementations to be
added. For example, if someone wanted to add the out-of-tree BLAKE3 AVX
implementation, they could do that. Right now, if two versions of the same
implementation are added, the one that is added first will take precedence,
but in the future, we can add the ability to force registration.
Signed-off-by: Sargun Dhillon <sargun@sargun.me>