Skip to content

Commit f0518cf

Browse files
committed
Replace magic payloadType with explicit sigType.
Previously the switch between normal and "backwards compatible json" mode was determined by a magic `payloadType`. The downside of this approach was that it was undiscoverable: readers would not know this magic value existed. Now this behavior is made explicit via a `signatures.sigType` field. The new string better explains the behavior, which is that the payload must be JSON and that `payloadType` is unauthenticated.
1 parent cd962c1 commit f0518cf

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

specification.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,28 @@ The signature format is a JSON message of the following form:
4040
```
4141

4242
Empty fields may be omitted. [Multiple signatures](#multiple-signatures) are
43-
allowed.
43+
allowed. Note that an optional `signature.sigType` field may be present but
44+
empty for compatibility with [backwards compatible signature] mode.
4445

4546
Parameters:
4647

4748
* SERIALIZED_BODY is the byte sequence to be signed.
4849

49-
* PAYLOAD_TYPE is a URI indicating how to interpret SERIALIZED_BODY. It
50-
encompasses the content type (JSON, Canonical-JSON, CBOR, etc.), the
51-
purpose, and the schema version of the payload. This obviates the need for
52-
the `_type` field within in-toto/TUF payloads. This URI does not need to be
53-
resolved to a remote resource, nor does such a resource need to be fetched.
54-
Examples:
50+
* PAYLOAD_TYPE is an authenticated(*) URI indicating how to interpret
51+
SERIALIZED_BODY. It encompasses the content type (JSON, Canonical-JSON,
52+
CBOR, etc.), the purpose, and the schema version of the payload. This
53+
obviates the need for the `_type` field within in-toto/TUF payloads. This
54+
URI does not need to be resolved to a remote resource, nor does such a
55+
resource need to be fetched. Examples:
5556

5657
- https://in-toto.io/Link/v0.9
5758
- https://in-toto.io/Layout/v0.9
5859
- https://theupdateframework.com/Root/v1.0.5
5960
- etc...
6061

62+
(*) Exception: PAYLOAD_TYPE is unauthenticated if `signature.sigType ==
63+
"raw-json-no-payload-type"`.
64+
6165
* KEYID is an optional, unauthenticated hint indicating what key was used to
6266
sign the message. It **must not** be used for security decisions.
6367

@@ -102,6 +106,9 @@ To sign:
102106
103107
To verify:
104108
109+
- If `sigType == "raw-json-no-payload-type"`, use
110+
[backwards compatible signature] instead. Reject if `sigType` is any other
111+
non-empty value.
105112
- Base64-decode `payload`; call this SERIALIZED_BODY. Reject if the decoding
106113
fails.
107114
- Base64-decode `sig` and verify PAE(UTF8(PAYLOAD_TYPE), SERIALIZED_BODY).
@@ -122,30 +129,31 @@ valid while avoiding the verifier from having to use [Canonical JSON].
122129
123130
```json
124131
{
125-
"payload": "<Base64(CanonicalJson(BODY))>",
126-
"payloadType": "<URI>/backwards-compatible-json",
132+
"payload": "<Base64(SERIALIZED_BODY)>",
127133
"signatures" : [{
128134
"keyid": "<KEYID>",
129-
"sig": "<Base64(Sign(CanonicalJson(BODY)))>"
135+
"sigType": "raw-json-no-payload-type",
136+
"sig" : "<Base64(Sign(SERIALIZED_BODY))>"
130137
}]
131138
}
132139
```
133140

134-
Support for this backwards compatibility mode is optional.
141+
Support for this backwards compatibility mode is optional and should be disabled
142+
by default.
135143

136144
To sign:
137145

138-
- BODY **must** be an object type (`{...}`).
139-
- Serialize BODY as [Canonical JSON]; call this SERIALIZED_BODY.
146+
- The message **must** be an object type (`{...}`).
147+
- Serialize the message as [Canonical JSON]; call this SERIALIZED_BODY.
140148
- Sign SERIALIZED_BODY, base64-encode the result, and store it in `sig`.
149+
- Store `"raw-json-no-payload-type"` in `sigType`.
141150
- Optionally, compute a KEYID and store it in `keyid`.
142151
- Base64-encode SERIALIZED_BODY and store it in `payload`.
143-
- Store `"<URI>/backwards-compatible-json"` in `payloadType`.
144152

145153
To verify:
146154

147-
- If `payloadType` != `"<URI>/backwards-compatible-json"`, use the normal
148-
verification process instead of this one.
155+
- If `sigType != "raw-json-no-payload-type"`, use the
156+
[normal verification process](#steps) instead of this one.
149157
- Base64-decode `payload`; call this SERIALIZED_BODY. Reject if the decoding
150158
fails.
151159
- Base64-decode `sig` and verify SERIALIZED_BODY. Reject if either the
@@ -154,6 +162,7 @@ To verify:
154162
the result is not a JSON object. In particular, the first byte of
155163
SERIALIZED_BODY must be `{`. Verifiers **must not** require SERIALIZED_BODY
156164
to be Canonical JSON.
165+
- Discard `payloadType` if present.
157166

158167
Backwards compatible signatures are not recommended because they lack the
159168
authenticated payloadType indicator.
@@ -334,18 +343,20 @@ To detect whether a signature is in the old or new format:
334343
To convert an existing signature to the new format:
335344

336345
- `new.payload = base64encode(CanonicalJson(orig.signed))`
337-
- `new.payloadType = "<URI>/backwards-compatible-json"`
346+
- `new.signatures[*].sigType = "raw-json-no-payload-type"`
338347
- `new.signatures[*].sig = base64encode(hexdecode(orig.signatures[*].sig))`
339348
- `new.signatures[*].keyid = orig.signatures[*].keyid`
340349

341-
To convert a backwards compatible signature to the old format:
350+
To convert a [backwards compatible signature] to the old format:
342351

343352
- `old.signed = jsonparse(base64decode(new.payload))`
344353
- `old.signatures[*].sig = hexencode(base64decode(new.signatures[*].sig))`
345354
- `old.signatures[*].keyid = new.signatures[*].keyid`
346355

347356
## Testing
348357

358+
TODO: Update reference implementation with this new design.
359+
349360
See [reference implementation](reference_implementation.ipynb). Here is an
350361
example.
351362

0 commit comments

Comments
 (0)