Meshline
简体中文规范下载 Markdown 原文

中文为规范基准;英文为维护译本。

消息加密测试向量执行说明

规范测试向量 · 通用执行规则

覆盖范围

文件:message-encryption-v1.json。章节为 envelope_signature、payload、timeline 和 notification。

固定输入与引用

envelope_signature 提供签名输入与结果,payload 提供消息加密及密钥盒的固定输入与结果。timeline 包含完整请求及收发双方密钥盒;notification 使用该请求的信封、证书和密钥盒执行字段、签名及重试校验。

外围引用按下表还原:

引用字段 同文件目标
envelope_signature.unsigned_object_ref /payload/encryption/envelope
envelope_signature.recipient_boxes_ref /payload/encryption/recipient_boxes
notification.base_envelope_ref、notification.variants[].envelope_ref /timeline/request/envelope
notification.signing_private_key_ref、notification.signing_public_key_ref /timeline/sender_signing_private_key、/timeline/request/signer_certificate/signing_public_key
notification.variants[].signing_input_utf8_hex_ref /timeline/envelope_signing_input_utf8_hex
notification.signature_tampering[].envelope_ref、notification.retry_cases[].accepted_envelope_ref、notification.retry_cases[].retry_envelope_ref 原始信封或 /notification/variants/1/envelope、/notification/variants/2/envelope 中的完整信封

每项测试独立复制指定信封,先删除 remove 列出的根字段,再新增或替换 set 给出的根字段。

执行步骤与断言

信封校验与收件方解密

从还原的未签名信封重建签名输入,比对给定输入与签名,并验证签名。执行收件方密钥盒解封及正文解密,逐项比对 AAD、密钥派生与加解密结果。

notification.variants 逐项重建并比对 signing_input_utf8_hex 和 device_signature,验证信封格式及签名;沿用 timeline 的固定输入复算消息 AAD、收发双方密钥盒和 payload 加解密,与原向量的中间值及加解密结果比对。

notification.field_cases 在 base_envelope 上应用操作,比较字段校验结果与 expected_format_valid;格式有效时再比较 expected_allows_push,本组不验证签名。notification.signature_tampering 对指定信封应用操作并保留原签名,重建签名输入后比较 expected_signature_valid。

AAD 认证拒绝

payload.aad_rejection_cases 使用 payload.encryption 的固定内容密钥、nonce 和密文。先从该信封与 network_context 重建消息 AAD 对象,再用各项 aad_overrides 替换指定输入字段,重新生成 Canonical JSON bytes 后直接执行 AES-GCM 认证解密;expected_authenticated: false 要求认证失败且不交付明文。

覆盖消息 ID、创建时间、发送账户、发送设备、目标账户及网络编号和 Registry 地址分别变化的上下文错配;不得仅以信封验签失败代替该认证解密检查。

收发双方密钥盒

timeline 中密钥盒的 KDF/AAD 输入、共享秘密、封装密钥和解密结果都是精确协议 bytes;实现还必须确认原信封设备签名有效,并能通过发送方密钥盒解密同一 payload。

幂等重试

notification.retry_cases 在 accepted_envelope 已被接受、结果仍在保留期且其他调用条件有效的前提下,对 notification.retry_methods 中每个方法独立执行;保持其他请求参数不变,以 retry_envelope 替换信封。expected_result 为 original_result 时返回原消息当前已知的投递结果,为 state_conflict 时拒绝冲突请求。expected_new_timeline_records 和 expected_new_push_triggers 分别统计本次重试新增的时间线记录和离线推送触发数。