forked from tpm2-software/tpm2-tss
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implmenet a TCTI module that will allow folks to write TCTIs in Python3. This will allow for more crazy and complex TCTI scenarios without having to re-write everyones stacks to use tpm2-pytss. TODO: 1. Check error paths 2. Add a test 3. doc cleanups and add examples Example Commandline: ```bash PYTHONPATH=$HOME tpm2_getcap --verbose --tcti=$(realpath ./src/tss2-tcti/.libs/libtss2-tcti-py.so.0.0.0):pytcti:$TPM2TOOLS_TCTI properties-fixed ``` Example TCTI: For the ultimate in mind-bending: C -> Python -> C and back for efficiency :-p. ```python3 from tpm2_pytss import TCTILdr class MyPyTCTI(object): def __init__(self, args: str): c = args.split(":", maxsplit=1) print(f"PYTHON: Initializing TCTI Ldr with mod: {c[0]} args: {c[1]}") self._tcti = TCTILdr(c[0], c[1]) @Property def magic(self): # Optional Method print("PYHTON magic") return 42 def receive(self, timeout: int) -> bytes: print("PYTHON receive") return self._tcti.receive(timeout=timeout) def transmit(self, data:bytes): print("PYTHON transmit") self._tcti.transmit(data) def tcti_init(args: str) -> MyPyTCTI: print(f"PYTHON tcti_init called with: {args}") return MyPyTCTI(args) ``` Signed-off-by: Bill Roberts <[email protected]>
- Loading branch information
1 parent
a7da221
commit db8b52e
Showing
12 changed files
with
652 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* SPDX-License-Identifier: BSD-2-Clause */ | ||
#ifndef TSS2_TCTI_CMD_H | ||
#define TSS2_TCTI_CMD_H | ||
|
||
#include "tss2_tcti.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
TSS2_RC Tss2_Tcti_Cmd_Init ( | ||
TSS2_TCTI_CONTEXT *tctiContext, | ||
size_t *size, | ||
const char *conf); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* TSS2_TCTI_CMD_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LIBRARY tss2-tcti-py | ||
EXPORTS | ||
Tss2_Tcti_Info | ||
Tss2_Tcti_Py_Init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
global: | ||
Tss2_Tcti_Info; | ||
Tss2_Tcti_Py_Init; | ||
local: | ||
*; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LIBRARY tss2-tcti-py | ||
EXPORTS | ||
Tss2_Tcti_Info | ||
Tss2_Tcti_Py_Init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
global: | ||
Tss2_Tcti_Info; | ||
Tss2_Tcti_Py_Init; | ||
local: | ||
*; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prefix=@prefix@ | ||
exec_prefix=@exec_prefix@ | ||
libdir=@libdir@ | ||
includedir=@includedir@ | ||
|
||
Name: tss2-tcti-py | ||
Description: TCTI library for implementing TCTIs in Python3. | ||
URL: https://github.com/tpm2-software/tpm2-tss | ||
Version: @VERSION@ | ||
Cflags: -I${includedir} -I${includedir}/tss2 | ||
Libs: -ltss2-py -L${libdir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.\" Process this file with | ||
.\" groff -man -Tascii foo.1 | ||
.\" | ||
.TH TCTI-PY 7 "JANUARY 2023" "TPM2 Software Stack" | ||
.SH NAME | ||
tcti-py \- Launch Python3 TPM2 TCTIs | ||
.SH SYNOPSIS | ||
Write a TCTI in Python3. | ||
.SH DESCRIPTION | ||
tcti-py is a library that allows creating TCTIs in Python3 by implementing a | ||
an PyTCTI interface in Python. | ||
It is related to the TPM Command Transmission Interface Specification\*(rq specification. |
Oops, something went wrong.