@@ -61,13 +61,13 @@ converted to a python representation of the respective datatype (e.g. a
61
61
` TPMS_SIG_SCHEME_ECDSA ` object).
62
62
63
63
``` python
64
- from tpmstream.common.event import events_to_obj
64
+ from tpmstream.common.object import events_to_obj
65
65
from tpmstream.io.binary import Binary
66
- from tpmstream.spec.commands.commands import Command
66
+ from tpmstream.spec.commands import Command
67
67
from tpmstream.spec.structures.constants import TPM_SU
68
68
69
69
events = Binary.marshal(tpm_type = Command, buffer = b " \x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00 " )
70
- command = events_to_obj(Command, events)
70
+ command = events_to_obj(events)
71
71
72
72
print (command.parameters.startupType) # prints TPM_SU.CLEAR
73
73
```
@@ -76,11 +76,24 @@ Likewise, these python objects can be turned into a sequence of events, again.
76
76
77
77
78
78
``` python
79
- from tpmstream.common.event import obj_to_events
80
-
81
- # ...
82
-
83
- events = obj_to_events(command)
79
+ from tpmstream.common.object import obj_to_events
80
+ from tpmstream.io.binary import Binary
81
+ from tpmstream.spec.commands import Command
82
+ from tpmstream.spec.commands.commands_handles import TPMS_COMMAND_HANDLES_STARTUP
83
+ from tpmstream.spec.commands.commands_params import TPMS_COMMAND_PARAMS_STARTUP
84
+ from tpmstream.spec.structures.base_types import UINT32
85
+ from tpmstream.spec.structures.constants import TPM_CC , TPM_ST , TPM_SU
86
+ from tpmstream.spec.structures.interface_types import TPMI_ST_COMMAND_TAG
87
+
88
+ startup_command = Command(
89
+ tag = TPMI_ST_COMMAND_TAG(TPM_ST .NO_SESSIONS ),
90
+ commandSize = UINT32(12 ),
91
+ commandCode = TPM_CC .Startup,
92
+ handles = TPMS_COMMAND_HANDLES_STARTUP(),
93
+ parameters = TPMS_COMMAND_PARAMS_STARTUP(startupType = TPM_SU .CLEAR ),
94
+ )
95
+
96
+ events = obj_to_events(startup_command)
84
97
85
98
# Note that `events` is a generator. You can obtain a list by via `list(events)`
86
99
```
@@ -93,7 +106,7 @@ format (binary, pretty print, ...).
93
106
``` python
94
107
from tpmstream.io.binary import Binary
95
108
from tpmstream.io.pretty import Pretty
96
- from tpmstream.spec.commands.commands import Command
109
+ from tpmstream.spec.commands import Command
97
110
98
111
events = Binary.marshal(tpm_type = Command, buffer = b " \x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00 " )
99
112
pretty = Pretty.unmarshal(events = events)
0 commit comments