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 that hashing bytes are base-64 encoded and give examples #2447

Merged
merged 4 commits into from Mar 3, 2023

Conversation

LPardue
Copy link
Contributor

@LPardue LPardue commented Feb 25, 2023

With Digest, the encoding of the digest value was based on the digest
algorithm. For different algorithms, this varied between base64, hex
encoding or decimal encoding.

In this spec, we removed the variablilty by using SF Byte Sequence,
which is always serialized as a base-64 encoding of the input bytes. All
algorithms are now expected to use this format.

This change tries to make it more clear that we expect the input of the
Byte Sequence to be. For example, we really don't want people accidentally
base-64'ing the textual hex represenation output of cksum - that can
lead to interop pain.

To help implementers further, add a new appendix with some samples that
can be used as test vectors.

Closes #2385

With Digest, the encoding of the digest value was based on the digest
algorithm. For different algorithms, this varied between base64, hex
encoding or decimal encoding.

In this spec, we removed the variablilty by using SF Byte Sequence,
which is always serialized as a base-64 encoding of the input bytes. All
algorithms are now expected to use this format.

This change tries to make it more clear that we expect the input of the
Byte Sequence to be. For example, we really don't want people accidentally
base-64'ing the textual hex represenation output of cksum - that can
lead to interop pain.

To help implementers further, add a new appendix with some samples that
can be used as test vectors.

Closes #2385
@LPardue
Copy link
Contributor Author

LPardue commented Feb 25, 2023

FWIW it would be nicer to have the examples rendered in a table. But the SHA-512 example is too long and makes the build whinge. I couldn't figure out any kramdown tricks for a multi-line table entry but if somebody else knows, I'd switch over.

@LPardue
Copy link
Contributor Author

LPardue commented Feb 25, 2023

Also, I welcome anyone checking my working in generating these values. The old algorithms don't tend to be supported in any decent libraries that are easily available. So I used a hodgepodge of various tools and sources to come up with bytes that would run as input into the SF serialization.

@@ -1291,6 +1321,11 @@ RFC 3230 could never communicate
the digest of HTTP message content in the Digest field;
Content-Digest now provides that capability.

RFC 3230 allowed algorithms to define their output encoding format for use with
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@ioggstream
Copy link
Contributor

@LPardue I like the example and I will check it.

I am not sure that we should explain how Binary serialization work (e.g. base64 delimited by : ...) because it's explained in SF.

@LPardue
Copy link
Contributor Author

LPardue commented Mar 2, 2023

Since we had some feedback that some of the examples were incorrect, and I fixed that up, I'm going to go ahead and assume the rest are ok. The important part here is that we add some coverage over all the algorithms and and I have not heard any pushback to the proposal. So I'm going to merge.

@LPardue LPardue merged commit 4f905b2 into main Mar 3, 2023
@LPardue LPardue deleted the digests-are-baset64-show-it-with-test-vectors branch March 3, 2023 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

No examples of encoding output any of the 6 "insecure" algorithms
3 participants