mirror of
https://github.com/kairos-io/tpm-helpers.git
synced 2025-09-15 06:10:24 +00:00
Add backends and simulated TPM device
Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
This commit is contained in:
40
config.go
Normal file
40
config.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user