-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
67 lines (55 loc) · 1.2 KB
/
config.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package keyfile
import (
"encoding/asn1"
"github.com/google/go-tpm/tpm2"
)
type TPMKeyOption func(key *TPMKey)
func WithKeytype(keytype asn1.ObjectIdentifier) TPMKeyOption {
return func(key *TPMKey) {
key.Keytype = keytype
}
}
func WithPolicy(policy []*TPMPolicy) TPMKeyOption {
return func(key *TPMKey) {
key.Policy = policy
}
}
func WithSecret(secret tpm2.TPM2BEncryptedSecret) TPMKeyOption {
return func(key *TPMKey) {
key.Secret = secret
}
}
func WithUserAuth(userauth []byte) TPMKeyOption {
return func(key *TPMKey) {
key.EmptyAuth = true
if len(userauth) != 0 {
key.userAuth = userauth
key.EmptyAuth = false
}
}
}
func WithDescription(desc string) TPMKeyOption {
return func(key *TPMKey) {
key.Description = desc
}
}
func WithParent(parent tpm2.TPMHandle) TPMKeyOption {
return func(key *TPMKey) {
key.Parent = parent
}
}
func WithAuthPolicy(authpolicy []*TPMAuthPolicy) TPMKeyOption {
return func(key *TPMKey) {
key.AuthPolicy = authpolicy
}
}
func WithPubkey(pubkey tpm2.TPM2BPublic) TPMKeyOption {
return func(key *TPMKey) {
key.Pubkey = pubkey
}
}
func WithPrivkey(privkey tpm2.TPM2BPrivate) TPMKeyOption {
return func(key *TPMKey) {
key.Privkey = privkey
}
}