Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { // Close Closes the connection. // Note if the io.ReadWriter returned by GetRW is not released // it's not possible to close the connection. Close() error // GetRW Returns io.ReadWriter object that can be used to communicate with the TPM // For example you can pass it to all tpm2 functions // Note if the io.ReadWriter must be released using the ReleaseRW method // before Close method is invoked. GetRW() (io.ReadWriter, error) // ReleaseRW Releases the io.ReadWriter received by the GetRW method ReleaseRW(writer io.ReadWriter) error }
Connection This interface represents an OPEN connection to the TPM module see NewTpmConnection for information how to obtain an instance.
Due to inconsistencies between how device files and unix sockets are handled by tpm2.OpenTPM and the tpm2 library as a whole we need to handle this our self.
For all cases to work as expected the unix socket connection must be kept open until we no longer need it. If we close the connection and reopen it we nee to do the whole initialization procedure again. In order to avoid that we keep the connection open until explicit close request. Also GetRW and ReleaseRW methods provide some rudimentary ownership management
func NewTpmConnection ¶
func NewTpmConnection(fileName string) (conn Connection, err error)
NewTpmConnection creates connection for a TPM device file name.
type Context ¶
type Context interface { crypto.Signer crypto.Decrypter // Close When you finish using this context, generally whenever you close the TLS connection // you need to close it and release the io.ReadWriter object it returns. Close() (io.ReadWriter, error) // TLSConfig returns an tls.Config object that can be used to establish TSL connection using // this TPM context. TLSConfig() *tls.Config }
Context represents TPM context.
func NewTPMContext ¶
func NewTPMContext(opts *ContextOpts, logger watermill.LoggerAdapter) (context Context, err error)
NewTPMContext creates a TPM context using the provided ContextOps.
type ContextOpts ¶
type ContextOpts struct { // TPMConnectionRW This MUST be initialized with an io.ReadWriter returned by Connection.GetRW TPMConnectionRW io.ReadWriter PrivateKeyFile string PublicKeyFile string StorageRootKeyHandle uint32 PublicCertFile string ExtTLSConfig *tls.Config }
ContextOpts defines TLS options.