refactor(crypto): 拆分签发与验证,新增 sign 包
- crypto 仅保留验证:验签、信任链、CRL/verdict、指纹 - 新增 sign 包:SignToken/SignBundle、密钥生成、私钥加解密 - TrustChain 移除 SignBundle 方法,改由 Bundle() 导出快照, 避免反射可达性把 SignToken 链入纯验证二进制 - Bundle 快照单次读锁,修复旧 SignBundle 递归读锁死锁窗口 - 新增 golden token 与 go tool nm 符号级回归测试
This commit is contained in:
21 files changed
+461
-168
No files matched your search
+2
-2
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// SignFunc 签名输入为 "HEADER_B64.PAYLOAD_B64"(ASCII),返回签名字节。
|
||||
// 由 internal/crypto 提供真实实现;本包不感知具体算法(依赖单向:crypto → license)。
|
||||
// 由 sign 包提供真实实现;本包不感知具体算法(依赖单向:sign/crypto → license)。
|
||||
type SignFunc func(content string) ([]byte, error)
|
||||
|
||||
const (
|
||||
@@ -46,7 +46,7 @@ func Encode(h Header, payload []byte, sign SignFunc) (string, error) {
|
||||
|
||||
// Decode 拆解三段式 token,返回 header、payload 字节与签名。
|
||||
// 只做结构级校验(段数、base64、header 白名单、payload JSON 合法性);
|
||||
// 验签与语义校验由 internal/crypto.VerifyToken 编排。
|
||||
// 验签与语义校验由 crypto.VerifyToken 编排。
|
||||
func Decode(token string) (Header, []byte, []byte, error) {
|
||||
parts := strings.Split(token, ".")
|
||||
if len(parts) != numTokenParts {
|
||||
|
||||
Reference in new issue
Block a user