Skip to content

Commit f52d4a6

Browse files
authored
Merge pull request #13 from MarkLodato/sig-type
Replace magic payloadType with explicit sigType.
2 parents 5950b31 + fba2968 commit f52d4a6

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

specification.md

Lines changed: 32 additions & 23 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 and algorithm
6266
was used to sign the message. As with Sign(), details are agreed upon
6367
out-of-band by the signer and verifier. It **MUST NOT** be used for security
@@ -105,6 +109,9 @@ To sign:
105109
106110
To verify:
107111
112+
- If `sigType == "raw-json-no-payload-type"`, use
113+
[backwards compatible signature] instead. Reject if `sigType` is any other
114+
non-empty value.
108115
- Base64-decode `payload`; call this SERIALIZED_BODY. Reject if the decoding
109116
fails.
110117
- Base64-decode `sig` and verify PAE(UTF8(PAYLOAD_TYPE), SERIALIZED_BODY).
@@ -119,44 +126,46 @@ either, and verifiers **MUST** accept either.
119126
### Backwards compatible signatures
120127
121128
To convert existing signatures from the current format to the new format,
122-
`"backwards-compatible-json"` is added to the payload type URI to indicate that
129+
`"raw-json-no-payload-type"` is added to the payload type URI to indicate that
123130
the signature is over the raw payload. This allows the signatures to remain
124131
valid while avoiding the verifier from having to use [Canonical JSON].
125132
126133
```json
127134
{
128-
"payload": "<Base64(CanonicalJson(BODY))>",
129-
"payloadType": "<URI>/backwards-compatible-json",
135+
"payload": "<Base64(SERIALIZED_BODY)>",
130136
"signatures" : [{
131137
"keyid": "<KEYID>",
132-
"sig": "<Base64(Sign(CanonicalJson(BODY)))>"
138+
"sigType": "raw-json-no-payload-type",
139+
"sig" : "<Base64(Sign(SERIALIZED_BODY))>"
133140
}]
134141
}
135142
```
136143

137-
Support for this backwards compatibility mode is optional.
144+
Support for this backwards compatibility mode is optional and should be disabled
145+
by default.
138146

139147
To sign:
140148

141-
- BODY **MUST** be an object type (`{...}`).
142-
- Serialize BODY as [Canonical JSON]; call this SERIALIZED_BODY.
149+
- The message **MUST** be an object type (`{...}`).
150+
- Serialize the message as [Canonical JSON]; call this SERIALIZED_BODY.
143151
- Sign SERIALIZED_BODY, base64-encode the result, and store it in `sig`.
152+
- Store `"raw-json-no-payload-type"` in `sigType`.
144153
- Optionally, compute a KEYID and store it in `keyid`.
145154
- Base64-encode SERIALIZED_BODY and store it in `payload`.
146-
- Store `"<URI>/backwards-compatible-json"` in `payloadType`.
147155

148156
To verify:
149157

150-
- If `payloadType` != `"<URI>/backwards-compatible-json"`, use the normal
151-
verification process instead of this one.
158+
- If `sigType != "raw-json-no-payload-type"`, use the
159+
[normal verification process](#steps) instead of this one.
152160
- Base64-decode `payload`; call this SERIALIZED_BODY. Reject if the decoding
153161
fails.
154162
- Base64-decode `sig` and verify SERIALIZED_BODY. Reject if either the
155163
decoding or the signature verification fails.
156164
- Parse SERIALIZED_BODY as a JSON object. Reject if the parsing fails or if
157165
the result is not a JSON object. In particular, the first byte of
158-
SERIALIZED_BODY **MUST** be `{`. Verifiers **MUST NOT** require SERIALIZED_BODY
159-
to be Canonical JSON.
166+
SERIALIZED_BODY **MUST** be `{`. Verifiers **MUST NOT** require
167+
SERIALIZED_BODY to be Canonical JSON.
168+
- Discard `payloadType` if present.
160169

161170
Backwards compatible signatures are not recommended because they lack the
162171
authenticated payloadType indicator.
@@ -280,8 +289,8 @@ Rationales for specific decisions:
280289
payloadType were not signed.
281290
- Also, URIs don't need to be registered while Media Types do.
282291

283-
- Why use payloadType "backwards-compatible-json" instead of assuming
284-
backwards compatible mode if payloadType is absent?
292+
- Why use payloadType "raw-json-no-payload-type" instead of assuming backwards
293+
compatible mode if payloadType is absent?
285294

286295
- We wanted to leave open the possibility of having an
287296
application-specific "default" value if payloadType is unspecified,
@@ -337,11 +346,11 @@ To detect whether a signature is in the old or new format:
337346
To convert an existing signature to the new format:
338347

339348
- `new.payload = base64encode(CanonicalJson(orig.signed))`
340-
- `new.payloadType = "<URI>/backwards-compatible-json"`
349+
- `new.signatures[*].sigType = "raw-json-no-payload-type"`
341350
- `new.signatures[*].sig = base64encode(hexdecode(orig.signatures[*].sig))`
342351
- `new.signatures[*].keyid = orig.signatures[*].keyid`
343352

344-
To convert a backwards compatible signature to the old format:
353+
To convert a [backwards compatible signature] to the old format:
345354

346355
- `old.signed = jsonparse(base64decode(new.payload))`
347356
- `old.signatures[*].sig = hexencode(base64decode(new.signatures[*].sig))`

0 commit comments

Comments
 (0)