1tpm2_createprimary(1) General Commands Manual tpm2_createprimary(1)
2
3
4
6 tpm2_createprimary(1) - Create a primary key.
7
9 tpm2_createprimary [OPTIONS]
10
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
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 OR STDIN:
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 If the data is specified as a file, the user is responsible for en‐
81 suring that this buffer is formatted per TPMU_PUBLIC_ID union.
82
83 The unique data can also be retrieved from stdin buffer by specifying
84 "-" as the --unique-data option value and the tool will parse the key
85 type and associate the input data with the unique data buffer associ‐
86 ated with the key type. NOTE:
87
88 1. The maximum allowed bytes is dependent on key type and the TPM im‐
89 plementation. Eg. While TSS allows a value upto 512 for
90 MAX_RSA_KEY_BYTES, however the ibmSwTPM implementation supports a
91 value upto 256 bytes.
92
93 2. The unique input data specified on stdin for ECC is split for
94 specifying the X coordinate and Y coordinate buffers.
95
96 • --creation-data=FILE:
97
98 An optional file output that saves the creation data for certifica‐
99 tion.
100
101 • --template-data=FILE:
102
103 An optional file output that saves the key template data (TPM2B_PUB‐
104 LIC) to be used in tpm2_policytemplate.
105
106 • -t, --creation-ticket=FILE:
107
108 An optional file output that saves the creation ticket for certifica‐
109 tion.
110
111 • -d, --creation-hash=FILE:
112
113 An optional file output that saves the creation hash for certifica‐
114 tion.
115
116 • -q, --outside-info=FILE_OR_HEX:
117
118 An optional file or hex string to add unique data to the creation da‐
119 ta. Note that it does not contribute in creating statistically
120 unique object.
121
122 • -l, --pcr-list=PCR:
123
124 The list of PCR banks and selected PCRs' ids for each bank to be in‐
125 cluded in the creation data for certification.
126
127 • --cphash=FILE
128
129 File path to record the hash of the command parameters. This is com‐
130 monly termed as cpHash. NOTE: When this option is selected, The tool
131 will not actually execute the command, it simply returns a cpHash.
132
133 References
135 The type of a context object, whether it is a handle or file name, is
136 determined according to the following logic in-order:
137
138 • If the argument is a file path, then the file is loaded as a restored
139 TPM transient object.
140
141 • If the argument is a prefix match on one of:
142
143 • owner: the owner hierarchy
144
145 • platform: the platform hierarchy
146
147 • endorsement: the endorsement hierarchy
148
149 • lockout: the lockout control persistent object
150
151 • If the argument argument can be loaded as a number it will be treat
152 as a handle, e.g. 0x81010013 and used directly.OBJECT.
153
155 Authorization for use of an object in TPM2.0 can come in 3 different
156 forms: 1. Password 2. HMAC 3. Sessions
157
158 NOTE: "Authorizations default to the EMPTY PASSWORD when not speci‐
159 fied".
160
161 Passwords
162 Passwords are interpreted in the following forms below using prefix
163 identifiers.
164
165 Note: By default passwords are assumed to be in the string form when
166 they do not have a prefix.
167
168 String
169 A string password, specified by prefix "str:" or it's absence (raw
170 string without prefix) is not interpreted, and is directly used for au‐
171 thorization.
172
173 Examples
174 foobar
175 str:foobar
176
177 Hex-string
178 A hex-string password, specified by prefix "hex:" is converted from a
179 hexidecimal form into a byte array form, thus allowing passwords with
180 non-printable and/or terminal un-friendly characters.
181
182 Example
183 hex:0x1122334455667788
184
185 File
186 A file based password, specified be prefix "file:" should be the path
187 of a file containing the password to be read by the tool or a "-" to
188 use stdin. Storing passwords in files prevents information leakage,
189 passwords passed as options can be read from the process list or common
190 shell history features.
191
192 Examples
193 # to use stdin and be prompted
194 file:-
195
196 # to use a file from a path
197 file:path/to/password/file
198
199 # to echo a password via stdin:
200 echo foobar | tpm2_tool -p file:-
201
202 # to use a bash here-string via stdin:
203
204 tpm2_tool -p file:- <<< foobar
205
206 Sessions
207 When using a policy session to authorize the use of an object, prefix
208 the option argument with the session keyword. Then indicate a path to
209 a session file that was created with tpm2_startauthsession(1). Option‐
210 ally, if the session requires an auth value to be sent with the session
211 handle (eg policy password), then append a + and a string as described
212 in the Passwords section.
213
214 Examples
215 To use a session context file called session.ctx.
216
217 session:session.ctx
218
219 To use a session context file called session.ctx AND send the authvalue
220 mypassword.
221
222 session:session.ctx+mypassword
223
224 To use a session context file called session.ctx AND send the HEX auth‐
225 value 0x11223344.
226
227 session:session.ctx+hex:11223344
228
229 PCR Authorizations
230 You can satisfy a PCR policy using the "pcr:" prefix and the PCR mini‐
231 language. The PCR minilanguage is as follows:
232 <pcr-spec>=<raw-pcr-file>
233
234 The PCR spec is documented in in the section "PCR bank specifiers".
235
236 The raw-pcr-file is an optional the output of the raw PCR contents as
237 returned by tpm2_pcrread(1).
238
239 PCR bank specifiers (common/pcr.md)
240
241 Examples
242 To satisfy a PCR policy of sha256 on banks 0, 1, 2 and 3 use a specifi‐
243 er of:
244
245 pcr:sha256:0,1,2,3
246
247 specifying AUTH.
248
250 Options that take algorithms support "nice-names".
251
252 There are two major algorithm specification string classes, simple and
253 complex. Only certain algorithms will be accepted by the TPM, based on
254 usage and conditions.
255
256 Simple specifiers
257 These are strings with no additional specification data. When creating
258 objects, non-specified portions of an object are assumed to defaults.
259 You can find the list of known "Simple Specifiers Below".
260
261 Asymmetric
262 • rsa
263
264 • ecc
265
266 Symmetric
267 • aes
268
269 • camellia
270
271 Hashing Algorithms
272 • sha1
273
274 • sha256
275
276 • sha384
277
278 • sha512
279
280 • sm3_256
281
282 • sha3_256
283
284 • sha3_384
285
286 • sha3_512
287
288 Keyed Hash
289 • hmac
290
291 • xor
292
293 Signing Schemes
294 • rsassa
295
296 • rsapss
297
298 • ecdsa
299
300 • ecdaa
301
302 • ecschnorr
303
304 Asymmetric Encryption Schemes
305 • oaep
306
307 • rsaes
308
309 • ecdh
310
311 Modes
312 • ctr
313
314 • ofb
315
316 • cbc
317
318 • cfb
319
320 • ecb
321
322 Misc
323 • null
324
325 Complex Specifiers
326 Objects, when specified for creation by the TPM, have numerous algo‐
327 rithms to populate in the public data. Things like type, scheme and
328 asymmetric details, key size, etc. Below is the general format for
329 specifying this data: <type>:<scheme>:<symmetric-details>
330
331 Type Specifiers
332 This portion of the complex algorithm specifier is required. The re‐
333 maining scheme and symmetric details will default based on the type
334 specified and the type of the object being created.
335
336 • aes - Default AES: aes128
337
338 • aes128<mode> - 128 bit AES with optional mode (ctr|ofb|cbc|cfb|ecb).
339 If mode is not specified, defaults to null.
340
341 • aes192<mode> - Same as aes128<mode>, except for a 192 bit key size.
342
343 • aes256<mode> - Same as aes128<mode>, except for a 256 bit key size.
344
345 • ecc - Elliptical Curve, defaults to ecc256.
346
347 • ecc192 - 192 bit ECC
348
349 • ecc224 - 224 bit ECC
350
351 • ecc256 - 256 bit ECC
352
353 • ecc384 - 384 bit ECC
354
355 • ecc521 - 521 bit ECC
356
357 • rsa - Default RSA: rsa2048
358
359 • rsa1024 - RSA with 1024 bit keysize.
360
361 • rsa2048 - RSA with 2048 bit keysize.
362
363 • rsa4096 - RSA with 4096 bit keysize.
364
365 Scheme Specifiers
366 Next, is an optional field, it can be skipped.
367
368 Schemes are usually Signing Schemes or Asymmetric Encryption Schemes.
369 Most signing schemes take a hash algorithm directly following the sign‐
370 ing scheme. If the hash algorithm is missing, it defaults to sha256.
371 Some take no arguments, and some take multiple arguments.
372
373 Hash Optional Scheme Specifiers
374 These scheme specifiers are followed by a dash and a valid hash algo‐
375 rithm, For example: oaep-sha256.
376
377 • oaep
378
379 • ecdh
380
381 • rsassa
382
383 • rsapss
384
385 • ecdsa
386
387 • ecschnorr
388
389 Multiple Option Scheme Specifiers
390 This scheme specifier is followed by a count (max size UINT16) then
391 followed by a dash(-) and a valid hash algorithm. * ecdaa For example,
392 ecdaa4-sha256. If no count is specified, it defaults to 4.
393
394 No Option Scheme Specifiers
395 This scheme specifier takes NO arguments. * rsaes
396
397 Symmetric Details Specifiers
398 This field is optional, and defaults based on the type of object being
399 created and it's attributes. Generally, any valid Symmetric specifier
400 from the Type Specifiers list should work. If not specified, an asym‐
401 metric objects symmetric details defaults to aes128cfb.
402
403 Examples
404 Create an rsa2048 key with an rsaes asymmetric encryption scheme
405 tpm2_create -C parent.ctx -G rsa2048:rsaes -u key.pub -r key.priv
406
407 Create an ecc256 key with an ecdaa signing scheme with a count of 4
408 and sha384 hash
409
410 /tpm2_create -C parent.ctx -G ecc256:ec‐
411 daa4-sha384 -u key.pub -r key.priv cryptographic algorithms ALGORITHM.
412
414 Object Attributes are used to control various properties of created ob‐
415 jects. When specified as an option, either the raw bitfield mask or
416 "nice-names" may be used. The values can be found in Table 31 Part 2
417 of the TPM2.0 specification, which can be found here:
418
419 <https://trustedcomputinggroup.org/wp-content/uploads/TPM-
420 Rev-2.0-Part-2-Structures-01.38.pdf>
421
422 Nice names are calculated by taking the name field of table 31 and re‐
423 moving the prefix TPMA_OBJECT_ and lowercasing the result. Thus, TP‐
424 MA_OBJECT_FIXEDTPM becomes fixedtpm. Nice names can be joined using
425 the bitwise or "|" symbol.
426
427 For instance, to set The fields TPMA_OBJECT_FIXEDTPM, TPMA_OBJECT_NODA,
428 and TPMA_OBJECT_SIGN_ENCRYPT, the argument would be:
429
430 fixedtpm|noda|sign specifying the object attributes ATTRIBUTES.
431
433 This collection of options are common to many programs and provide in‐
434 formation that many users may expect.
435
436 • -h, --help=[man|no-man]: Display the tools manpage. By default, it
437 attempts to invoke the manpager for the tool, however, on failure
438 will output a short tool summary. This is the same behavior if the
439 "man" option argument is specified, however if explicit "man" is re‐
440 quested, the tool will provide errors from man on stderr. If the
441 "no-man" option if specified, or the manpager fails, the short op‐
442 tions will be output to stdout.
443
444 To successfully use the manpages feature requires the manpages to be
445 installed or on MANPATH, See man(1) for more details.
446
447 • -v, --version: Display version information for this tool, supported
448 tctis and exit.
449
450 • -V, --verbose: Increase the information that the tool prints to the
451 console during its execution. When using this option the file and
452 line number are printed.
453
454 • -Q, --quiet: Silence normal tool output to stdout.
455
456 • -Z, --enable-errata: Enable the application of errata fixups. Useful
457 if an errata fixup needs to be applied to commands sent to the TPM.
458 Defining the environment TPM2TOOLS_ENABLE_ERRATA is equivalent. in‐
459 formation many users may expect.
460
462 The TCTI or "Transmission Interface" is the communication mechanism
463 with the TPM. TCTIs can be changed for communication with TPMs across
464 different mediums.
465
466 To control the TCTI, the tools respect:
467
468 1. The command line option -T or --tcti
469
470 2. The environment variable: TPM2TOOLS_TCTI.
471
472 Note: The command line option always overrides the environment vari‐
473 able.
474
475 The current known TCTIs are:
476
477 • tabrmd - The resource manager, called tabrmd
478 (https://github.com/tpm2-software/tpm2-abrmd). Note that tabrmd and
479 abrmd as a tcti name are synonymous.
480
481 • mssim - Typically used for communicating to the TPM software simula‐
482 tor.
483
484 • device - Used when talking directly to a TPM device file.
485
486 • none - Do not initalize a connection with the TPM. Some tools allow
487 for off-tpm options and thus support not using a TCTI. Tools that do
488 not support it will error when attempted to be used without a TCTI
489 connection. Does not support ANY options and MUST BE presented as
490 the exact text of "none".
491
492 The arguments to either the command line option or the environment
493 variable are in the form:
494
495 <tcti-name>:<tcti-option-config>
496
497 Specifying an empty string for either the <tcti-name> or <tcti-op‐
498 tion-config> results in the default being used for that portion respec‐
499 tively.
500
501 TCTI Defaults
502 When a TCTI is not specified, the default TCTI is searched for using
503 dlopen(3) semantics. The tools will search for tabrmd, device and
504 mssim TCTIs IN THAT ORDER and USE THE FIRST ONE FOUND. You can query
505 what TCTI will be chosen as the default by using the -v option to print
506 the version information. The "default-tcti" key-value pair will indi‐
507 cate which of the aforementioned TCTIs is the default.
508
509 Custom TCTIs
510 Any TCTI that implements the dynamic TCTI interface can be loaded. The
511 tools internally use dlopen(3), and the raw tcti-name value is used for
512 the lookup. Thus, this could be a path to the shared library, or a li‐
513 brary name as understood by dlopen(3) semantics.
514
516 This collection of options are used to configure the various known TCTI
517 modules available:
518
519 • device: For the device TCTI, the TPM character device file for use by
520 the device TCTI can be specified. The default is /dev/tpm0.
521
522 Example: -T device:/dev/tpm0 or export TPM2TOOLS_TCTI="de‐
523 vice:/dev/tpm0"
524
525 • mssim: For the mssim TCTI, the domain name or IP address and port
526 number used by the simulator can be specified. The default are
527 127.0.0.1 and 2321.
528
529 Example: -T mssim:host=localhost,port=2321 or export TPM2TOOLS_TC‐
530 TI="mssim:host=localhost,port=2321"
531
532 • abrmd: For the abrmd TCTI, the configuration string format is a se‐
533 ries of simple key value pairs separated by a ',' character. Each
534 key and value string are separated by a '=' character.
535
536 • TCTI abrmd supports two keys:
537
538 1. 'bus_name' : The name of the tabrmd service on the bus (a
539 string).
540
541 2. 'bus_type' : The type of the dbus instance (a string) limited to
542 'session' and 'system'.
543
544 Specify the tabrmd tcti name and a config string of bus_name=com.ex‐
545 ample.FooBar:
546
547 \--tcti=tabrmd:bus_name=com.example.FooBar
548
549 Specify the default (abrmd) tcti and a config string of bus_type=ses‐
550 sion:
551
552 \--tcti:bus_type=session
553
554 NOTE: abrmd and tabrmd are synonymous. the various known TCTI mod‐
555 ules.
556
558 Create an ECC primary object
559 tpm2_createprimary -C o -g sha256 -G ecc -c context.out
560
561 Create a primary object that follows the guidance of TCG
562 Provisioning guide
563
564 See : https://trustedcomputinggroup.org/wp-content/up‐
565 loads/TCG-TPM-v2.0-Provisioning-Guidance-Published-v1r1.pdf
566
567 Where unique.dat contains the binary-formatted data: 0x00 0x01 (0x00 *
568 256)
569
570 tpm2_createprimary -C o -G rsa2048:aes128cfb -g sha256 -c prim.ctx \
571 -a 'restricted|decrypt|fixedtpm|fixedparent|sensitivedataorigin|userwithauth|\
572 noda' -u unique.dat
573
575 Tools can return any of the following codes:
576
577 • 0 - Success.
578
579 • 1 - General non-specific error.
580
581 • 2 - Options handling error.
582
583 • 3 - Authentication error.
584
585 • 4 - TCTI related error.
586
587 • 5 - Non supported scheme. Applicable to tpm2_testparams.
588
590 Github Issues (https://github.com/tpm2-software/tpm2-tools/issues)
591
593 See the Mailing List (https://lists.01.org/mailman/listinfo/tpm2)
594
595
596
597tpm2-tools tpm2_createprimary(1)