forked from notaryproject/notary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signer.go
47 lines (37 loc) · 1.33 KB
/
signer.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 signer
import (
"crypto/tls"
pb "github.com/docker/notary/proto"
"github.com/docker/notary/trustmanager"
"github.com/docker/notary/tuf/data"
"github.com/docker/notary/tuf/signed"
)
// SigningService is the interface to implement a key management and signing service
type SigningService interface {
KeyManager
// Signer returns a Signer for a given keyID
Signer(keyID *pb.KeyID) (Signer, error)
}
// CryptoServiceIndex represents a mapping between a service algorithm string
// and a CryptoService
type CryptoServiceIndex map[string]signed.CryptoService
// KeyManager is the interface to implement key management (possibly a key database)
type KeyManager interface {
// CreateKey creates a new key and returns it's Information
CreateKey() (*pb.PublicKey, error)
// DeleteKey removes a key
DeleteKey(keyID *pb.KeyID) (*pb.Void, error)
// KeyInfo returns the public key of a particular key
KeyInfo(keyID *pb.KeyID) (*pb.PublicKey, error)
}
// Signer is the interface that allows the signing service to return signatures
type Signer interface {
Sign(request *pb.SignatureRequest) (*pb.Signature, error)
}
// Config tells how to configure a notary-signer
type Config struct {
GRPCAddr string
TLSConfig *tls.Config
CryptoServices CryptoServiceIndex
PendingKeyFunc func(trustmanager.KeyInfo) (data.PublicKey, error)
}