Add backends and simulated TPM device

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
This commit is contained in:
Ettore Di Giacinto
2022-02-16 12:52:30 +01:00
parent c2203f40dd
commit 1ab3e10e4d
11 changed files with 269 additions and 16 deletions

40
config.go Normal file
View File

@@ -0,0 +1,40 @@
package tpm
import "github.com/google/go-attestation/attest"
type Config struct {
emulated bool
commandChannel attest.CommandChannelTPM20
seed int64
}
type Option func(c *Config) error
var Emulated Option = func(c *Config) error {
c.emulated = true
return nil
}
func WithSeed(s int64) Option {
return func(c *Config) error {
c.seed = s
return nil
}
}
func WithCommandChannel(cc attest.CommandChannelTPM20) Option {
return func(c *Config) error {
c.commandChannel = cc
return nil
}
}
func (c *Config) Apply(opts ...Option) error {
for _, o := range opts {
if err := o(c); err != nil {
return err
}
}
return nil
}