版式文档中的电子印章、电子签章、时间戳

admin 2026-04-10 02:52:39 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 文档系统解析了电子印章、电子签章与时间戳在OFD版式文档中的技术实现与法律效力,基于国密算法(SM2/SM3/SM4)和GB/T38540-2020等标准,详细阐述了电子印章的数据结构、签章流程(包括十步验证机制)及时间戳的第三方时间绑定作用,强调三者协同构建数字信任体系,并列出《电子签名法》等法律依据确保电子文件与纸质文件同等法律效力。 综合评分: 88 文章分类: 技术标准,政策法规,数据安全,应用安全,网络安全


cover_image

版式文档中的电子印章、电子签章、时间戳

原创

利刃信安 利刃信安

利刃信安

2026年4月7日 03:03 北京

版式文档中的电子印章、电子签章、时间戳

一张电子合同盖了章,凭什么和纸质盖章具有同等法律效力?这背后是一套精密运转的密码学体系——电子印章、电子签章与时间戳三者协同工作,共同构建了数字世界的”信任基石”。


从一枚实物印章说起

在物理世界里,一枚印章之所以被信任,是因为它承载了三重保障:

  1. 1. 来源可信 — 印章由权威机构刻制,他人无法伪造
  2. 2. 内容绑定 — 盖在文件上后,印章与文件内容融为一体
  3. 3. 时间证明 — 文件上的日期记录了盖章发生的时刻

那么问题来了:到了数字世界,这三个保障如何实现?

答案是:密码技术。具体来说,就是我国自主研发的国密算法体系(SM2/SM3/SM4)支撑下的三大机制——电子印章、电子签章、时间戳


电子印章:数字化的”身份+权限”载体

它是什么?

电子印章不是一张图片,而是一段经过密码学处理的结构化数据。它的核心定义来自国家标准 GB/T 38540-2020《信息安全技术 安全电子签章密码技术规范》

SESeal ::= SEQUENCE {
    eSealInfo    SES_SealInfo,      -- 印章全部属性信息
    cert          OCTET STRING,     -- 制章者证书(DER编码)
    signAlgID     OBJECT IDENTIFIER,-- 签名算法标识(如 SM2+SM3: 1.2.156.10197.1.501)
    signedValue   BIT STRING        -- 制章者对印章信息的签名值
}

注意那个 signedValue 字段——这是整枚电子印章的灵魂。制章者用自己的 SM2 私钥对印章的全部属性(印模图像、名称、有效期、授权人证书列表等)进行了数字签名。这意味着:任何人都可以用制章者的公钥验证这枚印章是否被篡改过

它包含什么?

| 组成部分 | 说明 | | — | — | | SES_Header | 头部标识(固定值 "ES",版本号 4) | | esID | 全国唯一编码 | | property | 名称、类型、有效期、签章者证书列表 | | picture | 印模图像(支持 BMP/JPG/PNG/SVG 格式) | | signedValue | ⭐ 制章者 SM2 签名值 |

关键点:印章里还嵌入了签章者证书列表——这意味着只有名单上的人才能使用这枚印章来签文件。


电子签章:把印章”盖”到文件上的过程

核心数据结构

当我们要对一份 OFD 版式文档进行签章时,产生的数据结构如下(同样来自 GB/T 38540-2020):

SES_Signature ::= SEQUENCE {
    toSign         TBS_Sign,           -- 待签名信息(签章信息)
    cert           OCTET STRING,       -- 签章者证书(DER编码)
    signatureAlgID  OBJECT IDENTIFIER, -- 签名算法 OID
    signature      BIT STRING,        -- ⭐ 签章者的 SM2 签名值 (r, s)
    timeStamp[0]   BIT STRING OPTIONAL -- 时间戳(可选但重要)
}

其中最核心的是 TBS_Sign(To Be Signed,待签名信息):

TBS_Sign ::= SEQUENCE {
    version      INTEGER,         -- 电子签章版本号(与印章版本号保持一致)
    eseal        SESeal,          -- 引用的电子印章
    timeInfo     GeneralizedTime, -- 签章时间
    dataHash      BIT STRING,     -- ⭐ 原文的 SM3 杂凑值(注意是 BIT STRING 类型)
    propertyInfo  IA5String,       -- 原文属性(含签名保护范围等,注意是 IA5 String 类型)
    extDatas[0]   ExtensionDatas OPTIONAL -- 自定义扩展数据
}

类型提示dataHash 为 BIT STRING 而非 OCTET STRINGpropertyInfo 为 IA5 String 而非复杂结构体——这是 GB/T 38540-2020 的明确定义,容易混淆,需特别注意。

签章过程(三步走)

步骤①: 验证印章有效性
  → 格式检查 → 签名值验签 → 证书信任链 → 有效期校验

步骤②: 对原文进行签名
  → 按 propertyInfo 指定的保护范围提取原文
  → 计算 SM3 杂凑值 → 得到 dataHash
  → 组装 TBS_Sign {eseal + timeInfo + dataHash + propertyInfo}
  → 用签章者 SM2 私钥对 TBS_Sign 签名 → 得到 signature(r,s)

步骤③: [可选] 申请时间戳
  → 将签名值发给 TSA(时间戳机构)→ 获得带可信时间的戳

验证过程(十道关卡)

一份签了章的 OFD 文件在被验证时,需要通过以下检验(依据 GB/T 38540-2020 第7.3节及 GM/T 0047-2024):

| 序号 | 检验内容 | 不通过的后果 | | — | — | — | | ① | 数据格式解析(ASN.1 解码) | 直接判定无效 | | ② | 内嵌电子印章验证(格式+签名+证书+有效期) | 印章本身不可信 | | ③ | 签名值验签(用签章者公钥验证 signature) | 签名被伪造或篡改 | | ④ | 证书匹配性(签章者证书在印章的证书列表中) | 此人无权使用该印章 | | ⑤ | 签章时刻印章有效性(结合签章时间判断) | 签章时印章已过期/注销 | | ⑥ | 签章时刻印章状态(未被停用) | 签章时印章已被停用 | | ⑦ | 签章者证书有效性(信任链+有效期+吊销状态+密钥用法) | 证书过期或被吊销 | | ⑧ | 签章时间有效性(在证书有效期内且未吊销) | 时间矛盾 | | ⑨ | 原文杂凑一致性(dataHash 与实际原文匹配) | 文件内容被篡改! | | ⑩ | [可选] 时间戳验证(格式+签名+nonce+时间关系) | 时间戳无效或时间矛盾 |

第⑨步是防篡改的核心:如果有人修改了文件内容哪怕一个标点符号,重新计算出的 SM3 杂凑值就会与 dataHash 不匹配,验证立刻失败。


时间戳:独立的第三方时间证人

为什么需要时间戳?

你可能会问:TBS_Sign 里已经有 timeInfo(签章时间)字段了,为什么还要时间戳?

因为 timeInfo 是签章者自己填写的——自报的时间不能作为独立证据。就像你不能自己给自己写一张”我此时此刻在场”的证明一样。

时间戳的作用是引入**可信第三方(TSA,Time Stamp Authority,时间戳机构)**作为时间证人:

签章流程中:
  签章者生成签名(r,s)
       ↓
  将签名值发给 TSA(时间戳机构)
       ↓
  TSA 执行以下操作:
  ① 获取可信时间(来自国家授时中心)
  ② 组装 TSTInfo:
     genTime: "2026-04-07T10:30:00Z",   ← 可信时间
&nbsp; &nbsp; &nbsp;messageImprint: <签名值的SM3杂凑值>, ← 绑定签名值
&nbsp; &nbsp; &nbsp;serialNumber: 12345678, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ← 全局唯一序号
&nbsp; &nbsp; &nbsp;nonce: 987654321 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;← 防重放随机数
&nbsp; ③ 用 TSA 的 SM2 私钥对 TSTInfo 签名
&nbsp; &nbsp; &nbsp; &nbsp;↓
&nbsp; 返回 TimeStampToken 给签章者
&nbsp; &nbsp; &nbsp; &nbsp;↓
&nbsp; 嵌入 SES_Signature.timeStamp 字段(DER 编码)

注:根据 GB/T 38540-2020 第7.2节b)步骤5的规定,时间戳是对签名值产生的——即 messageImprint 中存放的是签名值的 SM3 杂凑值,从而将签章行为与可信时间强绑定。

时间戳解决的关键问题

| 问题 | 时间戳如何解决 | | — | — | | 事后伪造 | genTime 证明签名值在该时刻已存在,无法事后补造 | | 证书过期失效 | 即使签章者证书已过期,时间戳仍能证明签章时的合法状态 | | 重放攻击 | nonce (随机数)确保每个时间戳只能使用一次 | | 时间争议 | genTime 来自国家授时中心等标准时间源,具有独立公信力 |


三者如何协同工作

┌─────────────────────────────────────────────────────┐
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 完整的签章信任链 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│
├─────────────────────────────────────────────────────┤
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; 电子印章 (SESeal) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; ┌─────────────────────┐ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; │ "我是谁 + 我能授权谁" │ ← 制章者 SM2 签名 &nbsp; &nbsp; │
│ &nbsp; └──────────┬──────────┘ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ 被引用 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; 电子签章 (SES_Signature) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│
│ &nbsp; ┌─────────────────────┐ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; │ "我用这个章签了这个文件" │ ← 签章者 SM2 签名 &nbsp; │
│ &nbsp; │ dataHash = SM3(原文) &nbsp;│ ← 绑定文件内容 &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; └──────────┬──────────┘ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│ [可选] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;│
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;▼ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; 时间戳 (TimeStampToken / TSTInfo) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; ┌─────────────────────┐ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; │ "我在这个时间做了这件事" │ ← TSA SM2 签名 &nbsp; &nbsp; &nbsp;│
│ &nbsp; │ genTime = 国家授时中心 &nbsp; │ ← 第三方时间证明 &nbsp; &nbsp; │
│ &nbsp; └─────────────────────┘ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; 验证时: 印章可信 ✓ → 签名正确 ✓ → 内容未篡改 ✓ &nbsp;│
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; → 时间戳可信 ✓ → 全链路闭环 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
│ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; │
└─────────────────────────────────────────────────────┘

在OFD文档中的实际位置

一份签了章的 .ofd 文件(本质是 ZIP 压缩包),内部结构如下:

document.ofd (ZIP)
├── OFD.xml &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;主入口文件(唯一)
├── Doc_1/
│ &nbsp; ├── Document.xml &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 文档根节点
│ &nbsp; └── Page_1/Content.xml &nbsp; &nbsp; &nbsp;页面内容描述
├── Signs/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ⭐ 数字签名目录
│ &nbsp; ├── Signatures.xml &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;签名列表(记录所有签名)
│ &nbsp; └── Sign_1/
│ &nbsp; &nbsp; &nbsp; ├── Signature.xml &nbsp; &nbsp; &nbsp; &nbsp;签章描述(签名方案、保护范围、签名值路径)
│ &nbsp; &nbsp; &nbsp; ├── SignedValue.dat &nbsp; &nbsp; ⭐ 签名值(SES_Signature 的 DER 编码)
│ &nbsp; &nbsp; &nbsp; └── Seal.esl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;⭐ 电子印章(SESeal 的 DER 编码)
└── [Encryptions.xml] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;加密入口(如有加密,OFD 2.0+)

注:根据 GM/T 0099-2020 的规定,Signs/ 目录由签名协议产生。当签名类型为电子签章时,SignedValue.dat 的格式遵循 GB/T 38540(即 SES_Signature);当签名类型为**数字签名(SM2)**时,则遵循 GB/T 35275 / GM/T 0010(即 SignedData 封装格式)。


法律效力从何而来?

这套技术体系之所以能让电子签章与实物盖章具有同等法律效力,其法规和标准依据包括:

  1. 1. 《中华人民共和国电子签名法》 — 确立可靠电子签名的法律地位
  2. 2. 《中华人民共和国密码法》 — 规范密码技术的管理和应用
  3. 3. 《中华人民共和国网络安全法》《数据安全法》 — 网络与数据安全基础
  4. 4. 《电子印章管理办法》(国办发〔2025〕33号) — 明确规定:

“符合本办法规定的电子印章与实物印章具有同等法律效力”

  1. 5. GB/T 33190-2016 — 定义 OFD 版式文档格式(ZIP容器 + XML描述)
  2. 6. GM/T 0099-2020 — 定义 OFD 签名/加密/完整性保护三大协议
  3. 7. GB/T 38540-2020 / GM/T 0031-2025 — 定义电子印章与签章的数据结构和流程
  4. 8. GM/T 0047-2024 — 定义检测方法(17项检测,一票否决制)

最终效果:一份 OFD 电子公文盖上电子签章后,在任何设备上打开都能看到一致的版式布局,且任何人都能验证其真实性(确实是这个人签的)、完整性(文件没被改过)、时间性(确实是在那个时间签的)。


总结

| 组件 | 角色 | 核心密码技术 | 保证什么 | | — | — | — | — | | 电子印章 | 身份+权限载体 | SM2 数字签名 | 印章来源真实、授权关系明确 | | 电子签章 | 盖章动作 | SM2 签名 + SM3 杂凑 | 签名真实、文件完整、不可否认 | | 时间戳 | 时间证人 | SM2 签名 + 可信时间源 | 时间可信、防重放、长期有效 |

三者层层叠加,配合 OFD 版式文档固定布局、不随软硬件环境变化的特性,构成了数字世界中等效于实体盖章的完整信任体系。

而这整套体系背后的核心技术——SM2 椭圆曲线公钥密码、SM3 密码杂凑算法、SM4 分组密码,正是中国自主研发的国密算法体系,已在政务、金融、医疗、电子商务等领域得到广泛应用。

当你在手机上看到一份盖了电子印章的公文时,你知道:那不是一个简单的图片叠加,而是一次涉及多轮密码运算、多方证书验证、第三方时间戳证的精密操作——这就是数字时代”盖章”的真正含义。


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:利刃信安 利刃信安 利刃信安《版式文档中的电子印章、电子签章、时间戳》

评论:0   参与:  0