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.  Primary key creator may place information
73         that causes the primary key generation scheme internal to the TPM  to
74         generate  statistically  unique  values.   The TPM v2.0 specification
75         calls this field unique and overloads it so that it contains one val‐
76         ue  when the application provides this structure as input and another
77         value when the applications receives this structure as  output  (like
78         public portion of the rsa key).
79
80       · --creation-data=FILE:
81
82         An  optional  file output that saves the creation data for certifica‐
83         tion.
84
85       · --template-data=FILE:
86
87         An optional file output that saves the key template data  (TPM2B_PUB‐
88         LIC) to be used in tpm2_policytemplate.
89
90       · -t, --creation-ticket=FILE:
91
92         An optional file output that saves the creation ticket for certifica‐
93         tion.
94
95       · -d, --creation-hash=FILE:
96
97         An optional file output that saves the creation hash  for  certifica‐
98         tion.
99
100       · -q, --outside-info=FILE_OR_HEX:
101
102         An optional file or hex string to add unique data to the creation da‐
103         ta.  Note that it  does  not  contribute  in  creating  statistically
104         unique object.
105
106       · -l, --pcr-list=PCR:
107
108         The  list of PCR banks and selected PCRs' ids for each bank to be in‐
109         cluded in the creation data for certification.
110
111       · --cphash=FILE
112
113         File path to record the hash of the command parameters.  This is com‐
114         monly termed as cpHash.  NOTE: When this option is selected, The tool
115         will not actually execute the command, it simply returns a cpHash.
116
117   References

Context Object Format

119       The type of a context object, whether it is a handle or file  name,  is
120       determined according to the following logic in-order:
121
122       · If the argument is a file path, then the file is loaded as a restored
123         TPM transient object.
124
125       · If the argument is a prefix match on one of:
126
127         · owner: the owner hierarchy
128
129         · platform: the platform hierarchy
130
131         · endorsement: the endorsement hierarchy
132
133         · lockout: the lockout control persistent object
134
135       · If the argument argument can be loaded as a number it will  be  treat
136         as a handle, e.g.  0x81010013 and used directly.OBJECT.
137

Authorization Formatting

139       Authorization  for  use  of an object in TPM2.0 can come in 3 different
140       forms: 1.  Password 2.  HMAC 3.  Sessions
141
142       NOTE: "Authorizations default to the EMPTY  PASSWORD  when  not  speci‐
143       fied".
144
145   Passwords
146       Passwords  are  interpreted  in  the following forms below using prefix
147       identifiers.
148
149       Note: By default passwords are assumed to be in the  string  form  when
150       they do not have a prefix.
151
152   String
153       A  string  password,  specified  by  prefix "str:" or it's absence (raw
154       string without prefix) is not interpreted, and is directly used for au‐
155       thorization.
156
157   Examples
158              foobar
159              str:foobar
160
161   Hex-string
162       A  hex-string  password, specified by prefix "hex:" is converted from a
163       hexidecimal form into a byte array form, thus allowing  passwords  with
164       non-printable and/or terminal un-friendly characters.
165
166   Example
167              hex:0x1122334455667788
168
169   File
170       A  file  based password, specified be prefix "file:" should be the path
171       of a file containing the password to be read by the tool or  a  "-"  to
172       use  stdin.   Storing  passwords in files prevents information leakage,
173       passwords passed as options can be read from the process list or common
174       shell history features.
175
176   Examples
177              # to use stdin and be prompted
178              file:-
179
180              # to use a file from a path
181              file:path/to/password/file
182
183              # to echo a password via stdin:
184              echo foobar | tpm2_tool -p file:-
185
186              # to use a bash here-string via stdin:
187
188              tpm2_tool -p file:- <<< foobar
189
190   Sessions
191       When  using  a policy session to authorize the use of an object, prefix
192       the option argument with the session keyword.  Then indicate a path  to
193       a session file that was created with tpm2_startauthsession(1).  Option‐
194       ally, if the session requires an auth value to be sent with the session
195       handle  (eg policy password), then append a + and a string as described
196       in the Passwords section.
197
198   Examples
199       To use a session context file called session.ctx.
200
201              session:session.ctx
202
203       To use a session context file called session.ctx AND send the authvalue
204       mypassword.
205
206              session:session.ctx+mypassword
207
208       To use a session context file called session.ctx AND send the HEX auth‐
209       value 0x11223344.
210
211              session:session.ctx+hex:11223344
212
213   PCR Authorizations
214       You can satisfy a PCR policy using the "pcr:" prefix and the PCR  mini‐
215       language.       The     PCR     minilanguage     is     as     follows:
216       <pcr-spec>=<raw-pcr-file>
217
218       The PCR spec is documented in in the section "PCR bank specifiers".
219
220       The raw-pcr-file is an optional the output of the raw PCR  contents  as
221       returned by tpm2_pcrread(1).
222
223       PCR bank specifiers (common/pcr.md)
224
225   Examples
226       To satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3 use a specifi‐
227       er of:
228
229              pcr:sha256:0,1,2,3
230
231       specifying AUTH.
232

Algorithm Specifiers

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

Object Attributes

398       Object Attributes are used to control various properties of created ob‐
399       jects.   When  specified  as an option, either the raw bitfield mask or
400       "nice-names" may be used.  The values can be found in Table 31  Part  2
401       of the TPM2.0 specification, which can be found here:
402
403       <https://trustedcomputinggroup.org/wp-content/uploads/TPM-
404       Rev-2.0-Part-2-Structures-01.38.pdf>
405
406       Nice names are calculated by taking the name field of table 31 and  re‐
407       moving  the  prefix TPMA_OBJECT_ and lowercasing the result.  Thus, TP‐
408       MA_OBJECT_FIXEDTPM becomes fixedtpm.  Nice names can  be  joined  using
409       the bitwise or "|" symbol.
410
411       For instance, to set The fields TPMA_OBJECT_FIXEDTPM, TPMA_OBJECT_NODA,
412       and TPMA_OBJECT_SIGN_ENCRYPT, the argument would be:
413
414       fixedtpm|noda|sign specifying the object attributes ATTRIBUTES.
415

COMMON OPTIONS

417       This collection of options are common to many programs and provide  in‐
418       formation that many users may expect.
419
420       · -h,  --help=[man|no-man]:  Display the tools manpage.  By default, it
421         attempts to invoke the manpager for the  tool,  however,  on  failure
422         will  output  a short tool summary.  This is the same behavior if the
423         "man" option argument is specified, however if explicit "man" is  re‐
424         quested,  the  tool  will  provide errors from man on stderr.  If the
425         "no-man" option if specified, or the manpager fails,  the  short  op‐
426         tions will be output to stdout.
427
428         To  successfully use the manpages feature requires the manpages to be
429         installed or on MANPATH, See man(1) for more details.
430
431       · -v, --version: Display version information for this  tool,  supported
432         tctis and exit.
433
434       · -V,  --verbose:  Increase the information that the tool prints to the
435         console during its execution.  When using this option  the  file  and
436         line number are printed.
437
438       · -Q, --quiet: Silence normal tool output to stdout.
439
440       · -Z, --enable-errata: Enable the application of errata fixups.  Useful
441         if an errata fixup needs to be applied to commands sent to  the  TPM.
442         Defining  the environment TPM2TOOLS_ENABLE_ERRATA is equivalent.  in‐
443         formation many users may expect.
444

TCTI Configuration

446       The TCTI or "Transmission Interface"  is  the  communication  mechanism
447       with  the TPM.  TCTIs can be changed for communication with TPMs across
448       different mediums.
449
450       To control the TCTI, the tools respect:
451
452       1. The command line option -T or --tcti
453
454       2. The environment variable: TPM2TOOLS_TCTI.
455
456       Note: The command line option always overrides  the  environment  vari‐
457       able.
458
459       The current known TCTIs are:
460
461       · tabrmd      -     The     resource     manager,     called     tabrmd
462         (https://github.com/tpm2-software/tpm2-abrmd).  Note that tabrmd  and
463         abrmd as a tcti name are synonymous.
464
465       · mssim  - Typically used for communicating to the TPM software simula‐
466         tor.
467
468       · device - Used when talking directly to a TPM device file.
469
470       · none - Do not initalize a connection with the TPM.  Some tools  allow
471         for off-tpm options and thus support not using a TCTI.  Tools that do
472         not support it will error when attempted to be used  without  a  TCTI
473         connection.   Does  not  support ANY options and MUST BE presented as
474         the exact text of "none".
475
476       The arguments to either the command  line  option  or  the  environment
477       variable are in the form:
478
479       <tcti-name>:<tcti-option-config>
480
481       Specifying  an  empty  string  for  either the <tcti-name> or <tcti-op‐
482       tion-config> results in the default being used for that portion respec‐
483       tively.
484
485   TCTI Defaults
486       When  a  TCTI  is not specified, the default TCTI is searched for using
487       dlopen(3) semantics.  The tools will  search  for  tabrmd,  device  and
488       mssim  TCTIs  IN THAT ORDER and USE THE FIRST ONE FOUND.  You can query
489       what TCTI will be chosen as the default by using the -v option to print
490       the  version information.  The "default-tcti" key-value pair will indi‐
491       cate which of the aforementioned TCTIs is the default.
492
493   Custom TCTIs
494       Any TCTI that implements the dynamic TCTI interface can be loaded.  The
495       tools internally use dlopen(3), and the raw tcti-name value is used for
496       the lookup.  Thus, this could be a path to the shared library, or a li‐
497       brary name as understood by dlopen(3) semantics.
498

TCTI OPTIONS

500       This collection of options are used to configure the various known TCTI
501       modules available:
502
503       · device: For the device TCTI, the TPM character device file for use by
504         the device TCTI can be specified.  The default is /dev/tpm0.
505
506         Example:    -T   device:/dev/tpm0   or   export   TPM2TOOLS_TCTI="de‐
507         vice:/dev/tpm0"
508
509       · mssim: For the mssim TCTI, the domain name or  IP  address  and  port
510         number  used  by  the  simulator  can  be specified.  The default are
511         127.0.0.1 and 2321.
512
513         Example: -T mssim:host=localhost,port=2321  or  export  TPM2TOOLS_TC‐
514         TI="mssim:host=localhost,port=2321"
515
516       · abrmd:  For  the abrmd TCTI, the configuration string format is a se‐
517         ries of simple key value pairs separated by a  ','  character.   Each
518         key and value string are separated by a '=' character.
519
520         · TCTI abrmd supports two keys:
521
522           1. 'bus_name'  :  The  name  of  the  tabrmd  service on the bus (a
523              string).
524
525           2. 'bus_type' : The type of the dbus instance (a string) limited to
526              'session' and 'system'.
527
528         Specify  the tabrmd tcti name and a config string of bus_name=com.ex‐
529         ample.FooBar:
530
531         \--tcti=tabrmd:bus_name=com.example.FooBar
532
533         Specify the default (abrmd) tcti and a config string of bus_type=ses‐
534         sion:
535
536         \--tcti:bus_type=session
537
538         NOTE:  abrmd  and tabrmd are synonymous.  the various known TCTI mod‐
539         ules.
540

EXAMPLES

542   Create an ECC primary object
543              tpm2_createprimary -C o -g sha256 -G ecc -c context.out
544
545   Create a primary object that follows the guidance of TCG
546       Provisioning guide
547
548       See         :          https://trustedcomputinggroup.org/wp-content/up
549       loads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdf
550
551       Where  unique.dat contains the binary-formatted data: 0x00 0x01 (0x00 *
552       256)
553
554              tpm2_createprimary -C o -G rsa2048:aes128cfb -g sha256 -c prim.ctx \
555              -a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|\
556              noda' -u unique.dat
557

Returns

559       Tools can return any of the following codes:
560
561       · 0 - Success.
562
563       · 1 - General non-specific error.
564
565       · 2 - Options handling error.
566
567       · 3 - Authentication error.
568
569       · 4 - TCTI related error.
570
571       · 5 - Non supported scheme.  Applicable to tpm2_testparams.
572

BUGS

574       Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
575

HELP

577       See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)
578
579
580
581tpm2-tools                                               tpm2_createprimary(1)
Impressum