@@ -15,63 +15,81 @@ misinterpretation of the payload. The serialized payload is encoded as a string
15
15
and verified by the recipient _ before_ deserializing. A backwards compatible
16
16
variant is available.
17
17
18
- ## Specification
18
+ ## Overview
19
19
20
20
$signing_spec does not rely on Canonical JSON, nor any other canonicalization
21
21
scheme. Instead, the producer records the signed bytes exactly as signed and the
22
22
consumer verifies those exact bytes before parsing. In addition, the signature
23
23
now includes an authenticated ` payloadType ` field indicating how to interpret
24
24
the payload.
25
25
26
+ ## Specification
27
+
28
+ The signature format is a JSON message of the following form:
29
+
26
30
``` json
27
31
{
28
32
"payload" : " <Base64(SERIALIZED_BODY)>" ,
29
33
"payloadType" : " <PAYLOAD_TYPE>" ,
30
34
"signatures" : [{
31
35
…,
32
- "sig" : " <Base64(Sign(PAE([PAYLOAD_TYPE, SERIALIZED_BODY])))>"
36
+ "sig" : " <Base64(Sign(PAE([UTF8( PAYLOAD_TYPE) , SERIALIZED_BODY])))>"
33
37
}, … ]
34
38
}
35
39
```
36
40
37
- where PAE is the
38
- [ PASETO Pre-Authentication Encoding] ( https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Common.md#authentication-padding ) :
41
+ where:
39
42
40
- ``` none
41
- PAE([type, body]) := le64(2) || le64(len(type)) || type || le64(len(body)) || body
42
- le64(n) := 64-bit little-endian encoding of `n`, where 0 <= n < 2^63
43
- ```
43
+ * SERIALIZED_BODY is the byte sequence to be signed.
44
+
45
+ * PAYLOAD_TYPE is a URI indicating how to interpret SERIALIZED_BODY. It
46
+ encompasses the content type (JSON, Canonical-JSON, CBOR, etc.), the
47
+ purpose, and the schema version of the payload. This obviates the need for
48
+ the ` _type ` field within in-toto/TUF payloads. This URI does not need to be
49
+ resolved to a remote resource, nor does such a resource need to be fetched.
50
+ Examples:
51
+
52
+ - https://in-toto.io/Link/v0.9
53
+ - https://in-toto.io/Layout/v0.9
54
+ - https://theupdateframework.com/Root/v1.0.5
55
+ - etc...
56
+
57
+ * PAE() is the
58
+ [ PASETO Pre-Authentication Encoding] ( https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Common.md#authentication-padding ) ,
59
+ where parameters ` type ` and ` body ` are byte sequences:
60
+
61
+ ``` none
62
+ PAE([type, body]) := le64(2) || le64(len(type)) || type || le64(len(body)) || body
63
+ le64(n) := 64-bit little-endian encoding of `n`, where 0 <= n < 2^63
64
+ ```
44
65
45
- The PAYLOAD_TYPE is a URI indicating how to interpret SERIALIZED_BODY. It
46
- encompasses the content type (JSON, Canonical-JSON, CBOR, etc.), the purpose,
47
- and the schema version of the payload. This obviates the need for the ` _type `
48
- field within in-toto/TUF payloads. This URI does not need to be resolved to a
49
- remote resource, nor does such a resource need to be fetched. Examples:
66
+ * Sign() is an arbitrary digital signature format. Details must be agreed upon
67
+ out-of-band by the signer and verifier. This specification places no
68
+ restriction on the signature algorithm or format.
50
69
51
- - https://in-toto.io/Link/v0.9
52
- - https://in-toto.io/Layout/v0.9
53
- - https://theupdateframework.com/Root/v1.0.5
54
- - etc...
70
+ * UTF8() is [UTF-8 encoding](https://tools.ietf.org/html/rfc3629),
71
+ transforming a unicode string to a byte sequence.
55
72
56
- The switch from Hex to Base64 for ` sig ` is to save space and to be consistent
57
- with ` payload ` .
73
+ * Base64() is [Base64 encoding](https://tools.ietf.org/html/rfc4648),
74
+ transforming a byte sequence to a unicode string. Either standard or
75
+ URL-safe encoding is allowed.
58
76
59
77
### Steps
60
78
61
79
To sign:
62
80
63
81
- Serialize BODY according to PAYLOAD_TYPE. Call the result SERIALIZED_BODY.
64
- - Sign PAE([ PAYLOAD_TYPE, SERIALIZED_BODY] ), base64-encode the result, and
65
- store it in ` sig ` .
82
+ - Sign PAE([UTF8( PAYLOAD_TYPE) , SERIALIZED_BODY]), base64-encode the result,
83
+ and store it in `sig`.
66
84
- Base64-encode SERIALIZED_BODY and store it in `payload`.
67
85
- Store PAYLOAD_TYPE in `payloadType`.
68
86
69
87
To verify:
70
88
71
89
- Base64-decode `payload`; call this SERIALIZED_BODY. Reject if the decoding
72
90
fails.
73
- - Base64-decode ` sig ` and verify PAE([ PAYLOAD_TYPE, SERIALIZED_BODY] ). Reject
74
- if either the decoding or the signature verification fails.
91
+ - Base64-decode `sig` and verify PAE([UTF8( PAYLOAD_TYPE) , SERIALIZED_BODY]).
92
+ Reject if either the decoding or the signature verification fails.
75
93
- Parse SERIALIZED_BODY according to PAYLOAD_TYPE. Reject if the parsing
76
94
fails.
77
95
0 commit comments