-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeystore.go
41 lines (37 loc) · 1.36 KB
/
keystore.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
package keystores
import (
"context"
"crypto"
"errors"
)
var (
ErrNotImplemented = errors.New("not implemented yet")
ErrAlgorithmNotSupportedByKeyStore = errors.New("algorithm not supported by key store")
ErrOperationNotSupportedByKeyStore = errors.New("operation not supported by key store")
)
type KeyStore interface {
// Unique identifier within the provider. The returned Id must be URL safe.
Id() string
Name() string
Open() error
Close() error
IsOpen() bool
Reload() error
SupportedPrivateKeyAlgorithms() []KeyAlgorithm
KeyPairById(id KeyPairId) KeyPair
KeyPairs(reload bool) (map[KeyPairId]KeyPair, error)
CreateKeyPair(opts GenKeyPairOpts) (kp KeyPair, err error)
ImportKeyPair(privKey crypto.PrivateKey, opts GenKeyPairOpts) (kp KeyPair, err error)
}
type AsyncKeyStore interface {
Id(ctx context.Context) <-chan string
Name(ctx context.Context) <-chan string
Open(ctx context.Context) <-chan error
Close(ctx context.Context) <-chan error
IsOpen(ctx context.Context) <-chan bool
Reload(ctx context.Context) <-chan error
SupportedPrivateKeyAlgorithms(ctx context.Context) <-chan KeyAlgorithm
KeyPairs(ctx context.Context) (<-chan AsyncKeyPair, <-chan error)
CreateKeyPair(ctx context.Context, opts GenKeyPairOpts) (<-chan AsyncKeyPair, <-chan error)
ImportKeyPair(ctx context.Context, der []byte) (<-chan AsyncKeyPair, <-chan error)
}