3. RFC 3161 Timestamp Tokens: COSE Header Parameters
第 2.2 节和第 2.1 节描述的两种模式向时间戳机制提供不同输入, 因而在 COSE 与 TST 之间创建不同类型的绑定. 为清晰区分它们的语义, 本文档按以下小节定义两个不同的 COSE header parameters.
3.1. 3161-ctt
3161-ctt COSE unprotected header parameter 必须用于第 2.1 节描述的模式.
3161-ctt unprotected header parameter 包含以 CBOR byte string (Major type 2) 包装的 DER-encoded TST [RFC3161].
发送给 TSA 的请求中的 MessageImprint 必须是:
-
COSE_Sign1 message 的 CBOR-encoded signature 字段的哈希值, 或
-
COSE_Sign message 的 CBOR-encoded signatures 字段的哈希值.
在任一情况下, 为尽量减少依赖, 哈希算法应该与用于签署 COSE message 的算法相同. 如果 timestamp token 是在组装 COSE object 的处理上下文之外获得的, 这可能无法实现.
有关 MessageImprint 计算的具体示例, 参见第 3.1.1 节和第 3.1.2 节.
3.1.1. COSE_Sign1 的 MessageImprint 计算
以下展示了如何使用一个 COSE_Sign1 message 示例计算 MessageImprint.
给定 COSE_Sign1 message:
18(
[
/ protected h'a10126' / << {
/ alg / 1:-7 / ECDSA 256 /
} >>,
/ unprotected / {
/ kid / 4:'11'
},
/ payload / 'This is the content.',
/ signature / h'8eb33e4ca31d1c465ab05aac34cc6b23d58fef5c083106c4
d25a91aef0b0117e2af9a291aa32e14ab834dc56ed2a223444547e01f11d3b0916e5
a4c345cacb36'
]
)
bstr-wrapped signature:
58 40 # bytes(64)
8eb33e4ca31d1c465ab05aac34cc6b23
d58fef5c083106c4d25a91aef0b0117e
2af9a291aa32e14ab834dc56ed2a2234
44547e01f11d3b0916e5a4c345cacb36
(包括 heading bytes 0x5840) 被用作计算 MessageImprint 的输入.
使用 SHA-256 时, 得到的 MessageImprint 为:
SEQUENCE {
SEQUENCE {
OBJECT IDENTIFIER sha-256 (2 16 840 1 101 3 4 2 1)
NULL
}
OCTET STRING
44 C2 41 9D 13 1D 53 D5 55 84 B5 DD 33 B7 88 C2
4E 55 1C 6D 44 B1 AF C8 B2 B8 5E 69 54 76 3B 4E
}
3.1.2. COSE_Sign 的 MessageImprint 计算
以下展示了如何使用一个 COSE_Sign message 示例计算 MessageImprint.
给定 COSE_Sign message:
98(
[
/ protected / h'',
/ unprotected / {},
/ payload / 'This is the content.',
/ signatures / [
[
/ protected h'a10126' / << {
/ alg / 1:-7 / ECDSA 256 /
} >>,
/ unprotected / {
/ kid / 4:'11'
},
/ signature / h'e2aeafd40d69d19dfe6e52077c5d7ff4e408282cbefb
5d06cbf414af2e19d982ac45ac98b8544c908b4507de1e90b717c3d34816fe926a2b
98f53afd2fa0f30a'
]
]
]
)
signatures array:
81 # array(1)
83 # array(3)
43 # bytes(3)
a10126
a1 # map(1)
04 # unsigned(4)
42 # bytes(2)
3131 # "11"
58 40 # bytes(64)
e2aeafd40d69d19dfe6e52077c5d7ff4
e408282cbefb5d06cbf414af2e19d982
ac45ac98b8544c908b4507de1e90b717
c3d34816fe926a2b98f53afd2fa0f30a
被用作计算 MessageImprint 的输入.
使用 SHA-256 时, 得到的 MessageImprint 为:
SEQUENCE {
SEQUENCE {
OBJECT IDENTIFIER sha-256 (2 16 840 1 101 3 4 2 1)
NULL
}
OCTET STRING
80 3F AD A2 91 2D 6B 7A 83 3A 27 BD 96 1C C0 5B
C1 CC 16 47 59 B1 C5 6F 7A A7 71 E4 E2 15 26 F7
}
3.2. 3161-ttc
3161-ttc COSE protected header parameter 必须用于第 2.2 节描述的模式.
3161-ttc protected header parameter 包含以 CBOR byte string (Major type 2) 包装的 DER-encoded TST [RFC3161].
发送给 TSA 的 MessageImprint ([RFC3161] 第 2.4 节) 必须是 COSE Signed Message 的 payload 的哈希值. 这不包括 bstr 包装, 只包括 payload bytes. (示例见 Appendix A.1.)
为尽量减少依赖, 用于签署 COSE message 的哈希算法应该与 MessageImprint [RFC3161] 中使用的算法相同. 但是, 如果 timestamp requester 和 COSE message signer 是不同实体, 这可能无法实现.