const ( RSAKeyType = "rsa" RSAKeyScheme = "rsassa-pss-sha256" RSAPrivateKeyPEM = "RSA PRIVATE KEY" )
const ( PublicKeyPEM = "PUBLIC KEY" PrivateKeyPEM = "PRIVATE KEY" )
const ECDSAKeyType = "ecdsa"
const ED25519KeyType = "ed25519"
var ( ErrNotPrivateKey = errors.New("loaded key is not a private key") ErrSignatureVerificationFailed = errors.New("failed to verify signature") ErrUnknownKeyType = errors.New("unknown key type") ErrInvalidThreshold = errors.New("threshold is either less than 1 or greater than number of provided public keys") ErrInvalidKey = errors.New("key object has no value") )
var ( // ErrNoPEMBlock gets triggered when there is no PEM block in the provided file ErrNoPEMBlock = errors.New("failed to decode the data as PEM block (are you sure this is a pem file?)") // ErrFailedPEMParsing gets returned when PKCS1, PKCS8 or PKIX key parsing fails ErrFailedPEMParsing = errors.New("failed parsing the PEM block: unsupported PEM type") )
var KeyIDHashAlgorithms = []string{"sha256", "sha512"}
ECDSASignerVerifier is a dsse.SignerVerifier compliant interface to sign and verify signatures using ECDSA keys.
type ECDSASignerVerifier struct {
// contains filtered or unexported fields
}
func NewECDSASignerVerifierFromSSLibKey(key *SSLibKey) (*ECDSASignerVerifier, error)
NewECDSASignerVerifierFromSSLibKey creates an ECDSASignerVerifier from an SSLibKey.
func (sv *ECDSASignerVerifier) KeyID() (string, error)
KeyID returns the identifier of the key used to create the ECDSASignerVerifier instance.
func (sv *ECDSASignerVerifier) Public() crypto.PublicKey
Public returns the public portion of the key used to create the ECDSASignerVerifier instance.
func (sv *ECDSASignerVerifier) Sign(ctx context.Context, data []byte) ([]byte, error)
Sign creates a signature for `data`.
func (sv *ECDSASignerVerifier) Verify(ctx context.Context, data []byte, sig []byte) error
Verify verifies the `sig` value passed in against `data`.
ED25519SignerVerifier is a dsse.SignerVerifier compliant interface to sign and verify signatures using ED25519 keys.
type ED25519SignerVerifier struct {
// contains filtered or unexported fields
}
func NewED25519SignerVerifierFromSSLibKey(key *SSLibKey) (*ED25519SignerVerifier, error)
NewED25519SignerVerifierFromSSLibKey creates an Ed25519SignerVerifier from an SSLibKey.
func (sv *ED25519SignerVerifier) KeyID() (string, error)
KeyID returns the identifier of the key used to create the ED25519SignerVerifier instance.
func (sv *ED25519SignerVerifier) Public() crypto.PublicKey
Public returns the public portion of the key used to create the ED25519SignerVerifier instance.
func (sv *ED25519SignerVerifier) Sign(ctx context.Context, data []byte) ([]byte, error)
Sign creates a signature for `data`.
func (sv *ED25519SignerVerifier) Verify(ctx context.Context, data []byte, sig []byte) error
Verify verifies the `sig` value passed in against `data`.
type KeyVal struct { Private string `json:"private,omitempty"` Public string `json:"public,omitempty"` Certificate string `json:"certificate,omitempty"` Identity string `json:"identity,omitempty"` Issuer string `json:"issuer,omitempty"` }
RSAPSSSignerVerifier is a dsse.SignerVerifier compliant interface to sign and verify signatures using RSA keys following the RSA-PSS scheme.
type RSAPSSSignerVerifier struct {
// contains filtered or unexported fields
}
func NewRSAPSSSignerVerifierFromSSLibKey(key *SSLibKey) (*RSAPSSSignerVerifier, error)
NewRSAPSSSignerVerifierFromSSLibKey creates an RSAPSSSignerVerifier from an SSLibKey.
func (sv *RSAPSSSignerVerifier) KeyID() (string, error)
KeyID returns the identifier of the key used to create the RSAPSSSignerVerifier instance.
func (sv *RSAPSSSignerVerifier) Public() crypto.PublicKey
Public returns the public portion of the key used to create the RSAPSSSignerVerifier instance.
func (sv *RSAPSSSignerVerifier) Sign(ctx context.Context, data []byte) ([]byte, error)
Sign creates a signature for `data`.
func (sv *RSAPSSSignerVerifier) Verify(ctx context.Context, data []byte, sig []byte) error
Verify verifies the `sig` value passed in against `data`.
type SSLibKey struct { KeyIDHashAlgorithms []string `json:"keyid_hash_algorithms"` KeyType string `json:"keytype"` KeyVal KeyVal `json:"keyval"` Scheme string `json:"scheme"` KeyID string `json:"keyid"` }
func LoadECDSAKeyFromFile(path string) (*SSLibKey, error)
LoadECDSAKeyFromFile returns an SSLibKey instance for an ECDSA key stored in a file in the custom securesystemslib format.
func LoadED25519KeyFromFile(path string) (*SSLibKey, error)
LoadED25519KeyFromFile returns an SSLibKey instance for an ED25519 key stored in a file in the custom securesystemslib format.
func LoadKeyFromSSLibBytes(contents []byte) (*SSLibKey, error)
LoadKeyFromSSLibBytes returns a pointer to a Key instance created from the contents of the bytes. The key contents are expected to be in the custom securesystemslib format.
func LoadRSAPSSKeyFromBytes(contents []byte) (*SSLibKey, error)
func LoadRSAPSSKeyFromFile(path string) (*SSLibKey, error)
LoadRSAPSSKeyFromFile returns an SSLibKey instance for an RSA key stored in a file.