Initial commit: docker-compose-updater
Build and Push / build (push) Failing after 13m20s

Go 项目,包含:
- 服务端 updater:两阶段协议,ECDSA 签名验证,AES-GCM 加密
- 发送端 dcu-send:Gitea Action CLI
- internal/auth:加解密/签名/会话管理
- internal/docker:Docker CLI 容器查找/拉取/重建
- action/:Gitea Action 定义
- deploy/Dockerfile:多阶段构建
- .gitea/workflows/build.yaml:CI/CD
This commit is contained in:
ilovintit
2026-06-08 15:16:46 +08:00
commit cea9b941cf
21 changed files with 1874 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package auth
import (
"crypto/ecdsa"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"fmt"
)
// Sign ECDSA P-256 签名,返回 DER 编码的 Base64 签名。
func Sign(key *ecdsa.PrivateKey, data []byte) (string, error) {
hash := sha256.Sum256(data)
sig, err := ecdsa.SignASN1(rand.Reader, key, hash[:])
if err != nil {
return "", fmt.Errorf("ecdsa sign: %w", err)
}
return base64.StdEncoding.EncodeToString(sig), nil
}
// Verify 验证 ECDSA P-256 签名。
// sigBase64 是 DER 编码的 Base64 签名。
func Verify(key *ecdsa.PublicKey, data []byte, sigBase64 string) bool {
sig, err := base64.StdEncoding.DecodeString(sigBase64)
if err != nil {
return false
}
hash := sha256.Sum256(data)
return ecdsa.VerifyASN1(key, hash[:], sig)
}