Repository navigation
Implement dynamic hash registration - #62
Merged
Merged
Conversation
Merged
AkihiroSuda
approved these changes
Apr 21, 2021
Contributor
Author
|
Made one small fix around the comment from @stevvooe. I think I fulfilled the proposed ask. |
vbatts
requested changes
Apr 21, 2021
| algorithmsLock.Lock() | ||
| defer algorithmsLock.Unlock() | ||
|
|
||
| if _, ok := algorithms[algorithm]; ok { |
Member
There was a problem hiding this comment.
We made the standard keys lowercase. Perhaps we should force the same here of all keys (and comment as such) so that "SHA256" doesn't confuse with "sha256"
Contributor
Author
There was a problem hiding this comment.
@vbatts Should I add a validator based on the semantic here? https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md#digests
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 <[email protected]>
This was referenced Sep 17, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 [email protected]