1
0
mirror of https://github.com/opencontainers/go-digest.git synced 2025-04-19 14:22:15 +03:00

8 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
a1f6e2eda3
address some linting issues
- 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>
2024-07-02 13:22:02 +02:00
Sebastiaan van Stijn
84af967803
TestFroms: use sub-tests
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>
2023-08-01 15:27:26 +02:00
Sebastiaan van Stijn
f94d70dcad
TestFroms: fix some linting issues
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>
2023-08-01 15:27:26 +02:00
Sebastiaan van Stijn
084376bb54
make sure the standard algorithms are registered
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>
2021-08-18 23:45:18 +02:00
Sargun Dhillon
b9e02e015b Implement dynamic hash registration
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>
2021-04-21 11:34:35 -07:00
Vincent Batts
264d27f5bd
*: add OCI copyright
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2020-01-20 11:09:29 -05:00
Stephen J Day
b6234c321f
*: add LICENSE headers to Go files
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-01-30 15:27:15 -08:00
Stephen J Day
f8e420604f digest: better test coverage
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-12-15 17:33:33 -08:00