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
@@ -0,0 +1,23 @@
|
||||
package sign
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"encoding/json"
|
||||
|
||||
"git.wxccs.org/EntitleForge/EntitleForge-SDK-go/crypto"
|
||||
"git.wxccs.org/EntitleForge/EntitleForge-SDK-go/license"
|
||||
)
|
||||
|
||||
// rootKid 是 root 签 trust bundle 时 header.kid 的固定值
|
||||
// (root 唯一,不需要轮换标识;装载方以公钥锚定)。
|
||||
const rootKid = "root"
|
||||
|
||||
// SignBundle 把信任链快照(signing 公钥集合 + CRL)打包为 root 签名的
|
||||
// trust bundle token。快照由 crypto.TrustChain.Bundle 提供,只含公钥数据。
|
||||
func SignBundle(tc *crypto.TrustChain, rootPriv ed25519.PrivateKey) (string, error) {
|
||||
payload, err := json.Marshal(tc.Bundle())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return SignToken(rootPriv, rootKid, license.TypTrust, payload)
|
||||
}
|
||||
Reference in new issue
Block a user