File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ package simplesequoia
2+
3+ import (
4+ "errors"
5+ "strings"
6+ )
7+
8+ type Option func (* simpleSequoiaSigner ) error
9+
10+ // WithSequoiaHome returns an Option for NewSigner, specifying a Sequoia home directory to use.
11+ func WithSequoiaHome (sequoiaHome string ) Option {
12+ return func (s * simpleSequoiaSigner ) error {
13+ s .sequoiaHome = sequoiaHome
14+ return nil
15+ }
16+ }
17+
18+ // WithKeyFingerprint returns an Option for NewSigner, specifying a key to sign with, using the provided Sequoia-PGP key fingerprint.
19+ func WithKeyFingerprint (keyFingerprint string ) Option {
20+ return func (s * simpleSequoiaSigner ) error {
21+ s .keyFingerprint = keyFingerprint
22+ return nil
23+ }
24+ }
25+
26+ // WithPassphrase returns an Option for NewSigner, specifying a passphrase for the private key.
27+ func WithPassphrase (passphrase string ) Option {
28+ return func (s * simpleSequoiaSigner ) error {
29+ // The gpgme implementation can’t use passphrase with \n; reject it here for consistent behavior.
30+ // FIXME: We don’t need it in this API at all, but the "\n" check exists in the current call stack. That should go away.
31+ if strings .Contains (passphrase , "\n " ) {
32+ return errors .New ("invalid passphrase: must not contain a line break" )
33+ }
34+ s .passphrase = passphrase
35+ return nil
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ package simplesequoia
2+
3+ import (
4+ "errors"
5+
6+ "github.com/containers/image/v5/signature/signer"
7+ )
8+
9+ // simpleSequoiaSigner is a signer.SignerImplementation implementation for simple signing signatures using Sequoia.
10+ type simpleSequoiaSigner struct {
11+ // This is not really used, we just keep the struct fields so that the With… Option functions can be compiled.
12+
13+ sequoiaHome string // "" if using the system's default
14+ keyFingerprint string
15+ passphrase string // "" if not provided.
16+ }
17+
18+ // NewSigner returns a signature.Signer which creates "simple signing" signatures using the user's default
19+ // Sequoia PGP configuration.
20+ //
21+ // The set of options must identify a key to sign with, probably using a WithKeyFingerprint.
22+ //
23+ // The caller must call Close() on the returned Signer.
24+ func NewSigner (opts ... Option ) (* signer.Signer , error ) {
25+ return nil , errors .New ("Sequoia-PGP support is not enabled in this build" )
26+ }
You can’t perform that action at this time.
0 commit comments