Help us shape the future of Go! Take the 2026 Go Developer Survey

signeddata

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package signeddata 实现 GB/T 35275 的 SM2/SM3 SignedData 与原文字节绑定。

Index

Constants

View Source
const MaxBytes = 4 << 20

Variables

View Source
var (
	ErrInvalid     = errors.New("signeddata: 无效的签名消息")
	ErrUnsupported = errors.New("signeddata: 未支持的签名消息")
)

Functions

func Create

func Create(original, certificateDER []byte, signer crypto.Signer, opt Options) ([]byte, error)

Create 生成 detached GB/T 35275 SignedData;Signer.Sign 接收完整 DER 签名属性 和 sm2.NewSM2SignerOption(true, UID)。函数不创建或保存私钥。

Types

type Options

type Options struct {
	Time          time.Time
	UID           []byte
	Intermediates [][]byte
	Timestamp     func([]byte) ([]byte, error)
}

Options 由外部签名器或硬件适配器提供密钥及时间戳服务。

type Proof

type Proof struct {
	Signer         *smx509.Certificate
	Certificates   []*smx509.Certificate
	SigningTime    time.Time
	Timestamp      *ses.TimestampProof
	TimestampError error
}

Proof 只报告数学和字节绑定证据;证书信任及吊销状态由上层验证。

func Verify

func Verify(value, original, uid []byte) (*Proof, error)

Verify 校验 attached/detached SignedData 绑定完整原始文件字节,不做 XML 规范化。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL