Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: clarify we only deal with hex-encoded digests #32

Merged
merged 2 commits into from
Jan 8, 2020

Conversation

jonboulle
Copy link
Contributor

Also fixes a typo and adds one clarifying link in the README.

Fixes #31

Also fixes a typo and adds one clarifying link in the README.

Fixes opencontainers#31

Signed-off-by: Jonathan Boulle <[email protected]>
@vbatts
Copy link
Member

vbatts commented Mar 9, 2017

LGTM

Approved with PullApprove

doc.go Outdated
@@ -32,6 +32,8 @@
// In this case, the string "sha256" is the algorithm and the hex bytes are
// the "digest".
//
// This package exclusively uses hex encoding for all digests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... for currently supported algorithms. The hex limitation is about the encoding of digest that is bound to the algorithm. New "algorithms" may support other kinds of encodings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this wording is a bit confusing, but I've posted a revised take @ d1caf20, PTAL

verify your input with `digest.Parse` or use `Digest.Validate`
when accepting untrusted input. While there are measures to
avoid common problems, this will ensure you have valid digests
in the rest of your application.

3. While alternative encodings of hash values (digests) are possible (for
example, base64), this package deals exclusively with hex-encoded digests.
Copy link
Contributor

@wking wking Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, with d1caf20 the package position will be:

  1. The algorithm identifier (e.g. ‘sha256’) identifies both the hash algorithm (e.g. SHA-256) and the encoding (e.g. lowercase base16).
  2. Algorithm identifiers which use encodings other than lowercase base 16 are allowed.
  3. This package will reject pull requests which would allow support for algorithm identifiers which use encodings other than lowercase base 16.
  4. This package will reject pull requests which would allow library consumers to register their own externally-defined Algorithm unless that externally-defined Algorithm uses a lowercase base 16 encoding.

Putting that all together, that's “you can define a new algorithm identifier using an encoding other than lowercase base 16, but if you do you won't be able to use go-digest at all, and we're not interested in providing a library that will work with you”. I find that position unfortunate, when the alternatives (either requiring hex encoding for all algorithm identifiers, or providing a framework that would support algorithm identifiers which used other encodings) seem so easy to adopt. But maybe I'm misunderstanding something about the package position?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that summarises the state of the world today. I don't have the effort to fight #31 so I'm just trying to clarify the current situation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this section. The doc update clarifies the point and the interface has been updated to be less opinionated about encoding. Other sections look good.

Copy link
Contributor

@wking wking May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc update clarifies the point and the interface has been updated to be less opinionated about encoding.

The doc update in this PR says that all current algorithms in this package are hex (true). This README line is getting at “and this package currently has no interest in supporting users who want custom, non-hex algorithms”.

And while the interface seems less opinionated now that there is an Algorithm.Encode, that's currently hardcoded to assume hex, Algorithm is still not an interface (like I proposed in #30), and there is no way for consumers to register or use non-hex algorithms with this package. If there is a way to do that, I'd recommend pushing docs for “how you register your custom non-hex algorithm” to doc.go. With #30, you'd do it by pushing your Algorithm-interface implementing object into the Algorithms map.

Other sections look good.

Pulling the typo-fixes and such out (if they still apply) into less contentious PRs might help get them landed faster.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link that doc?

Look down

Pulling the typo-fixes and such out (if they still apply) into less contentious PRs might help get them landed faster.

I am requesting the other way around, otherwise would just carry this PR with those changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look down

Yup, sorry. I've edited my earlier comment.

I am requesting the other way around.

That's fine too, as long as we remove Fixes #31.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine too, as long as we remove Fixes #31.

Fair

@vbatts
Copy link
Member

vbatts commented Dec 13, 2019

LGTM

Approved with PullApprove

@thaJeztah
Copy link
Member

ping @dmcgowan PTAL

@dmcgowan
Copy link
Member

dmcgowan commented Jan 8, 2020

LGTM

Approved with PullApprove

@dmcgowan dmcgowan merged commit 998894b into opencontainers:master Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hardcoded assumptions that the hash will be encoded in hex
6 participants