-
Notifications
You must be signed in to change notification settings - Fork 18
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
Use a simpler PAE #27
Comments
In fact, here is a bash implementation of the suggested simpler PAE: local payloadTypeLength=$(LC_ALL=C; echo "${#payloadType}")
local payloadSize=$(stat -c %s "$payloadFile")
printf "%s" "DSSEv1 $payloadTypeLength $payloadType $payloadSize "
cat "$payloadFile" Doing this with the current PAE would be more difficult. |
Wouldn't it be beneficial to base64 encode the payload first? |
@kommendorkapten No, I don't think so. Base64 is a transport detail that should get stripped off before it gets to the PAE stage. For example, if you parse the JSON with the protobuf library, it does the base64-decoding for you. Plus the protocol is encoding-agnostic, and base64 isn't used at all for CBOR, Avro, Protobuf, or any other binary encoding. Heck, you might have an "ASCII Armor" encoding like PGP where you wrap at 72 columns, in which case you can't feed it directly into PAE anyway. |
Makes as PAE is used to canonicalize the data prior to signature generation.
This I didn't get. An ASCII Armor encoding is a regular string (with newlines), so why couldn't that be fed into PAE? The result of PAE is an octet stream that won't be decoded, only used to generate a signature if I got it right. |
There are two steps to signing:
The protocol is agnostic to the encoding. If you decode a JSON envelope and re-encode as CBOR, the signature should stay valid. Now consider the proposal where PAE uses a base64-encoded payload:
You could say, "You sign whatever encoding the sender used." OK, but that would break the notion of being able to re-encode the envelope, and what would it buy you? AFAICT, the only difference is that you do the PAE before base64-decoding instead of after. But why is that worth the added complexity? |
I think we are talking about different things :) I looked at your example
And I jumped the gun and thought that you meant for this PAE function to convert a 2-tuple to a string (not a byte stream). |
Ah, so sorry for the confusion! 😄 Yes, the proposal is for it to still be a byte stream (to be fed to a cryptographic hash function), but the first few bytes just happen to be ASCII because it's easier to deal with ASCII. In particular, |
Got it, thanks for clarifying 👍 |
The previous PAE required binary encoding, which can be tricky in some langauges. The new PAE is pure ASCII so it can be implemented very easily in almost any language.
Just a minor nit: when you write "concatenate the following elements, separated by spaces" you probably mean "separated by a single space character". Otherwise, there can be ambiguity, for example when a length is followed by multiple spaces. |
Fixed, though the real text is at #37. Please take a look at that to see if it looks good to you. |
Done! |
In 0.1, we choose PASETO's PAE because it was already written. But it is does require doing some integer-to-bytes conversion and a need to be careful about sizes and endianness. Here is an example where a potential customer was scared off by the perceived complexity of PAE: sigstore/cosign#214 (comment)
For 1.0, perhaps we should choose a simpler function that is easier to describe and implement. Here is my proposal: concatenate the following, separated by a single space:
Example:
DSSEv1 31 https://in-toto.io/Statement/v1 434 {"subject": {...}, ...}
This is basically the same as the current PAE except it is simpler to implement. Note that this is a byte stream that happens to be start with unicode characters, and we never need to decode it.
Edit 1: reorder the fields to match the existing PAE.
Edit 2: clarify that it is a byte stream, and mention version 0.1.
The text was updated successfully, but these errors were encountered: