Skip to content

Commit 9d40eed

Browse files
AdamZWuMarkLodato
andcommitted
Add UTF-8 encoding option to the envelope document and proto.
Signed-off-by: Zhenyu (Adam) Wu <[email protected]> Co-authored-by: Mark Lodato <[email protected]>
1 parent 6aca2e8 commit 9d40eed

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

envelope.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
March 03, 2021
44

5-
Version 1.0.0
5+
Version 1.1.0
66

77
This document describes the recommended data structure for storing DSSE
88
signatures, which we call the "JSON Envelope". For the protocol/algorithm, see
@@ -16,9 +16,12 @@ to define the schema. JSON is the only recommended encoding.)
1616
The standard data structure for storing a signed message is a JSON message of
1717
the following form, called the "JSON envelope":
1818

19-
```json
19+
```jsonc
2020
{
21-
"payload": "<Base64(SERIALIZED_BODY)>",
21+
// Exactly one of the following must be set:
22+
"payload": "<Base64Encode(SERIALIZED_BODY)>",
23+
"payloadUtf8": "<Utf8Decode(SERIALIZED_BODY)>",
24+
// End oneof
2225
"payloadType": "<PAYLOAD_TYPE>",
2326
"signatures": [{
2427
"keyid": "<KEYID>",
@@ -29,9 +32,22 @@ the following form, called the "JSON envelope":
2932

3033
See [Protocol](protocol.md) for a definition of parameters and functions.
3134

32-
Base64() is [Base64 encoding](https://tools.ietf.org/html/rfc4648), transforming
33-
a byte sequence to a unicode string. Either standard or URL-safe encoding is
34-
allowed.
35+
Exactly one of `payload` or `payloadUtf8` MUST be set:
36+
37+
- `payload` supports arbitrary SERIALIZED_BODY.
38+
[Base64Encode()](https://tools.ietf.org/html/rfc4648) transforms a byte
39+
sequence to a Unicode string. Base64 has a fixed 33% space overhead but
40+
supports payloads that are not necessarily valid UTF-8. Either standard or
41+
URL-safe encoding is allowed.
42+
43+
- `payloadUtf8` only supports valid
44+
[UTF-8](https://tools.ietf.org/html/rfc3629) SERIALIZED_BODY. `Utf8Decode()`
45+
converts that UTF-8 byte sequence to a Unicode string. Regular JSON string
46+
escaping applies, but this is usually more compact and amenable to
47+
compression than Base64.
48+
49+
Note: The choice of `payload` vs `payloadUtf8` does not impact the
50+
[the signing or the signatures](protocol.md#signature-definition).
3551

3652
### Multiple signatures
3753

@@ -54,8 +70,8 @@ envelopes with individual signatures.
5470

5571
### Parsing rules
5672

57-
* The following fields are REQUIRED and MUST be set, even if empty: `payload`,
58-
`payloadType`, `signature`, `signature.sig`.
73+
* The following fields are REQUIRED and MUST be set, even if empty:
74+
exactly one of {`payload` or `payloadUtf8`}, `payloadType`, `signature`, `signature.sig`.
5975
* The following fields are OPTIONAL and MAY be unset: `signature.keyid`.
6076
An unset field MUST be treated the same as set-but-empty.
6177
* Producers, or future versions of the spec, MAY add additional fields.
@@ -75,5 +91,8 @@ At this point we do not standardize any other encoding. If a need arises, we may
7591
do so in the future.
7692

7793
## Change history
94+
* 1.1.0:
95+
* Added support for UTF-8 encoded payload and `payloadUtf8` field.
96+
7897
* 1.0.0: Initial version.
7998

envelope.proto

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ package io.intoto;
44

55
// An authenticated message of arbitrary type.
66
message Envelope {
7-
// Message to be signed. (In JSON, this is encoded as base64.)
7+
// Message to be signed.
88
// REQUIRED.
9-
bytes payload = 1;
10-
9+
oneof payload_encoding {
10+
// Raw bytes. In JSON, this is encoded as base64.
11+
bytes payload = 1;
12+
// Unicode string, where the signed byte stream (SERIALIZED_BODY) is the UTF-8 encoding of `payloadUtf8`. In JSON, this is a regular string.
13+
string payloadUtf8 = 4;
14+
}
15+
1116
// String unambiguously identifying how to interpret payload.
1217
// REQUIRED.
1318
string payloadType = 2;

0 commit comments

Comments
 (0)