trust: the signing half of publisher signatures
Moved from yet's internal/trust without changing behavior or file formats: KeyPair, GenerateKey, SaveKeyPair, LoadPrivateKey, ParsePrivateKey, LoadPublicKey, MarshalPublicKey, SignEd25519, VerifyEd25519, ExportPEM, ImportPEM, and the package signature as SignDigest. New: Sign and VerifyMessage, a detached minisign signature over any bytes and its check (returns the trusted comment; another key with a colliding ID fails), and KeyFromRef, a key pair from a core/secretref reference with error messages that never carry the secret. A golden vector (testdata/sign-vector.*) pins the output, and VerifySignature is tested against what SignDigest makes. For yabar's evidence signing (ADR-0037 there, owner decision Q-5 option A); yet keeps registry signing and its auto-sign key store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9395fadbf7
commit
e1495430c5
10 files changed
+586
-7
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package trust
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yetano.dev/yetano/core/secretref"
|
||||
)
|
||||
|
||||
// KeyFromRef loads a signing key pair from a secret reference
|
||||
// (secret://, env:, file:, base64: -- core/secretref), for example
|
||||
// "secret://yabar/evidence/minisign" in yaseva. The value is a minisign
|
||||
// private key file's contents. passwordRef ("" for none) is the
|
||||
// reference of the password of an encrypted key. Error messages never
|
||||
// contain the secret.
|
||||
func KeyFromRef(ctx context.Context, r *secretref.Resolver, keyRef, passwordRef string) (KeyPair, error) {
|
||||
data, err := r.Resolve(ctx, keyRef)
|
||||
if err != nil {
|
||||
return KeyPair{}, fmt.Errorf("signing key %s: %s", keyRef, r.Redact(err.Error()))
|
||||
}
|
||||
var password string
|
||||
if passwordRef != "" {
|
||||
if password, err = r.ResolveString(ctx, passwordRef); err != nil {
|
||||
return KeyPair{}, fmt.Errorf("signing key password %s: %s", passwordRef, r.Redact(err.Error()))
|
||||
}
|
||||
}
|
||||
kp, err := ParsePrivateKey(data, password)
|
||||
if err != nil {
|
||||
return KeyPair{}, fmt.Errorf("signing key %s: %s", keyRef, r.Redact(err.Error()))
|
||||
}
|
||||
return kp, nil
|
||||
}
|
||||
Reference in new issue
Block a user