forked from notaryproject/notary
-
Notifications
You must be signed in to change notification settings - Fork 2
/
keys_pkcs11.go
38 lines (33 loc) · 993 Bytes
/
keys_pkcs11.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
// +build pkcs11
package main
import (
"github.com/theupdateframework/notary"
store "github.com/theupdateframework/notary/storage"
"github.com/theupdateframework/notary/trustmanager"
"github.com/theupdateframework/notary/trustmanager/yubikey"
)
func getYubiStore(fileKeyStore trustmanager.KeyStore, ret notary.PassRetriever) (*yubikey.YubiStore, error) {
return yubikey.NewYubiStore(fileKeyStore, ret)
}
func getImporters(baseDir string, ret notary.PassRetriever) ([]trustmanager.Importer, error) {
var importers []trustmanager.Importer
if yubikey.IsAccessible() {
yubiStore, err := getYubiStore(nil, ret)
if err == nil {
importers = append(
importers,
yubikey.NewImporter(yubiStore, ret),
)
}
}
fileStore, err := store.NewPrivateKeyFileStorage(baseDir, notary.KeyExtension)
if err == nil {
importers = append(
importers,
fileStore,
)
} else if len(importers) == 0 {
return nil, err // couldn't initialize any stores
}
return importers, nil
}