/
keys.go
47 lines (38 loc) · 1.58 KB
/
keys.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Package keys provides interfaces and handlers for managing public/private key pairs that
are used for sealing and unsealing secure envelopes. This package is not intended for
use with symmetric keys that are used to encrypt payloads.
*/
package keys
import api "github.com/trisacrypto/trisa/pkg/trisa/api/v1beta1"
// Key provides a generic interface to either a private key pair or to a public key that
// has been shared in a TRISA key-exchange. The primary use of this top level interface
// is serializing and deserializing keys with the marshaler interface and creating a
// unified mechanism to manage keys on disk.
type Key interface {
PublicKey
PrivateKey
KeyMarshaler
// Indicates if the Key contains a private key. If this method returns false, then
// the UnsealingKey() method should always return an error.
IsPrivate() bool
}
type PublicKey interface {
KeyIdentifier
// Return the key object that can be used to seal an envelope, typically an *rsa.PublicKey
SealingKey() (interface{}, error)
// Return the protocol buffer exchange key object to send to the counterparty
Proto() (*api.SigningKey, error)
}
type PrivateKey interface {
// Return the key object that can be used to unseal an envelope, typically an *rsa.PrivateKey
UnsealingKey() (interface{}, error)
}
type KeyIdentifier interface {
PublicKeyAlgorithm() string // The sealing public key algorithm to identify the key type
PublicKeySignature() (string, error) // An identifier of the public key for key management
}
type KeyMarshaler interface {
Marshal() ([]byte, error)
Unmarshal(data []byte) error
}