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
|
//go:build tpmsimulator
package tss2
import (
"crypto/rand"
"encoding/hex"
"io"
"testing"
"github.com/stretchr/testify/require"
"go.step.sm/crypto/tpm/simulator"
)
var seed string
func init() {
b := make([]byte, 8)
if _, err := io.ReadFull(rand.Reader, b); err != nil {
panic(err)
}
seed = hex.EncodeToString(b)
}
func openTPM(t *testing.T) io.ReadWriteCloser {
t.Helper()
sim, err := simulator.New(simulator.WithSeed(seed))
require.NoError(t, err)
require.NoError(t, sim.Open())
return sim
}
|