| 131 | } |
| 132 | |
| 133 | func (s *Provider) storeSTEK(dstek distributedSTEK) error { |
| 134 | var buf bytes.Buffer |
| 135 | err := gob.NewEncoder(&buf).Encode(dstek) |
| 136 | if err != nil { |
| 137 | return fmt.Errorf("encoding STEK gob: %v", err) |
| 138 | } |
| 139 | err = s.storage.Store(s.ctx, stekFileName, buf.Bytes()) |
| 140 | if err != nil { |
| 141 | return fmt.Errorf("storing STEK gob: %v", err) |
| 142 | } |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | // getSTEK locks and loads the current STEK from storage. If none |
| 147 | // currently exists, a new STEK is created and persisted. If the |