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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
package storage
// FeedthroughStore is a TPMStore that feeds through storage operations
// to the underlying TPMStore. If no backing TPMStore is set, but the
// operation requires one, [ErrNoStorageConfigured] will be returned.
type FeedthroughStore struct {
store TPMStore
}
func NewFeedthroughStore(store TPMStore) *FeedthroughStore {
return &FeedthroughStore{
store: store,
}
}
func (f *FeedthroughStore) ListKeys() ([]*Key, error) {
if f.store == nil {
return nil, ErrNoStorageConfigured
}
return f.store.ListKeys()
}
func (f *FeedthroughStore) ListKeyNames() []string {
if f.store == nil {
return nil
}
return f.store.ListKeyNames()
}
func (f *FeedthroughStore) GetKey(name string) (*Key, error) {
if f.store == nil {
return nil, ErrNoStorageConfigured
}
return f.store.GetKey(name)
}
func (f *FeedthroughStore) AddKey(key *Key) error {
if f.store == nil {
return ErrNoStorageConfigured
}
return f.store.AddKey(key)
}
func (f *FeedthroughStore) UpdateKey(key *Key) error {
if f.store == nil {
return ErrNoStorageConfigured
}
return f.store.UpdateKey(key)
}
func (f *FeedthroughStore) DeleteKey(name string) error {
if f.store == nil {
return ErrNoStorageConfigured
}
return f.store.DeleteKey(name)
}
func (f *FeedthroughStore) ListAKs() ([]*AK, error) {
if f.store == nil {
return nil, ErrNoStorageConfigured
}
return f.store.ListAKs()
}
func (f *FeedthroughStore) ListAKNames() []string {
if f.store == nil {
return nil
}
return f.store.ListAKNames()
}
func (f *FeedthroughStore) GetAK(name string) (*AK, error) {
if f.store == nil {
return nil, ErrNoStorageConfigured
}
return f.store.GetAK(name)
}
func (f *FeedthroughStore) AddAK(ak *AK) error {
if f.store == nil {
return ErrNoStorageConfigured
}
return f.store.AddAK(ak)
}
func (f *FeedthroughStore) UpdateAK(ak *AK) error {
if f.store == nil {
return ErrNoStorageConfigured
}
return f.store.UpdateAK(ak)
}
func (f *FeedthroughStore) DeleteAK(name string) error {
if f.store == nil {
return ErrNoStorageConfigured
}
return f.store.DeleteAK(name)
}
func (f *FeedthroughStore) Persist() error {
if f.store == nil {
return nil
}
return f.store.Persist()
}
func (f *FeedthroughStore) Load() error {
if f.store == nil {
return nil
}
return f.store.Load()
}
var _ TPMStore = (*FeedthroughStore)(nil)
|