时间戳的目标是证明签名是在给定时间之前创建的,因此您必须使用时间戳对数字签名和当前时间进行签名。时间戳必须作为无符号属性添加到 CMS 签名中。此外 SignatureTimeStampToken 本身就是一个签名。
要向 CMS 添加时间戳,您可以使用具有 1.2.840.113549.1.9.16.2.14 对象标识符和 ASN.1 类型的 Signature 时间戳属性(以下信息均来自 CMS 和TSPRFC)
SignatureTimeStampToken ::= TimeStampToken
TimeStampToken ::= ContentInfo
-- contentType is id-signedData ([CMS])
-- content is SignedData ([CMS])
SignedData ::= SEQUENCE {
version CMSVersion,
digestAlgorithms DigestAlgorithmIdentifiers,
encapContentInfo EncapsulatedContentInfo,
certificates [0] IMPLICIT CertificateSet OPTIONAL,
crls [1] IMPLICIT RevocationInfoChoices OPTIONAL,
signerInfos SignerInfos }
在 TimeStampToken 中,SignedData 构造的 EncapsulatedContentInfo 类型的字段具有以下含义:
eContentType 是唯一指定内容类型的对象标识符。对于时间戳记令牌,它被定义为:
id-ct-TSTInfo OBJECT IDENTIFIER ::= { iso(1) member-body(2)
us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) ct(1) 4}
eContent 是内容本身,作为八位字节字符串携带。eContent 应为 TSTInfo 的 DER 编码值。
时间戳记令牌不得包含除 TSA 签名之外的任何签名。 TSA 证书的证书标识符 (ESSCertID) 必须作为 signerInfo 属性包含在 SigningCertificate 属性中。
TSTInfo ::= SEQUENCE {
version INTEGER { v1(1) },
policy TSAPolicyId,
messageImprint MessageImprint,
-- MUST have the same value as the similar field in
-- TimeStampReq
serialNumber INTEGER,
-- Time-Stamping users MUST be ready to accommodate integers
-- up to 160 bits.
genTime GeneralizedTime,
accuracy Accuracy OPTIONAL,
ordering BOOLEAN DEFAULT FALSE,
nonce INTEGER OPTIONAL,
-- MUST be present if the similar field was present
-- in TimeStampReq. In that case it MUST have the same value.
tsa [0] GeneralName OPTIONAL,
extensions [1] IMPLICIT Extensions OPTIONAL }
希望这会有所帮助,