1tpm2_nvwrite(1)             General Commands Manual            tpm2_nvwrite(1)
2
3
4

NAME

6       tpm2_nvwrite(1) - Write data to a Non-Volatile (NV) index.
7

SYNOPSIS

9       tpm2_nvwrite [OPTIONS] [ARGUMENT]
10

DESCRIPTION

12       tpm2_nvwrite(1)  - Write data specified via FILE to a Non-Volatile (NV)
13       index.  If FILE is not specified, it defaults to stdin.  The index  can
14       be  specified  as  raw handle or an offset value to the nv handle range
15       "TPM2_HR_NV_INDEX".
16

OPTIONS

18       · -i, --input=FILE:
19
20         Specifies the input file with data to write to NV.
21
22       · -C, --hierarchy=OBJECT:
23         Specifies the hierarchy used to authorize.  Supported options are:
24
25         · o for TPM_RH_OWNER
26
27         · p for TPM_RH_PLATFORM
28
29         · <num> where a hierarchy handle or nv-index may be used.
30
31         When -C isn't explicitly passed the index handle will be used to  au‐
32         thorize  against  the  index.  The index auth value is set via the -p
33         option to tpm2_nvdefine(1).
34
35       · -P, --auth=AUTH:
36
37         Specifies the authorization value for the hierarchy.
38
39       · --offset=NATURAL_NUMBER:
40
41         The offset within the NV index to start writing at.
42
43       · --cphash=FILE
44
45         File path to record the hash of the command parameters.  This is com‐
46         monly termed as cpHash.  NOTE: When this option is selected, The tool
47         will not actually execute the command, it simply returns a cpHash.
48
49   References

Context Object Format

51       The type of a context object, whether it is a handle or file  name,  is
52       determined according to the following logic in-order:
53
54       · If the argument is a file path, then the file is loaded as a restored
55         TPM transient object.
56
57       · If the argument is a prefix match on one of:
58
59         · owner: the owner hierarchy
60
61         · platform: the platform hierarchy
62
63         · endorsement: the endorsement hierarchy
64
65         · lockout: the lockout control persistent object
66
67       · If the argument argument can be loaded as a number it will  be  treat
68         as a handle, e.g.  0x81010013 and used directly.OBJECT.
69

Authorization Formatting

71       Authorization  for  use  of an object in TPM2.0 can come in 3 different
72       forms: 1.  Password 2.  HMAC 3.  Sessions
73
74       NOTE: "Authorizations default to the EMPTY  PASSWORD  when  not  speci‐
75       fied".
76
77   Passwords
78       Passwords  are  interpreted  in  the following forms below using prefix
79       identifiers.
80
81       Note: By default passwords are assumed to be in the  string  form  when
82       they do not have a prefix.
83
84   String
85       A  string  password,  specified  by  prefix "str:" or it's absence (raw
86       string without prefix) is not interpreted, and is directly used for au‐
87       thorization.
88
89   Examples
90              foobar
91              str:foobar
92
93   Hex-string
94       A  hex-string  password, specified by prefix "hex:" is converted from a
95       hexidecimal form into a byte array form, thus allowing  passwords  with
96       non-printable and/or terminal un-friendly characters.
97
98   Example
99              hex:0x1122334455667788
100
101   File
102       A  file  based password, specified be prefix "file:" should be the path
103       of a file containing the password to be read by the tool or  a  "-"  to
104       use  stdin.   Storing  passwords in files prevents information leakage,
105       passwords passed as options can be read from the process list or common
106       shell history features.
107
108   Examples
109              # to use stdin and be prompted
110              file:-
111
112              # to use a file from a path
113              file:path/to/password/file
114
115              # to echo a password via stdin:
116              echo foobar | tpm2_tool -p file:-
117
118              # to use a bash here-string via stdin:
119
120              tpm2_tool -p file:- <<< foobar
121
122   Sessions
123       When  using  a policy session to authorize the use of an object, prefix
124       the option argument with the session keyword.  Then indicate a path  to
125       a session file that was created with tpm2_startauthsession(1).  Option‐
126       ally, if the session requires an auth value to be sent with the session
127       handle  (eg policy password), then append a + and a string as described
128       in the Passwords section.
129
130   Examples
131       To use a session context file called session.ctx.
132
133              session:session.ctx
134
135       To use a session context file called session.ctx AND send the authvalue
136       mypassword.
137
138              session:session.ctx+mypassword
139
140       To use a session context file called session.ctx AND send the HEX auth‐
141       value 0x11223344.
142
143              session:session.ctx+hex:11223344
144
145   PCR Authorizations
146       You can satisfy a PCR policy using the "pcr:" prefix and the PCR  mini‐
147       language.       The     PCR     minilanguage     is     as     follows:
148       <pcr-spec>=<raw-pcr-file>
149
150       The PCR spec is documented in in the section "PCR bank specifiers".
151
152       The raw-pcr-file is an optional the output of the raw PCR  contents  as
153       returned by tpm2_pcrread(1).
154
155       PCR bank specifiers (common/pcr.md)
156
157   Examples
158       To satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3 use a specifi‐
159       er of:
160
161              pcr:sha256:0,1,2,3
162
163       specifying AUTH.
164

COMMON OPTIONS

166       This collection of options are common to many programs and provide  in‐
167       formation that many users may expect.
168
169       · -h,  --help=[man|no-man]:  Display the tools manpage.  By default, it
170         attempts to invoke the manpager for the  tool,  however,  on  failure
171         will  output  a short tool summary.  This is the same behavior if the
172         "man" option argument is specified, however if explicit "man" is  re‐
173         quested,  the  tool  will  provide errors from man on stderr.  If the
174         "no-man" option if specified, or the manpager fails,  the  short  op‐
175         tions will be output to stdout.
176
177         To  successfully use the manpages feature requires the manpages to be
178         installed or on MANPATH, See man(1) for more details.
179
180       · -v, --version: Display version information for this  tool,  supported
181         tctis and exit.
182
183       · -V,  --verbose:  Increase the information that the tool prints to the
184         console during its execution.  When using this option  the  file  and
185         line number are printed.
186
187       · -Q, --quiet: Silence normal tool output to stdout.
188
189       · -Z, --enable-errata: Enable the application of errata fixups.  Useful
190         if an errata fixup needs to be applied to commands sent to  the  TPM.
191         Defining  the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.  in‐
192         formation many users may expect.
193

TCTI Configuration

195       The TCTI or "Transmission Interface"  is  the  communication  mechanism
196       with  the TPM.  TCTIs can be changed for communication with TPMs across
197       different mediums.
198
199       To control the TCTI, the tools respect:
200
201       1. The command line option -T or --tcti
202
203       2. The environment variable: TPM2TOOLS_TCTI.
204
205       Note: The command line option always overrides  the  environment  vari‐
206       able.
207
208       The current known TCTIs are:
209
210       · tabrmd      -     The     resource     manager,     called     tabrmd
211         (https://github.com/tpm2-software/tpm2-abrmd).  Note that tabrmd  and
212         abrmd as a tcti name are synonymous.
213
214       · mssim  - Typically used for communicating to the TPM software simula‐
215         tor.
216
217       · device - Used when talking directly to a TPM device file.
218
219       · none - Do not initalize a connection with the TPM.  Some tools  allow
220         for off-tpm options and thus support not using a TCTI.  Tools that do
221         not support it will error when attempted to be used  without  a  TCTI
222         connection.   Does  not  support ANY options and MUST BE presented as
223         the exact text of "none".
224
225       The arguments to either the command  line  option  or  the  environment
226       variable are in the form:
227
228       <tcti-name>:<tcti-option-config>
229
230       Specifying  an  empty  string  for  either the <tcti-name> or <tcti-op‐
231       tion-config> results in the default being used for that portion respec‐
232       tively.
233
234   TCTI Defaults
235       When  a  TCTI  is not specified, the default TCTI is searched for using
236       dlopen(3) semantics.  The tools will  search  for  tabrmd,  device  and
237       mssim  TCTIs  IN THAT ORDER and USE THE FIRST ONE FOUND.  You can query
238       what TCTI will be chosen as the default by using the -v option to print
239       the  version information.  The "default-tcti" key-value pair will indi‐
240       cate which of the aforementioned TCTIs is the default.
241
242   Custom TCTIs
243       Any TCTI that implements the dynamic TCTI interface can be loaded.  The
244       tools internally use dlopen(3), and the raw tcti-name value is used for
245       the lookup.  Thus, this could be a path to the shared library, or a li‐
246       brary name as understood by dlopen(3) semantics.
247

TCTI OPTIONS

249       This collection of options are used to configure the various known TCTI
250       modules available:
251
252       · device: For the device TCTI, the TPM character device file for use by
253         the device TCTI can be specified.  The default is /dev/tpm0.
254
255         Example:    -T   device:/dev/tpm0   or   export   TPM2TOOLS_TCTI="de‐
256         vice:/dev/tpm0"
257
258       · mssim: For the mssim TCTI, the domain name or  IP  address  and  port
259         number  used  by  the  simulator  can  be specified.  The default are
260         127.0.0.1 and 2321.
261
262         Example: -T mssim:host=localhost,port=2321  or  export  TPM2TOOLS_TC‐
263         TI="mssim:host=localhost,port=2321"
264
265       · abrmd:  For  the abrmd TCTI, the configuration string format is a se‐
266         ries of simple key value pairs separated by a  ','  character.   Each
267         key and value string are separated by a '=' character.
268
269         · TCTI abrmd supports two keys:
270
271           1. 'bus_name'  :  The  name  of  the  tabrmd  service on the bus (a
272              string).
273
274           2. 'bus_type' : The type of the dbus instance (a string) limited to
275              'session' and 'system'.
276
277         Specify  the tabrmd tcti name and a config string of bus_name=com.ex‐
278         ample.FooBar:
279
280         \--tcti=tabrmd:bus_name=com.example.FooBar
281
282         Specify the default (abrmd) tcti and a config string of bus_type=ses‐
283         sion:
284
285         \--tcti:bus_type=session
286
287         NOTE:  abrmd  and tabrmd are synonymous.  the various known TCTI mod‐
288         ules.
289

EXAMPLES

291   Write the file nv.data to index 0x01000001
292              tpm2_nvdefine -Q   1 -C o -s 32 -a "ownerread|policywrite|ownerwrite"
293
294              echo "please123abc" > nv.test_w
295
296              tpm2_nvwrite -Q   1 -C o -i nv.test_w
297

Returns

299       Tools can return any of the following codes:
300
301       · 0 - Success.
302
303       · 1 - General non-specific error.
304
305       · 2 - Options handling error.
306
307       · 3 - Authentication error.
308
309       · 4 - TCTI related error.
310
311       · 5 - Non supported scheme.  Applicable to tpm2_testparams.
312

BUGS

314       Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
315

HELP

317       See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)
318
319
320
321tpm2-tools                                                     tpm2_nvwrite(1)
Impressum