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