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

NAME

6       tpm2_hmac(1) - Performs an HMAC operation with the TPM.
7

SYNOPSIS

9       tpm2_hmac [OPTIONS] [ARGUMENT]
10

DESCRIPTION

12       tpm2_hmac(1)  - Performs an HMAC operation and returns the results.  If
13       argument file is not specified, then data is read from stdin.
14
15       The hashing algorithm defaults to the keys scheme or sha256 if the  key
16       has a NULL scheme.
17
18       Output  defaults to STDOUT and binary format unless otherwise specified
19       via -o and --hex options respectively.
20

OPTIONS

22       · -c, --key-context=OBJECT:
23
24         The context object of the symmetric signing key  providing  the  HMAC
25         key.   Either a file or a handle number.  See section "Context Object
26         Format".
27
28       · -p, --auth=AUTH:
29
30         Optional authorization value to use the key specified by -c.
31
32       · -g, --hash-algorithm=ALGORITHM:
33
34         The hash algorithm to use.  Algorithms should follow the  "formatting
35         standards",  see  section  "Algorithm Specifiers".  Also, see section
36         "Supported Hash Algorithms" for a list of supported hash algorithms.
37
38       · --hex
39
40         Convert the output hmac to hex format without a leading "0x".
41
42       · -o, --output=FILE:
43
44         Optional file record of the HMAC result.  Defaults to STDOUT.
45
46       · -t, --ticket=FILE:
47
48         Optional file record of the ticket result.
49
50       · ARGUMENT the command line argument specifies the file  path  for  the
51         data to HMAC.  Defaults to STDIN if not specified.
52
53   References

Context Object Format

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

Authorization Formatting

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

Authorization Formatting

170       Authorization  for  use  of an object in TPM2.0 can come in 3 different
171       forms: 1.  Password 2.  HMAC 3.  Sessions
172
173       NOTE: "Authorizations default to the EMPTY  PASSWORD  when  not  speci‐
174       fied".
175
176   Passwords
177       Passwords  are  interpreted  in  the following forms below using prefix
178       identifiers.
179
180       Note: By default passwords are assumed to be in the  string  form  when
181       they do not have a prefix.
182
183   String
184       A  string  password,  specified  by  prefix "str:" or it's absence (raw
185       string without prefix) is not interpreted, and is directly used for au‐
186       thorization.
187
188   Examples
189              foobar
190              str:foobar
191
192   Hex-string
193       A  hex-string  password, specified by prefix "hex:" is converted from a
194       hexidecimal form into a byte array form, thus allowing  passwords  with
195       non-printable and/or terminal un-friendly characters.
196
197   Example
198              hex:0x1122334455667788
199
200   File
201       A  file  based password, specified be prefix "file:" should be the path
202       of a file containing the password to be read by the tool or  a  "-"  to
203       use  stdin.   Storing  passwords in files prevents information leakage,
204       passwords passed as options can be read from the process list or common
205       shell history features.
206
207   Examples
208              # to use stdin and be prompted
209              file:-
210
211              # to use a file from a path
212              file:path/to/password/file
213
214              # to echo a password via stdin:
215              echo foobar | tpm2_tool -p file:-
216
217              # to use a bash here-string via stdin:
218
219              tpm2_tool -p file:- <<< foobar
220
221   Sessions
222       When  using  a policy session to authorize the use of an object, prefix
223       the option argument with the session keyword.  Then indicate a path  to
224       a session file that was created with tpm2_startauthsession(1).  Option‐
225       ally, if the session requires an auth value to be sent with the session
226       handle  (eg policy password), then append a + and a string as described
227       in the Passwords section.
228
229   Examples
230       To use a session context file called session.ctx.
231
232              session:session.ctx
233
234       To use a session context file called session.ctx AND send the authvalue
235       mypassword.
236
237              session:session.ctx+mypassword
238
239       To use a session context file called session.ctx AND send the HEX auth‐
240       value 0x11223344.
241
242              session:session.ctx+hex:11223344
243
244   PCR Authorizations
245       You can satisfy a PCR policy using the "pcr:" prefix and the PCR  mini‐
246       language.       The     PCR     minilanguage     is     as     follows:
247       <pcr-spec>=<raw-pcr-file>
248
249       The PCR spec is documented in in the section "PCR bank specifiers".
250
251       The raw-pcr-file is an optional the output of the raw PCR  contents  as
252       returned by tpm2_pcrread(1).
253
254       PCR bank specifiers (common/pcr.md)
255
256   Examples
257       To satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3 use a specifi‐
258       er of:
259
260              pcr:sha256:0,1,2,3
261
262       ALGORITHM.
263

COMMON OPTIONS

265       This collection of options are common to many programs and provide  in‐
266       formation that many users may expect.
267
268       · -h,  --help=[man|no-man]:  Display the tools manpage.  By default, it
269         attempts to invoke the manpager for the  tool,  however,  on  failure
270         will  output  a short tool summary.  This is the same behavior if the
271         "man" option argument is specified, however if explicit "man" is  re‐
272         quested,  the  tool  will  provide errors from man on stderr.  If the
273         "no-man" option if specified, or the manpager fails,  the  short  op‐
274         tions will be output to stdout.
275
276         To  successfully use the manpages feature requires the manpages to be
277         installed or on MANPATH, See man(1) for more details.
278
279       · -v, --version: Display version information for this  tool,  supported
280         tctis and exit.
281
282       · -V,  --verbose:  Increase the information that the tool prints to the
283         console during its execution.  When using this option  the  file  and
284         line number are printed.
285
286       · -Q, --quiet: Silence normal tool output to stdout.
287
288       · -Z, --enable-errata: Enable the application of errata fixups.  Useful
289         if an errata fixup needs to be applied to commands sent to  the  TPM.
290         Defining  the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.  in‐
291         formation many users may expect.
292

TCTI Configuration

294       The TCTI or "Transmission Interface"  is  the  communication  mechanism
295       with  the TPM.  TCTIs can be changed for communication with TPMs across
296       different mediums.
297
298       To control the TCTI, the tools respect:
299
300       1. The command line option -T or --tcti
301
302       2. The environment variable: TPM2TOOLS_TCTI.
303
304       Note: The command line option always overrides  the  environment  vari‐
305       able.
306
307       The current known TCTIs are:
308
309       · tabrmd      -     The     resource     manager,     called     tabrmd
310         (https://github.com/tpm2-software/tpm2-abrmd).  Note that tabrmd  and
311         abrmd as a tcti name are synonymous.
312
313       · mssim  - Typically used for communicating to the TPM software simula‐
314         tor.
315
316       · device - Used when talking directly to a TPM device file.
317
318       · none - Do not initalize a connection with the TPM.  Some tools  allow
319         for off-tpm options and thus support not using a TCTI.  Tools that do
320         not support it will error when attempted to be used  without  a  TCTI
321         connection.   Does  not  support ANY options and MUST BE presented as
322         the exact text of "none".
323
324       The arguments to either the command  line  option  or  the  environment
325       variable are in the form:
326
327       <tcti-name>:<tcti-option-config>
328
329       Specifying  an  empty  string  for  either the <tcti-name> or <tcti-op‐
330       tion-config> results in the default being used for that portion respec‐
331       tively.
332
333   TCTI Defaults
334       When  a  TCTI  is not specified, the default TCTI is searched for using
335       dlopen(3) semantics.  The tools will  search  for  tabrmd,  device  and
336       mssim  TCTIs  IN THAT ORDER and USE THE FIRST ONE FOUND.  You can query
337       what TCTI will be chosen as the default by using the -v option to print
338       the  version information.  The "default-tcti" key-value pair will indi‐
339       cate which of the aforementioned TCTIs is the default.
340
341   Custom TCTIs
342       Any TCTI that implements the dynamic TCTI interface can be loaded.  The
343       tools internally use dlopen(3), and the raw tcti-name value is used for
344       the lookup.  Thus, this could be a path to the shared library, or a li‐
345       brary name as understood by dlopen(3) semantics.
346

TCTI OPTIONS

348       This collection of options are used to configure the various known TCTI
349       modules available:
350
351       · device: For the device TCTI, the TPM character device file for use by
352         the device TCTI can be specified.  The default is /dev/tpm0.
353
354         Example:    -T   device:/dev/tpm0   or   export   TPM2TOOLS_TCTI="de‐
355         vice:/dev/tpm0"
356
357       · mssim: For the mssim TCTI, the domain name or  IP  address  and  port
358         number  used  by  the  simulator  can  be specified.  The default are
359         127.0.0.1 and 2321.
360
361         Example: -T mssim:host=localhost,port=2321  or  export  TPM2TOOLS_TC‐
362         TI="mssim:host=localhost,port=2321"
363
364       · abrmd:  For  the abrmd TCTI, the configuration string format is a se‐
365         ries of simple key value pairs separated by a  ','  character.   Each
366         key and value string are separated by a '=' character.
367
368         · TCTI abrmd supports two keys:
369
370           1. 'bus_name'  :  The  name  of  the  tabrmd  service on the bus (a
371              string).
372
373           2. 'bus_type' : The type of the dbus instance (a string) limited to
374              'session' and 'system'.
375
376         Specify  the tabrmd tcti name and a config string of bus_name=com.ex‐
377         ample.FooBar:
378
379         \--tcti=tabrmd:bus_name=com.example.FooBar
380
381         Specify the default (abrmd) tcti and a config string of bus_type=ses‐
382         sion:
383
384         \--tcti:bus_type=session
385
386         NOTE:  abrmd  and tabrmd are synonymous.  the various known TCTI mod‐
387         ules.
388

EXAMPLES

390   Setup
391              # create a primary object
392              tpm2_createprimary -o primary.ctx
393
394              # create an hmac key
395              tpm2_create -C primary.ctx -Ghmac -o hmac.key
396
397   Perform an HMAC with Default Hash Algorithm
398       Perform an hmac using the key's default  scheme  (hash  algorithm)  and
399       output to stdout in hexidecimal format.
400
401              tpm2_hmac -c hmac.key --hex data.in
402              e6eda48a53a9ddbb92f788f6d98e0372d63a408afb11aca43f522a2475a32805
403

Returns

405       Tools can return any of the following codes:
406
407       · 0 - Success.
408
409       · 1 - General non-specific error.
410
411       · 2 - Options handling error.
412
413       · 3 - Authentication error.
414
415       · 4 - TCTI related error.
416
417       · 5 - Non supported scheme.  Applicable to tpm2_testparams.
418

BUGS

420       Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
421

HELP

423       See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)
424
425
426
427tpm2-tools                                                        tpm2_hmac(1)
Impressum