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   References

Context Object Format

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

Authorization Formatting

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

COMMON OPTIONS

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

TCTI Configuration

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

TCTI OPTIONS

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

EXAMPLES

285   Write the file nv.data to index 0x01000001
286              tpm2_nvdefine -Q   1 -C o -s 32 -a "ownerread|policywrite|ownerwrite"
287
288              echo "please123abc" > nv.test_w
289
290              tpm2_nvwrite -Q   1 -C o -i nv.test_w
291

Returns

293       Tools can return any of the following codes:
294
295       · 0 - Success.
296
297       · 1 - General non-specific error.
298
299       · 2 - Options handling error.
300
301       · 3 - Authentication error.
302
303       · 4 - TCTI related error.
304
305       · 5 - Non supported scheme.  Applicable to tpm2_testparams.
306

BUGS

308       Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
309

HELP

311       See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)
312
313
314
315tpm2-tools                                                     tpm2_nvwrite(1)
Impressum