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

NAME

6       tpm2_createprimary(1) - Create a primary key.
7

SYNOPSIS

9       tpm2_createprimary [OPTIONS]
10

DESCRIPTION

12       tpm2_createprimary(1) - This command is used to create a primary object
13       under one of the hierarchies: Owner, Platform, Endorsement, NULL.   The
14       command  will create and load a Primary Object.  The sensitive and pub‐
15       lic portions are not returned.  A context file for the created object's
16       handle is saved as a file for future interactions with the created pri‐
17       mary.
18

OPTIONS

20       · -C, --hierarchy=OBJECT:
21         The hierarchy under which the object is created.  This will also dic‐
22         tate  which authorization secret (if any) must be supplied.  Defaults
23         to TPM_RH_OWNER, when no value specified.  Supported options are:
24
25         · o for TPM_RH_OWNER
26
27         · p for TPM_RH_PLATFORM
28
29         · e for TPM_RH_ENDORSEMENT
30
31         · n for TPM_RH_NULL
32
33         · <num> where a raw number can be used.
34
35       · -P, --hierarchy-auth=AUTH:
36
37         The authorization value for the hierarchy specified with -C.
38
39       · -p, --key-auth=AUTH:
40
41         The authorization value for the primary object created.
42
43       · -g, --hash-algorithm=ALGORITHM:
44
45         The hash algorithm to use for generating the objects name.   Defaults
46         to sha256 if not specified.
47
48       · -G, --key-algorithm=ALGORITHM:
49
50         The  algorithm  type  for  the  generated  primary  key.  Defaults to
51         rsa2048:null:aes128cfb.
52
53       · -c, --key-context=FILE:
54
55         The file path to save the object context of the generated primary ob‐
56         ject.
57
58       · -L, --policy=FILE:
59
60         An  optional  file  input  that contains the policy digest for policy
61         based authorization of the object.
62
63       · -a, --attributes=ATTRIBUTES:
64
65         The object attributes, optional.  Defaults to:  TPMA_OBJECT_RESTRICT‐
66         ED|TPMA_OBJECT_DECRYPT|TPMA_OBJECT_FIXEDTPM|  TPMA_OBJECT_FIXEDPAR‐
67         ENT|TPMA_OBJECT_SENSITIVEDATAORIGIN|  TPMA_OBJECT_USERWITHAUTH
68
69       · -u, --unique-data=FILE:
70
71         An optional file input that contains the unique field of  TPMT_PUBLIC
72         in little-endian format.
73
74   References

Context Object Format

76       The  type  of a context object, whether it is a handle or file name, is
77       determined according to the following logic in-order:
78
79       · If the argument is a file path, then the file is loaded as a restored
80         TPM transient object.
81
82       · If the argument is a prefix match on one of:
83
84         · owner: the owner hierarchy
85
86         · platform: the platform hierarchy
87
88         · endorsement: the endorsement hierarchy
89
90         · lockout: the lockout control persistent object
91
92       · If  the  argument argument can be loaded as a number it will be treat
93         as a handle, e.g.  0x81010013 and used directly.OBJECT.
94

Authorization Formatting

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

Algorithm Specifiers

191       Options that take algorithms support "nice-names".
192
193       There  are two major algorithm specification string classes, simple and
194       complex.  Only certain algorithms will be accepted by the TPM, based on
195       usage and conditions.
196
197   Simple specifiers
198       These are strings with no additional specification data.  When creating
199       objects, non-specified portions of an object are assumed  to  defaults.
200       You can find the list of known "Simple Specifiers Below".
201
202   Asymmetric
203       · rsa
204
205       · ecc
206
207   Symmetric
208       · aes
209
210       · camellia
211
212   Hashing Algorithms
213       · sha1
214
215       · sha256
216
217       · sha384
218
219       · sha512
220
221       · sm3_256
222
223       · sha3_256
224
225       · sha3_384
226
227       · sha3_512
228
229   Keyed Hash
230       · hmac
231
232       · xor
233
234   Signing Schemes
235       · rsassa
236
237       · rsapss
238
239       · ecdsa
240
241       · ecdaa
242
243       · ecschnorr
244
245   Asymmetric Encryption Schemes
246       · oaep
247
248       · rsaes
249
250       · ecdh
251
252   Modes
253       · ctr
254
255       · ofb
256
257       · cbc
258
259       · cfb
260
261       · ecb
262
263   Misc
264       · null
265
266   Complex Specifiers
267       Objects,  when  specified  for creation by the TPM, have numerous algo‐
268       rithms to populate in the public data.  Things like  type,  scheme  and
269       asymmetric  details,  key  size,  etc.  Below is the general format for
270       specifying this data: <type>:<scheme>:<symmetric-details>
271
272   Type Specifiers
273       This portion of the complex algorithm specifier is required.   The  re‐
274       maining  scheme  and  symmetric  details will default based on the type
275       specified and the type of the object being created.
276
277       · aes - Default AES: aes128
278
279       · aes128<mode> - 128 bit AES with optional mode  (ctr|ofb|cbc|cfb|ecb).
280         If mode is not specified, defaults to null.
281
282       · aes192<mode> - Same as aes128<mode>, except for a 192 bit key size.
283
284       · aes256<mode> - Same as aes128<mode>, except for a 256 bit key size.
285
286       · ecc - Elliptical Curve, defaults to ecc256.
287
288       · ecc192 - 192 bit ECC
289
290       · ecc224 - 224 bit ECC
291
292       · ecc256 - 256 bit ECC
293
294       · ecc384 - 384 bit ECC
295
296       · ecc521 - 521 bit ECC
297
298       · rsa - Default RSA: rsa2048
299
300       · rsa1024 - RSA with 1024 bit keysize.
301
302       · rsa2048 - RSA with 2048 bit keysize.
303
304       · rsa4096 - RSA with 4096 bit keysize.
305
306   Scheme Specifiers
307       Next, is an optional field, it can be skipped.
308
309       Schemes  are  usually Signing Schemes or Asymmetric Encryption Schemes.
310       Most signing schemes take a hash algorithm directly following the sign‐
311       ing  scheme.   If the hash algorithm is missing, it defaults to sha256.
312       Some take no arguments, and some take multiple arguments.
313
314   Hash Optional Scheme Specifiers
315       These scheme specifiers are followed by a dash and a valid  hash  algo‐
316       rithm, For example: oaep-sha256.
317
318       · oaep
319
320       · ecdh
321
322       · rsassa
323
324       · rsapss
325
326       · ecdsa
327
328       · ecschnorr
329
330   Multiple Option Scheme Specifiers
331       This  scheme  specifier  is  followed by a count (max size UINT16) then
332       folloed by a dash(-) and a valid hash algorithm.  * ecdaa For  example,
333       ecdaa4-sha256.  If no count is specified, it defaults to 4.
334
335   No Option Scheme Specifiers
336       This scheme specifier takes NO arguments.  * rsaes
337
338   Symmetric Details Specifiers
339       This  field is optional, and defaults based on the type of object being
340       created and it's attributes.  Generally, any valid Symmetric  specifier
341       from  the Type Specifiers list should work.  If not specified, an asym‐
342       metric objects symmetric details defaults to aes128cfb.
343
344   Examples
345   Create an rsa2048 key with an rsaes asymmetric encryption scheme
346       tpm2_create -C parent.ctx -G rsa2048:rsaes -u key.pub -r key.priv
347
348   Create an ecc256 key with an ecdaa signing scheme with a count of 4
349       and sha384 hash
350
351       /tpm2_create -C parent.ctx -G ecc256:ec‐
352       daa4-sha384 -u key.pub -r key.priv cryptographic algorithms ALGORITHM.
353

Object Attributes

355       Object Attributes are used to control various properties of created ob‐
356       jects.  When specified as an option, either the raw  bitfield  mask  or
357       "nice-names"  may  be used.  The values can be found in Table 31 Part 2
358       of the TPM2.0 specification, which can be found here:
359
360       <https://trustedcomputinggroup.org/wp-content/uploads/TPM-
361       Rev-2.0-Part-2-Structures-01.38.pdf>
362
363       Nice  names are calculated by taking the name field of table 31 and re‐
364       moving the prefix TPMA_OBJECT_ and lowercasing the result.   Thus,  TP‐
365       MA_OBJECT_FIXEDTPM  becomes  fixedtpm.   Nice names can be joined using
366       the bitwise or "|" symbol.
367
368       For instance, to set The fields TPMA_OBJECT_FIXEDTPM, TPMA_OBJECT_NODA,
369       and TPMA_OBJECT_SIGN_ENCRYPT, the argument would be:
370
371       fixedtpm|noda|sign specifying the object attributes ATTRIBUTES.
372

COMMON OPTIONS

374       This  collection of options are common to many programs and provide in‐
375       formation that many users may expect.
376
377       · -h, --help=[man|no-man]: Display the tools manpage.  By  default,  it
378         attempts  to  invoke  the  manpager for the tool, however, on failure
379         will output a short tool summary.  This is the same behavior  if  the
380         "man"  option argument is specified, however if explicit "man" is re‐
381         quested, the tool will provide errors from man  on  stderr.   If  the
382         "no-man"  option  if  specified, or the manpager fails, the short op‐
383         tions will be output to stdout.
384
385         To successfully use the manpages feature requires the manpages to  be
386         installed or on MANPATH, See man(1) for more details.
387
388       · -v,  --version:  Display version information for this tool, supported
389         tctis and exit.
390
391       · -V, --verbose: Increase the information that the tool prints  to  the
392         console  during  its  execution.  When using this option the file and
393         line number are printed.
394
395       · -Q, --quiet: Silence normal tool output to stdout.
396
397       · -Z, --enable-errata: Enable the application of errata fixups.  Useful
398         if  an  errata fixup needs to be applied to commands sent to the TPM.
399         Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.   in‐
400         formation many users may expect.
401

TCTI Configuration

403       The  TCTI  or  "Transmission  Interface" is the communication mechanism
404       with the TPM.  TCTIs can be changed for communication with TPMs  across
405       different mediums.
406
407       To control the TCTI, the tools respect:
408
409       1. The command line option -T or --tcti
410
411       2. The environment variable: TPM2TOOLS_TCTI.
412
413       Note:  The  command  line option always overrides the environment vari‐
414       able.
415
416       The current known TCTIs are:
417
418       · tabrmd     -     The     resource     manager,     called      tabrmd
419         (https://github.com/tpm2-software/tpm2-abrmd).   Note that tabrmd and
420         abrmd as a tcti name are synonymous.
421
422       · mssim - Typically used for communicating to the TPM software  simula‐
423         tor.
424
425       · device - Used when talking directly to a TPM device file.
426
427       · none  - Do not initalize a connection with the TPM.  Some tools allow
428         for off-tpm options and thus support not using a TCTI.  Tools that do
429         not  support  it  will error when attempted to be used without a TCTI
430         connection.  Does not support ANY options and MUST  BE  presented  as
431         the exact text of "none".
432
433       The  arguments  to  either  the  command line option or the environment
434       variable are in the form:
435
436       <tcti-name>:<tcti-option-config>
437
438       Specifying an empty string for  either  the  <tcti-name>  or  <tcti-op‐
439       tion-config> results in the default being used for that portion respec‐
440       tively.
441
442   TCTI Defaults
443       When a TCTI is not specified, the default TCTI is  searched  for  using
444       dlopen(3)  semantics.   The  tools  will  search for tabrmd, device and
445       mssim TCTIs IN THAT ORDER and USE THE FIRST ONE FOUND.  You  can  query
446       what TCTI will be chosen as the default by using the -v option to print
447       the version information.  The "default-tcti" key-value pair will  indi‐
448       cate which of the aforementioned TCTIs is the default.
449
450   Custom TCTIs
451       Any TCTI that implements the dynamic TCTI interface can be loaded.  The
452       tools internally use dlopen(3), and the raw tcti-name value is used for
453       the lookup.  Thus, this could be a path to the shared library, or a li‐
454       brary name as understood by dlopen(3) semantics.
455

TCTI OPTIONS

457       This collection of options are used to configure the various known TCTI
458       modules available:
459
460       · device: For the device TCTI, the TPM character device file for use by
461         the device TCTI can be specified.  The default is /dev/tpm0.
462
463         Example:   -T   device:/dev/tpm0   or   export    TPM2TOOLS_TCTI="de‐
464         vice:/dev/tpm0"
465
466       · mssim:  For  the  mssim  TCTI, the domain name or IP address and port
467         number used by the simulator  can  be  specified.   The  default  are
468         127.0.0.1 and 2321.
469
470         Example:  -T  mssim:host=localhost,port=2321  or export TPM2TOOLS_TC‐
471         TI="mssim:host=localhost,port=2321"
472
473       · abrmd: For the abrmd TCTI, the configuration string format is  a  se‐
474         ries  of  simple  key value pairs separated by a ',' character.  Each
475         key and value string are separated by a '=' character.
476
477         · TCTI abrmd supports two keys:
478
479           1. 'bus_name' : The name of  the  tabrmd  service  on  the  bus  (a
480              string).
481
482           2. 'bus_type' : The type of the dbus instance (a string) limited to
483              'session' and 'system'.
484
485         Specify the tabrmd tcti name and a config string of  bus_name=com.ex‐
486         ample.FooBar:
487
488         \--tcti=tabrmd:bus_name=com.example.FooBar
489
490         Specify the default (abrmd) tcti and a config string of bus_type=ses‐
491         sion:
492
493         \--tcti:bus_type=session
494
495         NOTE: abrmd and tabrmd are synonymous.  the various known  TCTI  mod‐
496         ules.
497

EXAMPLES

499   Create an ECC primary object
500              tpm2_createprimary -C o -g sha256 -G ecc -c context.out
501
502   Create a primary object that follows the guidance of TCG
503       Provisioning guide
504
505       See          :         https://trustedcomputinggroup.org/wp-content/up
506       loads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdf
507
508       Where unique.dat contains the binary-formatted data: 0x00 0x01 (0x00  *
509       256)
510
511              tpm2_createprimary -C o -G rsa2048:aes128cfb -g sha256 -c prim.ctx \
512              -a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|\
513              noda' -u unique.dat
514

Returns

516       Tools can return any of the following codes:
517
518       · 0 - Success.
519
520       · 1 - General non-specific error.
521
522       · 2 - Options handling error.
523
524       · 3 - Authentication error.
525
526       · 4 - TCTI related error.
527
528       · 5 - Non supported scheme.  Applicable to tpm2_testparams.
529

BUGS

531       Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
532

HELP

534       See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)
535
536
537
538tpm2-tools                                               tpm2_createprimary(1)
Impressum