File: tpmstore.go

package info (click to toggle)
golang-github-smallstep-crypto 0.57.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 3,284 kB
  • sloc: sh: 53; makefile: 36
file content (38 lines) | stat: -rw-r--r-- 897 bytes parent folder | download | duplicates (3)
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
package storage

import "context"

type contextKey struct{}

// NewContext adds TPMStore `t` to the context.
func NewContext(ctx context.Context, t TPMStore) context.Context {
	return context.WithValue(ctx, contextKey{}, t)
}

// FromContext retrieves a TPMStore from the context.
//
// It panics when there's no TPMStore present.
func FromContext(ctx context.Context) TPMStore {
	return ctx.Value(contextKey{}).(TPMStore)
}

// TPMStore is the interface that TPM storage implementations
// need to implement.
type TPMStore interface {
	ListKeys() ([]*Key, error)
	ListKeyNames() []string
	GetKey(name string) (*Key, error)
	AddKey(key *Key) error
	UpdateKey(key *Key) error
	DeleteKey(name string) error

	ListAKs() ([]*AK, error)
	ListAKNames() []string
	GetAK(name string) (*AK, error)
	AddAK(ak *AK) error
	UpdateAK(ak *AK) error
	DeleteAK(name string) error

	Persist() error
	Load() error
}