Debian Codegraph @

signature/simplesequoia/mechanism.go

raw
1 //go:build containers_image_sequoia
2
3 package simplesequoia
4
5 // This implements a signature.signingMechanismWithPassphrase that only supports signing.
6 //
7 // FIXME: Consider restructuring the simple signing signature creation code path
8 // not to require this indirection and all those unimplemented methods.
9
10 import (
11 "go.podman.io/image/v5/signature/internal/sequoia"
12 )
13
14 // A GPG/OpenPGP signing mechanism, implemented using Sequoia.
15 type sequoiaSigningOnlyMechanism struct {
16 inner *sequoia.SigningMechanism
17 }
18
19 func (m *sequoiaSigningOnlyMechanism) Close() error {
20 panic("Should never be called")
21 }
22
23 // SupportsSigning returns nil if the mechanism supports signing, or a SigningNotSupportedError.
24 func (m *sequoiaSigningOnlyMechanism) SupportsSigning() error {
25 panic("Should never be called")
26 }
27
28 // Sign creates a (non-detached) signature of input using keyIdentity and passphrase.
29 // Fails with a SigningNotSupportedError if the mechanism does not support signing.
30 func (m *sequoiaSigningOnlyMechanism) SignWithPassphrase(input []byte, keyIdentity string, passphrase string) ([]byte, error) {
31 return m.inner.SignWithPassphrase(input, keyIdentity, passphrase)
32 }
33
34 // Sign creates a (non-detached) signature of input using keyIdentity.
35 // Fails with a SigningNotSupportedError if the mechanism does not support signing.
36 func (m *sequoiaSigningOnlyMechanism) Sign(input []byte, keyIdentity string) ([]byte, error) {
37 panic("Should never be called")
38 }
39
40 // Verify parses unverifiedSignature and returns the content and the signer's identity
41 func (m *sequoiaSigningOnlyMechanism) Verify(unverifiedSignature []byte) (contents []byte, keyIdentity string, err error) {
42 panic("Should never be called")
43 }
44
45 // UntrustedSignatureContents returns UNTRUSTED contents of the signature WITHOUT ANY VERIFICATION,
46 // along with a short identifier of the key used for signing.
47 // WARNING: The short key identifier (which corresponds to "Key ID" for OpenPGP keys)
48 // is NOT the same as a "key identity" used in other calls to this interface, and
49 // the values may have no recognizable relationship if the public key is not available.
50 func (m *sequoiaSigningOnlyMechanism) UntrustedSignatureContents(untrustedSignature []byte) (untrustedContents []byte, shortKeyIdentifier string, err error) {
51 panic("Should never be called")
52 }