mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-12-15 16:09:39 -05:00
Move attestation, atls and oid packages to internal directory
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
b461c40c3a
commit
3467df6b69
70 changed files with 183 additions and 103 deletions
43
internal/attestation/simulator/simulator.go
Normal file
43
internal/attestation/simulator/simulator.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//go:build !disable_tpm_simulator
|
||||
// +build !disable_tpm_simulator
|
||||
|
||||
package simulator
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/google/go-tpm-tools/simulator"
|
||||
)
|
||||
|
||||
// OpenSimulatedTPM returns a simulated TPM device.
|
||||
func OpenSimulatedTPM() (io.ReadWriteCloser, error) {
|
||||
return simulator.Get()
|
||||
}
|
||||
|
||||
// NewSimulatedTPMOpenFunc returns a TPMOpenFunc that opens a simulated TPM.
|
||||
func NewSimulatedTPMOpenFunc() (func() (io.ReadWriteCloser, error), io.Closer) {
|
||||
tpm, err := OpenSimulatedTPM()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return func() (io.ReadWriteCloser, error) {
|
||||
return &simulatedTPM{tpm}, nil
|
||||
}, tpm
|
||||
}
|
||||
|
||||
type simulatedTPM struct {
|
||||
openSimulatedTPM io.ReadWriteCloser
|
||||
}
|
||||
|
||||
func (t *simulatedTPM) Read(p []byte) (int, error) {
|
||||
return t.openSimulatedTPM.Read(p)
|
||||
}
|
||||
|
||||
func (t *simulatedTPM) Write(p []byte) (int, error) {
|
||||
return t.openSimulatedTPM.Write(p)
|
||||
}
|
||||
|
||||
func (t *simulatedTPM) Close() error {
|
||||
// never close the underlying simulated TPM to allow calling the TPMOpenFunc again
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue