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

signeddata

package
v0.1.7 Latest Latest
Warning

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

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

Documentation

Overview

Package signeddata 实现 SM2/SM3 GB/T 35275 和 RSA/ECDSA CMS SignedData 的原文字节绑定。

Index

Constants

View Source
const (
	SM2WithSM3      = "1.2.156.10197.1.501"
	SHA256WithRSA   = "1.2.840.113549.1.1.11"
	SHA384WithRSA   = "1.2.840.113549.1.1.12"
	SHA512WithRSA   = "1.2.840.113549.1.1.13"
	ECDSAWithSHA256 = "1.2.840.10045.4.3.2"
	ECDSAWithSHA384 = "1.2.840.10045.4.3.3"
	ECDSAWithSHA512 = "1.2.840.10045.4.3.4"
)

算法值采用组合签名 OID,供 OFD SignatureMethod 与签名器选项共用。

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 SignedData;SM2 使用 GB/T 35275,RSA/ECDSA 使用 RFC 5652 CMS。函数不创建或保存私钥,Signer.Sign 参数约定见 Options。

func SupportsAlgorithm added in v0.1.7

func SupportsAlgorithm(method string) bool

SupportsAlgorithm 判断 OFD SignatureMethod 是否为已支持的组合签名 OID。

Types

type Options

type Options struct {
	// Algorithm 为组合签名算法 OID;缺省 SM2WithSM3。RSA/ECDSA 对签名属性的
	// SHA-2 摘要调用 Signer.Sign,SM2 则传完整属性和 SM2 专用签名选项。
	Algorithm     string
	Time          time.Time
	UID           []byte
	Intermediates [][]byte
	Timestamp     func([]byte) ([]byte, error)
}

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

type Proof

type Proof struct {
	Algorithm      string
	Format         string
	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