forked from microsoft/TSS.MSR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tpm.ts
2517 lines (2268 loc) · 135 KB
/
Tpm.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright(c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
* See the LICENSE file in the project root for full license information.
*/
/*
* This file is automatically generated from the TPM 2.0 rev. 1.62 specification documents.
* Do not edit it directly.
*/
import * as tt from "./TpmTypes.js";
import { TpmBase, TpmError } from "./TpmBase.js";
import { TpmBuffer } from "./TpmMarshaller.js";
export class Tpm extends TpmBase
{
/** TPM2_Startup() is always preceded by _TPM_Init, which is the physical indication that
* TPM initialization is necessary because of a system-wide reset. TPM2_Startup() is only
* valid after _TPM_Init. Additional TPM2_Startup() commands are not allowed after it has
* completed successfully. If a TPM requires TPM2_Startup() and another command is
* received, or if the TPM receives TPM2_Startup() when it is not required, the TPM shall
* return TPM_RC_INITIALIZE.
* @param startupType TPM_SU_CLEAR or TPM_SU_STATE
*/
Startup(startupType: tt.TPM_SU,
continuation: (err: TpmError, res?: void) => void)
{
let req = new tt.TPM2_Startup_REQUEST(startupType);
this.dispatchCommand(tt.TPM_CC.Startup, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf);
setImmediate(continuation, this.lastError); });
} // Startup()
/** This command is used to prepare the TPM for a power cycle. The shutdownType parameter
* indicates how the subsequent TPM2_Startup() will be processed.
* @param shutdownType TPM_SU_CLEAR or TPM_SU_STATE
*/
Shutdown(shutdownType: tt.TPM_SU,
continuation: (err: TpmError, res?: void) => void)
{
let req = new tt.TPM2_Shutdown_REQUEST(shutdownType);
this.dispatchCommand(tt.TPM_CC.Shutdown, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf);
setImmediate(continuation, this.lastError); });
} // Shutdown()
/** This command causes the TPM to perform a test of its capabilities. If the fullTest is
* YES, the TPM will test all functions. If fullTest = NO, the TPM will only test those
* functions that have not previously been tested.
* @param fullTest YES if full test to be performed
* NO if only test of untested functions required
*/
SelfTest(fullTest: number,
continuation: (err: TpmError, res?: void) => void)
{
let req = new tt.TPM2_SelfTest_REQUEST(fullTest);
this.dispatchCommand(tt.TPM_CC.SelfTest, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf);
setImmediate(continuation, this.lastError); });
} // SelfTest()
/** This command causes the TPM to perform a test of the selected algorithms.
* @param toTest List of algorithms that should be tested
* @return toDoList - List of algorithms that need testing
*/
IncrementalSelfTest(toTest: tt.TPM_ALG_ID[],
continuation: (err: TpmError, res?: tt.TPM_ALG_ID[]) => void)
{
let req = new tt.TPM2_IncrementalSelfTest_REQUEST(toTest);
this.dispatchCommand(tt.TPM_CC.IncrementalSelfTest, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.IncrementalSelfTestResponse);
setImmediate(continuation, this.lastError, res?.toDoList); });
} // IncrementalSelfTest()
/** This command returns manufacturer-specific information regarding the results of a
* self-test and an indication of the test status.
* @return outData - Test result data
* contains manufacturer-specific information<br>
* testResult - TBD
*/
GetTestResult(continuation: (err: TpmError, res?: tt.GetTestResultResponse) => void)
{
let req = new tt.TPM2_GetTestResult_REQUEST();
this.dispatchCommand(tt.TPM_CC.GetTestResult, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.GetTestResultResponse);
setImmediate(continuation, this.lastError, res); });
} // GetTestResult()
/** This command is used to start an authorization session using alternative methods of
* establishing the session key (sessionKey). The session key is then used to derive
* values used for authorization and for encrypting parameters.
* @param tpmKey Handle of a loaded decrypt key used to encrypt salt
* may be TPM_RH_NULL
* Auth Index: None
* @param bind Entity providing the authValue
* may be TPM_RH_NULL
* Auth Index: None
* @param nonceCaller Initial nonceCaller, sets nonceTPM size for the session
* shall be at least 16 octets
* @param encryptedSalt Value encrypted according to the type of tpmKey
* If tpmKey is TPM_RH_NULL, this shall be the Empty Buffer.
* @param sessionType Indicates the type of the session; simple HMAC or policy (including
* a
* trial policy)
* @param symmetric The algorithm and key size for parameter encryption
* may select TPM_ALG_NULL
* @param authHash Hash algorithm to use for the session
* Shall be a hash algorithm supported by the TPM and not TPM_ALG_NULL
* @return handle - Handle for the newly created session<br>
* nonceTPM - The initial nonce from the TPM, used in the computation of the sessionKey
*/
StartAuthSession(tpmKey: tt.TPM_HANDLE, bind: tt.TPM_HANDLE, nonceCaller: Buffer, encryptedSalt: Buffer, sessionType: tt.TPM_SE, symmetric: tt.TPMT_SYM_DEF, authHash: tt.TPM_ALG_ID,
continuation: (err: TpmError, res?: tt.StartAuthSessionResponse) => void)
{
let req = new tt.TPM2_StartAuthSession_REQUEST(tpmKey, bind, nonceCaller, encryptedSalt, sessionType, symmetric, authHash);
this.dispatchCommand(tt.TPM_CC.StartAuthSession, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.StartAuthSessionResponse);
setImmediate(continuation, this.lastError, res); });
} // StartAuthSession()
/** This command allows a policy authorization session to be returned to its initial
* state. This command is used after the TPM returns TPM_RC_PCR_CHANGED. That response
* code indicates that a policy will fail because the PCR have changed after
* TPM2_PolicyPCR() was executed. Restarting the session allows the authorizations to be
* replayed because the session restarts with the same nonceTPM. If the PCR are valid for
* the policy, the policy may then succeed.
* @param sessionHandle The handle for the policy session
*/
PolicyRestart(sessionHandle: tt.TPM_HANDLE,
continuation: (err: TpmError, res?: void) => void)
{
let req = new tt.TPM2_PolicyRestart_REQUEST(sessionHandle);
this.dispatchCommand(tt.TPM_CC.PolicyRestart, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf);
setImmediate(continuation, this.lastError); });
} // PolicyRestart()
/** This command is used to create an object that can be loaded into a TPM using
* TPM2_Load(). If the command completes successfully, the TPM will create the new object
* and return the objects creation data (creationData), its public area (outPublic), and
* its encrypted sensitive area (outPrivate). Preservation of the returned data is the
* responsibility of the caller. The object will need to be loaded (TPM2_Load()) before
* it may be used. The only difference between the inPublic TPMT_PUBLIC template and the
* outPublic TPMT_PUBLIC object is in the unique field.
* @param parentHandle Handle of parent for new object
* Auth Index: 1
* Auth Role: USER
* @param inSensitive The sensitive data
* @param inPublic The public template
* @param outsideInfo Data that will be included in the creation data for this object to
* provide permanent, verifiable linkage between this object and some object owner
* data
* @param creationPCR PCR that will be used in creation data
* @return outPrivate - The private portion of the object<br>
* outPublic - The public portion of the created object<br>
* creationData - Contains a TPMS_CREATION_DATA<br>
* creationHash - Digest of creationData using nameAlg of outPublic<br>
* creationTicket - Ticket used by TPM2_CertifyCreation() to validate that the
* creation data was produced by the TPM
*/
Create(parentHandle: tt.TPM_HANDLE, inSensitive: tt.TPMS_SENSITIVE_CREATE, inPublic: tt.TPMT_PUBLIC, outsideInfo: Buffer, creationPCR: tt.TPMS_PCR_SELECTION[],
continuation: (err: TpmError, res?: tt.CreateResponse) => void)
{
let req = new tt.TPM2_Create_REQUEST(parentHandle, inSensitive, inPublic, outsideInfo, creationPCR);
this.dispatchCommand(tt.TPM_CC.Create, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.CreateResponse);
setImmediate(continuation, this.lastError, res); });
} // Create()
/** This command is used to load objects into the TPM. This command is used when both a
* TPM2B_PUBLIC and TPM2B_PRIVATE are to be loaded. If only a TPM2B_PUBLIC is to be
* loaded, the TPM2_LoadExternal command is used.
* @param parentHandle TPM handle of parent key; shall not be a reserved handle
* Auth Index: 1
* Auth Role: USER
* @param inPrivate The private portion of the object
* @param inPublic The public portion of the object
* @return handle - Handle of type TPM_HT_TRANSIENT for the loaded object
*/
Load(parentHandle: tt.TPM_HANDLE, inPrivate: tt.TPM2B_PRIVATE, inPublic: tt.TPMT_PUBLIC,
continuation: (err: TpmError, res?: tt.TPM_HANDLE) => void)
{
let req = new tt.TPM2_Load_REQUEST(parentHandle, inPrivate, inPublic);
this.dispatchCommand(tt.TPM_CC.Load, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.LoadResponse);
setImmediate(continuation, this.lastError, res?.handle); });
} // Load()
/** This command is used to load an object that is not a Protected Object into the TPM.
* The command allows loading of a public area or both a public and sensitive area.
* @param inPrivate The sensitive portion of the object (optional)
* @param inPublic The public portion of the object
* @param hierarchy Hierarchy with which the object area is associated
* @return handle - Handle of type TPM_HT_TRANSIENT for the loaded object
*/
LoadExternal(inPrivate: tt.TPMT_SENSITIVE, inPublic: tt.TPMT_PUBLIC, hierarchy: tt.TPM_HANDLE,
continuation: (err: TpmError, res?: tt.TPM_HANDLE) => void)
{
let req = new tt.TPM2_LoadExternal_REQUEST(inPrivate, inPublic, hierarchy);
this.dispatchCommand(tt.TPM_CC.LoadExternal, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.LoadExternalResponse);
setImmediate(continuation, this.lastError, res?.handle); });
} // LoadExternal()
/** This command allows access to the public area of a loaded object.
* @param objectHandle TPM handle of an object
* Auth Index: None
* @return outPublic - Structure containing the public area of an object<br>
* name - Name of the object<br>
* qualifiedName - The Qualified Name of the object
*/
ReadPublic(objectHandle: tt.TPM_HANDLE,
continuation: (err: TpmError, res?: tt.ReadPublicResponse) => void)
{
let req = new tt.TPM2_ReadPublic_REQUEST(objectHandle);
this.dispatchCommand(tt.TPM_CC.ReadPublic, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ReadPublicResponse);
setImmediate(continuation, this.lastError, res); });
} // ReadPublic()
/** This command enables the association of a credential with an object in a way that
* ensures that the TPM has validated the parameters of the credentialed object.
* @param activateHandle Handle of the object associated with certificate in credentialBlob
* Auth Index: 1
* Auth Role: ADMIN
* @param keyHandle Loaded key used to decrypt the TPMS_SENSITIVE in credentialBlob
* Auth Index: 2
* Auth Role: USER
* @param credentialBlob The credential
* @param secret KeyHandle algorithm-dependent encrypted seed that protects credentialBlob
* @return certInfo - The decrypted certificate information
* the data should be no larger than the size of the digest of the nameAlg
* associated with keyHandle
*/
ActivateCredential(activateHandle: tt.TPM_HANDLE, keyHandle: tt.TPM_HANDLE, credentialBlob: tt.TPMS_ID_OBJECT, secret: Buffer,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_ActivateCredential_REQUEST(activateHandle, keyHandle, credentialBlob, secret);
this.dispatchCommand(tt.TPM_CC.ActivateCredential, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ActivateCredentialResponse);
setImmediate(continuation, this.lastError, res?.certInfo); });
} // ActivateCredential()
/** This command allows the TPM to perform the actions required of a Certificate Authority
* (CA) in creating a TPM2B_ID_OBJECT containing an activation credential.
* @param handle Loaded public area, used to encrypt the sensitive area containing the
* credential key
* Auth Index: None
* @param credential The credential information
* @param objectName Name of the object to which the credential applies
* @return credentialBlob - The credential<br>
* secret - Handle algorithm-dependent data that wraps the key that encrypts credentialBlob
*/
MakeCredential(handle: tt.TPM_HANDLE, credential: Buffer, objectName: Buffer,
continuation: (err: TpmError, res?: tt.MakeCredentialResponse) => void)
{
let req = new tt.TPM2_MakeCredential_REQUEST(handle, credential, objectName);
this.dispatchCommand(tt.TPM_CC.MakeCredential, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.MakeCredentialResponse);
setImmediate(continuation, this.lastError, res); });
} // MakeCredential()
/** This command returns the data in a loaded Sealed Data Object.
* @param itemHandle Handle of a loaded data object
* Auth Index: 1
* Auth Role: USER
* @return outData - Unsealed data
* Size of outData is limited to be no more than 128 octets.
*/
Unseal(itemHandle: tt.TPM_HANDLE,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_Unseal_REQUEST(itemHandle);
this.dispatchCommand(tt.TPM_CC.Unseal, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.UnsealResponse);
setImmediate(continuation, this.lastError, res?.outData); });
} // Unseal()
/** This command is used to change the authorization secret for a TPM-resident object.
* @param objectHandle Handle of the object
* Auth Index: 1
* Auth Role: ADMIN
* @param parentHandle Handle of the parent
* Auth Index: None
* @param newAuth New authorization value
* @return outPrivate - Private area containing the new authorization value
*/
ObjectChangeAuth(objectHandle: tt.TPM_HANDLE, parentHandle: tt.TPM_HANDLE, newAuth: Buffer,
continuation: (err: TpmError, res?: tt.TPM2B_PRIVATE) => void)
{
let req = new tt.TPM2_ObjectChangeAuth_REQUEST(objectHandle, parentHandle, newAuth);
this.dispatchCommand(tt.TPM_CC.ObjectChangeAuth, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ObjectChangeAuthResponse);
setImmediate(continuation, this.lastError, res?.outPrivate); });
} // ObjectChangeAuth()
/** This command creates an object and loads it in the TPM. This command allows creation
* of any type of object (Primary, Ordinary, or Derived) depending on the type of
* parentHandle. If parentHandle references a Primary Seed, then a Primary Object is
* created; if parentHandle references a Storage Parent, then an Ordinary Object is
* created; and if parentHandle references a Derivation Parent, then a Derived Object is generated.
* @param parentHandle Handle of a transient storage key, a persistent storage key,
* TPM_RH_ENDORSEMENT, TPM_RH_OWNER, TPM_RH_PLATFORM+{PP}, or TPM_RH_NULL
* Auth Index: 1
* Auth Role: USER
* @param inSensitive The sensitive data, see TPM 2.0 Part 1 Sensitive Values
* @param inPublic The public template
* @return handle - Handle of type TPM_HT_TRANSIENT for created object<br>
* outPrivate - The sensitive area of the object (optional)<br>
* outPublic - The public portion of the created object<br>
* name - The name of the created object
*/
CreateLoaded(parentHandle: tt.TPM_HANDLE, inSensitive: tt.TPMS_SENSITIVE_CREATE, inPublic: Buffer,
continuation: (err: TpmError, res?: tt.CreateLoadedResponse) => void)
{
let req = new tt.TPM2_CreateLoaded_REQUEST(parentHandle, inSensitive, inPublic);
this.dispatchCommand(tt.TPM_CC.CreateLoaded, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.CreateLoadedResponse);
setImmediate(continuation, this.lastError, res); });
} // CreateLoaded()
/** This command duplicates a loaded object so that it may be used in a different
* hierarchy. The new parent key for the duplicate may be on the same or different TPM or
* TPM_RH_NULL. Only the public area of newParentHandle is required to be loaded.
* @param objectHandle Loaded object to duplicate
* Auth Index: 1
* Auth Role: DUP
* @param newParentHandle Shall reference the public area of an asymmetric key
* Auth Index: None
* @param encryptionKeyIn Optional symmetric encryption key
* The size for this key is set to zero when the TPM is to generate the key. This
* parameter may be encrypted.
* @param symmetricAlg Definition for the symmetric algorithm to be used for the inner wrapper
* may be TPM_ALG_NULL if no inner wrapper is applied
* @return encryptionKeyOut - If the caller provided an encryption key or if symmetricAlg
* was
* TPM_ALG_NULL, then this will be the Empty Buffer;
* otherwise, it
* shall contain the TPM-generated, symmetric encryption key for
* the inner wrapper.<br>
* duplicate - Private area that may be encrypted by encryptionKeyIn; and may be
* doubly encrypted<br>
* outSymSeed - Seed protected by the asymmetric algorithms of new parent (NP)
*/
Duplicate(objectHandle: tt.TPM_HANDLE, newParentHandle: tt.TPM_HANDLE, encryptionKeyIn: Buffer, symmetricAlg: tt.TPMT_SYM_DEF_OBJECT,
continuation: (err: TpmError, res?: tt.DuplicateResponse) => void)
{
let req = new tt.TPM2_Duplicate_REQUEST(objectHandle, newParentHandle, encryptionKeyIn, symmetricAlg);
this.dispatchCommand(tt.TPM_CC.Duplicate, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.DuplicateResponse);
setImmediate(continuation, this.lastError, res); });
} // Duplicate()
/** This command allows the TPM to serve in the role as a Duplication Authority. If proper
* authorization for use of the oldParent is provided, then an HMAC key and a symmetric
* key are recovered from inSymSeed and used to integrity check and decrypt inDuplicate.
* A new protection seed value is generated according to the methods appropriate for
* newParent and the blob is re-encrypted and a new integrity value is computed. The
* re-encrypted blob is returned in outDuplicate and the symmetric key returned in outSymKey.
* @param oldParent Parent of object
* Auth Index: 1
* Auth Role: User
* @param newParent New parent of the object
* Auth Index: None
* @param inDuplicate An object encrypted using symmetric key derived from inSymSeed
* @param name The Name of the object being rewrapped
* @param inSymSeed The seed for the symmetric key and HMAC key
* needs oldParent private key to recover the seed and generate the symmetric key
* @return outDuplicate - An object encrypted using symmetric key derived from outSymSeed<br>
* outSymSeed - Seed for a symmetric key protected by newParent asymmetric key
*/
Rewrap(oldParent: tt.TPM_HANDLE, newParent: tt.TPM_HANDLE, inDuplicate: tt.TPM2B_PRIVATE, name: Buffer, inSymSeed: Buffer,
continuation: (err: TpmError, res?: tt.RewrapResponse) => void)
{
let req = new tt.TPM2_Rewrap_REQUEST(oldParent, newParent, inDuplicate, name, inSymSeed);
this.dispatchCommand(tt.TPM_CC.Rewrap, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.RewrapResponse);
setImmediate(continuation, this.lastError, res); });
} // Rewrap()
/** This command allows an object to be encrypted using the symmetric encryption values of
* a Storage Key. After encryption, the object may be loaded and used in the new
* hierarchy. The imported object (duplicate) may be singly encrypted, multiply
* encrypted, or unencrypted.
* @param parentHandle The handle of the new parent for the object
* Auth Index: 1
* Auth Role: USER
* @param encryptionKey The optional symmetric encryption key used as the inner wrapper
* for duplicate
* If symmetricAlg is TPM_ALG_NULL, then this parameter shall be the Empty Buffer.
* @param objectPublic The public area of the object to be imported
* This is provided so that the integrity value for duplicate and the object
* attributes can be checked.
* NOTE Even if the integrity value of the object is not checked on input, the object
* Name is required to create the integrity value for the imported object.
* @param duplicate The symmetrically encrypted duplicate object that may contain an inner
* symmetric wrapper
* @param inSymSeed The seed for the symmetric key and HMAC key
* inSymSeed is encrypted/encoded using the algorithms of newParent.
* @param symmetricAlg Definition for the symmetric algorithm to use for the inner wrapper
* If this algorithm is TPM_ALG_NULL, no inner wrapper is present and encryptionKey
* shall be the Empty Buffer.
* @return outPrivate - The sensitive area encrypted with the symmetric key of parentHandle
*/
Import(parentHandle: tt.TPM_HANDLE, encryptionKey: Buffer, objectPublic: tt.TPMT_PUBLIC, duplicate: tt.TPM2B_PRIVATE, inSymSeed: Buffer, symmetricAlg: tt.TPMT_SYM_DEF_OBJECT,
continuation: (err: TpmError, res?: tt.TPM2B_PRIVATE) => void)
{
let req = new tt.TPM2_Import_REQUEST(parentHandle, encryptionKey, objectPublic, duplicate, inSymSeed, symmetricAlg);
this.dispatchCommand(tt.TPM_CC.Import, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ImportResponse);
setImmediate(continuation, this.lastError, res?.outPrivate); });
} // Import()
/** This command performs RSA encryption using the indicated padding scheme according to
* IETF RFC 8017. If the scheme of keyHandle is TPM_ALG_NULL, then the caller may use
* inScheme to specify the padding scheme. If scheme of keyHandle is not TPM_ALG_NULL,
* then inScheme shall either be TPM_ALG_NULL or be the same as scheme (TPM_RC_SCHEME).
* @param keyHandle Reference to public portion of RSA key to use for encryption
* Auth Index: None
* @param message Message to be encrypted
* NOTE 1 The data type was chosen because it limits the overall size of the input
* to
* no greater than the size of the largest RSA public key. This may be larger than
* allowed for keyHandle.
* @param inScheme The padding scheme to use if scheme associated with keyHandle is TPM_ALG_NULL
* One of: TPMS_KEY_SCHEME_ECDH, TPMS_KEY_SCHEME_ECMQV, TPMS_SIG_SCHEME_RSASSA,
* TPMS_SIG_SCHEME_RSAPSS, TPMS_SIG_SCHEME_ECDSA, TPMS_SIG_SCHEME_ECDAA,
* TPMS_SIG_SCHEME_SM2, TPMS_SIG_SCHEME_ECSCHNORR, TPMS_ENC_SCHEME_RSAES,
* TPMS_ENC_SCHEME_OAEP, TPMS_SCHEME_HASH, TPMS_NULL_ASYM_SCHEME.
* @param label Optional label L to be associated with the message
* Size of the buffer is zero if no label is present
* NOTE 2 See description of label above.
* @return outData - Encrypted output
*/
RSA_Encrypt(keyHandle: tt.TPM_HANDLE, message: Buffer, inScheme: tt.TPMU_ASYM_SCHEME, label: Buffer,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_RSA_Encrypt_REQUEST(keyHandle, message, inScheme, label);
this.dispatchCommand(tt.TPM_CC.RSA_Encrypt, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.RSA_EncryptResponse);
setImmediate(continuation, this.lastError, res?.outData); });
} // RSA_Encrypt()
/** This command performs RSA decryption using the indicated padding scheme according to
* IETF RFC 8017 ((PKCS#1).
* @param keyHandle RSA key to use for decryption
* Auth Index: 1
* Auth Role: USER
* @param cipherText Cipher text to be decrypted
* NOTE An encrypted RSA data block is the size of the public modulus.
* @param inScheme The padding scheme to use if scheme associated with keyHandle is TPM_ALG_NULL
* One of: TPMS_KEY_SCHEME_ECDH, TPMS_KEY_SCHEME_ECMQV, TPMS_SIG_SCHEME_RSASSA,
* TPMS_SIG_SCHEME_RSAPSS, TPMS_SIG_SCHEME_ECDSA, TPMS_SIG_SCHEME_ECDAA,
* TPMS_SIG_SCHEME_SM2, TPMS_SIG_SCHEME_ECSCHNORR, TPMS_ENC_SCHEME_RSAES,
* TPMS_ENC_SCHEME_OAEP, TPMS_SCHEME_HASH, TPMS_NULL_ASYM_SCHEME.
* @param label Label whose association with the message is to be verified
* @return message - Decrypted output
*/
RSA_Decrypt(keyHandle: tt.TPM_HANDLE, cipherText: Buffer, inScheme: tt.TPMU_ASYM_SCHEME, label: Buffer,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_RSA_Decrypt_REQUEST(keyHandle, cipherText, inScheme, label);
this.dispatchCommand(tt.TPM_CC.RSA_Decrypt, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.RSA_DecryptResponse);
setImmediate(continuation, this.lastError, res?.message); });
} // RSA_Decrypt()
/** This command uses the TPM to generate an ephemeral key pair (de, Qe where Qe [de]G).
* It uses the private ephemeral key and a loaded public key (QS) to compute the shared
* secret value (P [hde]QS).
* @param keyHandle Handle of a loaded ECC key public area.
* Auth Index: None
* @return zPoint - Results of P h[de]Qs<br>
* pubPoint - Generated ephemeral public point (Qe)
*/
ECDH_KeyGen(keyHandle: tt.TPM_HANDLE,
continuation: (err: TpmError, res?: tt.ECDH_KeyGenResponse) => void)
{
let req = new tt.TPM2_ECDH_KeyGen_REQUEST(keyHandle);
this.dispatchCommand(tt.TPM_CC.ECDH_KeyGen, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ECDH_KeyGenResponse);
setImmediate(continuation, this.lastError, res); });
} // ECDH_KeyGen()
/** This command uses the TPM to recover the Z value from a public point (QB) and a
* private key (ds). It will perform the multiplication of the provided inPoint (QB) with
* the private key (ds) and return the coordinates of the resultant point (Z = (xZ , yZ)
* [hds]QB; where h is the cofactor of the curve).
* @param keyHandle Handle of a loaded ECC key
* Auth Index: 1
* Auth Role: USER
* @param inPoint A public key
* @return outPoint - X and Y coordinates of the product of the multiplication Z = (xZ ,
* yZ) [hdS]QB
*/
ECDH_ZGen(keyHandle: tt.TPM_HANDLE, inPoint: tt.TPMS_ECC_POINT,
continuation: (err: TpmError, res?: tt.TPMS_ECC_POINT) => void)
{
let req = new tt.TPM2_ECDH_ZGen_REQUEST(keyHandle, inPoint);
this.dispatchCommand(tt.TPM_CC.ECDH_ZGen, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ECDH_ZGenResponse);
setImmediate(continuation, this.lastError, res?.outPoint); });
} // ECDH_ZGen()
/** This command returns the parameters of an ECC curve identified by its TCG-assigned curveID.
* @param curveID Parameter set selector
* @return parameters - ECC parameters for the selected curve
*/
ECC_Parameters(curveID: tt.TPM_ECC_CURVE,
continuation: (err: TpmError, res?: tt.TPMS_ALGORITHM_DETAIL_ECC) => void)
{
let req = new tt.TPM2_ECC_Parameters_REQUEST(curveID);
this.dispatchCommand(tt.TPM_CC.ECC_Parameters, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ECC_ParametersResponse);
setImmediate(continuation, this.lastError, res?.parameters); });
} // ECC_Parameters()
/** This command supports two-phase key exchange protocols. The command is used in
* combination with TPM2_EC_Ephemeral(). TPM2_EC_Ephemeral() generates an ephemeral key
* and returns the public point of that ephemeral key along with a numeric value that
* allows the TPM to regenerate the associated private key.
* @param keyA Handle of an unrestricted decryption key ECC
* The private key referenced by this handle is used as dS,A
* Auth Index: 1
* Auth Role: USER
* @param inQsB Other partys static public key (Qs,B = (Xs,B, Ys,B))
* @param inQeB Other party's ephemeral public key (Qe,B = (Xe,B, Ye,B))
* @param inScheme The key exchange scheme
* @param counter Value returned by TPM2_EC_Ephemeral()
* @return outZ1 - X and Y coordinates of the computed value (scheme dependent)<br>
* outZ2 - X and Y coordinates of the second computed value (scheme dependent)
*/
ZGen_2Phase(keyA: tt.TPM_HANDLE, inQsB: tt.TPMS_ECC_POINT, inQeB: tt.TPMS_ECC_POINT, inScheme: tt.TPM_ALG_ID, counter: number,
continuation: (err: TpmError, res?: tt.ZGen_2PhaseResponse) => void)
{
let req = new tt.TPM2_ZGen_2Phase_REQUEST(keyA, inQsB, inQeB, inScheme, counter);
this.dispatchCommand(tt.TPM_CC.ZGen_2Phase, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ZGen_2PhaseResponse);
setImmediate(continuation, this.lastError, res); });
} // ZGen_2Phase()
/** This command performs ECC encryption as described in Part 1, Annex D.
* @param keyHandle Reference to public portion of ECC key to use for encryption
* Auth Index: None
* @param plainText Plaintext to be encrypted
* @param inScheme The KDF to use if scheme associated with keyHandle is TPM_ALG_NULL
* One of: TPMS_KDF_SCHEME_MGF1, TPMS_KDF_SCHEME_KDF1_SP800_56A, TPMS_KDF_SCHEME_KDF2,
* TPMS_KDF_SCHEME_KDF1_SP800_108, TPMS_SCHEME_HASH, TPMS_NULL_KDF_SCHEME.
* @return C1 - The public ephemeral key used for ECDH<br>
* C2 - The data block produced by the XOR process<br>
* C3 - The integrity value
*/
ECC_Encrypt(keyHandle: tt.TPM_HANDLE, plainText: Buffer, inScheme: tt.TPMU_KDF_SCHEME,
continuation: (err: TpmError, res?: tt.ECC_EncryptResponse) => void)
{
let req = new tt.TPM2_ECC_Encrypt_REQUEST(keyHandle, plainText, inScheme);
this.dispatchCommand(tt.TPM_CC.ECC_Encrypt, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ECC_EncryptResponse);
setImmediate(continuation, this.lastError, res); });
} // ECC_Encrypt()
/** This command performs ECC decryption.
* @param keyHandle ECC key to use for decryption
* Auth Index: 1
* Auth Role: USER
* @param C1 The public ephemeral key used for ECDH
* @param C2 The data block produced by the XOR process
* @param C3 The integrity value
* @param inScheme The KDF to use if scheme associated with keyHandle is TPM_ALG_NULL
* One of: TPMS_KDF_SCHEME_MGF1, TPMS_KDF_SCHEME_KDF1_SP800_56A, TPMS_KDF_SCHEME_KDF2,
* TPMS_KDF_SCHEME_KDF1_SP800_108, TPMS_SCHEME_HASH, TPMS_NULL_KDF_SCHEME.
* @return plainText - Decrypted output
*/
ECC_Decrypt(keyHandle: tt.TPM_HANDLE, C1: tt.TPMS_ECC_POINT, C2: Buffer, C3: Buffer, inScheme: tt.TPMU_KDF_SCHEME,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_ECC_Decrypt_REQUEST(keyHandle, C1, C2, C3, inScheme);
this.dispatchCommand(tt.TPM_CC.ECC_Decrypt, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.ECC_DecryptResponse);
setImmediate(continuation, this.lastError, res?.plainText); });
} // ECC_Decrypt()
/** NOTE 1 This command is deprecated, and TPM2_EncryptDecrypt2() is preferred. This
* should be reflected in platform-specific specifications.
* @param keyHandle The symmetric key used for the operation
* Auth Index: 1
* Auth Role: USER
* @param decrypt If YES, then the operation is decryption; if NO, the operation is encryption
* @param mode Symmetric encryption/decryption mode
* this field shall match the default mode of the key or be TPM_ALG_NULL.
* @param ivIn An initial value as required by the algorithm
* @param inData The data to be encrypted/decrypted
* @return outData - Encrypted or decrypted output<br>
* ivOut - Chaining value to use for IV in next round
*/
EncryptDecrypt(keyHandle: tt.TPM_HANDLE, decrypt: number, mode: tt.TPM_ALG_ID, ivIn: Buffer, inData: Buffer,
continuation: (err: TpmError, res?: tt.EncryptDecryptResponse) => void)
{
let req = new tt.TPM2_EncryptDecrypt_REQUEST(keyHandle, decrypt, mode, ivIn, inData);
this.dispatchCommand(tt.TPM_CC.EncryptDecrypt, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.EncryptDecryptResponse);
setImmediate(continuation, this.lastError, res); });
} // EncryptDecrypt()
/** This command is identical to TPM2_EncryptDecrypt(), except that the inData parameter
* is the first parameter. This permits inData to be parameter encrypted.
* @param keyHandle The symmetric key used for the operation
* Auth Index: 1
* Auth Role: USER
* @param inData The data to be encrypted/decrypted
* @param decrypt If YES, then the operation is decryption; if NO, the operation is encryption
* @param mode Symmetric mode
* this field shall match the default mode of the key or be TPM_ALG_NULL.
* @param ivIn An initial value as required by the algorithm
* @return outData - Encrypted or decrypted output<br>
* ivOut - Chaining value to use for IV in next round
*/
EncryptDecrypt2(keyHandle: tt.TPM_HANDLE, inData: Buffer, decrypt: number, mode: tt.TPM_ALG_ID, ivIn: Buffer,
continuation: (err: TpmError, res?: tt.EncryptDecrypt2Response) => void)
{
let req = new tt.TPM2_EncryptDecrypt2_REQUEST(keyHandle, inData, decrypt, mode, ivIn);
this.dispatchCommand(tt.TPM_CC.EncryptDecrypt2, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.EncryptDecrypt2Response);
setImmediate(continuation, this.lastError, res); });
} // EncryptDecrypt2()
/** This command performs a hash operation on a data buffer and returns the results.
* @param data Data to be hashed
* @param hashAlg Algorithm for the hash being computed shall not be TPM_ALG_NULL
* @param hierarchy Hierarchy to use for the ticket (TPM_RH_NULL allowed)
* @return outHash - Results<br>
* validation - Ticket indicating that the sequence of octets used to compute
* outDigest did not start with TPM_GENERATED_VALUE
* will be a NULL ticket if the digest may not be signed with a
* restricted key
*/
Hash(data: Buffer, hashAlg: tt.TPM_ALG_ID, hierarchy: tt.TPM_HANDLE,
continuation: (err: TpmError, res?: tt.HashResponse) => void)
{
let req = new tt.TPM2_Hash_REQUEST(data, hashAlg, hierarchy);
this.dispatchCommand(tt.TPM_CC.Hash, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.HashResponse);
setImmediate(continuation, this.lastError, res); });
} // Hash()
/** This command performs an HMAC on the supplied data using the indicated hash algorithm.
* @param handle Handle for the symmetric signing key providing the HMAC key
* Auth Index: 1
* Auth Role: USER
* @param buffer HMAC data
* @param hashAlg Algorithm to use for HMAC
* @return outHMAC - The returned HMAC in a sized buffer
*/
HMAC(handle: tt.TPM_HANDLE, buffer: Buffer, hashAlg: tt.TPM_ALG_ID,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_HMAC_REQUEST(handle, buffer, hashAlg);
this.dispatchCommand(tt.TPM_CC.HMAC, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.HMACResponse);
setImmediate(continuation, this.lastError, res?.outHMAC); });
} // HMAC()
/** This command performs an HMAC or a block cipher MAC on the supplied data using the
* indicated algorithm.
* @param handle Handle for the symmetric signing key providing the MAC key
* Auth Index: 1
* Auth Role: USER
* @param buffer MAC data
* @param inScheme Algorithm to use for MAC
* @return outMAC - The returned MAC in a sized buffer
*/
MAC(handle: tt.TPM_HANDLE, buffer: Buffer, inScheme: tt.TPM_ALG_ID,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_MAC_REQUEST(handle, buffer, inScheme);
this.dispatchCommand(tt.TPM_CC.MAC, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.MACResponse);
setImmediate(continuation, this.lastError, res?.outMAC); });
} // MAC()
/** This command returns the next bytesRequested octets from the random number generator (RNG).
* @param bytesRequested Number of octets to return
* @return randomBytes - The random octets
*/
GetRandom(bytesRequested: number,
continuation: (err: TpmError, res?: Buffer) => void)
{
let req = new tt.TPM2_GetRandom_REQUEST(bytesRequested);
this.dispatchCommand(tt.TPM_CC.GetRandom, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.GetRandomResponse);
setImmediate(continuation, this.lastError, res?.randomBytes); });
} // GetRandom()
/** This command is used to add "additional information" to the RNG state.
* @param inData Additional information
*/
StirRandom(inData: Buffer,
continuation: (err: TpmError, res?: void) => void)
{
let req = new tt.TPM2_StirRandom_REQUEST(inData);
this.dispatchCommand(tt.TPM_CC.StirRandom, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf);
setImmediate(continuation, this.lastError); });
} // StirRandom()
/** This command starts an HMAC sequence. The TPM will create and initialize an HMAC
* sequence structure, assign a handle to the sequence, and set the authValue of the
* sequence object to the value in auth.
* @param handle Handle of an HMAC key
* Auth Index: 1
* Auth Role: USER
* @param auth Authorization value for subsequent use of the sequence
* @param hashAlg The hash algorithm to use for the HMAC
* @return handle - A handle to reference the sequence
*/
HMAC_Start(handle: tt.TPM_HANDLE, auth: Buffer, hashAlg: tt.TPM_ALG_ID,
continuation: (err: TpmError, res?: tt.TPM_HANDLE) => void)
{
let req = new tt.TPM2_HMAC_Start_REQUEST(handle, auth, hashAlg);
this.dispatchCommand(tt.TPM_CC.HMAC_Start, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.HMAC_StartResponse);
setImmediate(continuation, this.lastError, res?.handle); });
} // HMAC_Start()
/** This command starts a MAC sequence. The TPM will create and initialize a MAC sequence
* structure, assign a handle to the sequence, and set the authValue of the sequence
* object to the value in auth.
* @param handle Handle of a MAC key
* Auth Index: 1
* Auth Role: USER
* @param auth Authorization value for subsequent use of the sequence
* @param inScheme The algorithm to use for the MAC
* @return handle - A handle to reference the sequence
*/
MAC_Start(handle: tt.TPM_HANDLE, auth: Buffer, inScheme: tt.TPM_ALG_ID,
continuation: (err: TpmError, res?: tt.TPM_HANDLE) => void)
{
let req = new tt.TPM2_MAC_Start_REQUEST(handle, auth, inScheme);
this.dispatchCommand(tt.TPM_CC.MAC_Start, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.MAC_StartResponse);
setImmediate(continuation, this.lastError, res?.handle); });
} // MAC_Start()
/** This command starts a hash or an Event Sequence. If hashAlg is an implemented hash,
* then a hash sequence is started. If hashAlg is TPM_ALG_NULL, then an Event Sequence is
* started. If hashAlg is neither an implemented algorithm nor TPM_ALG_NULL, then the TPM
* shall return TPM_RC_HASH.
* @param auth Authorization value for subsequent use of the sequence
* @param hashAlg The hash algorithm to use for the hash sequence
* An Event Sequence starts if this is TPM_ALG_NULL.
* @return handle - A handle to reference the sequence
*/
HashSequenceStart(auth: Buffer, hashAlg: tt.TPM_ALG_ID,
continuation: (err: TpmError, res?: tt.TPM_HANDLE) => void)
{
let req = new tt.TPM2_HashSequenceStart_REQUEST(auth, hashAlg);
this.dispatchCommand(tt.TPM_CC.HashSequenceStart, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.HashSequenceStartResponse);
setImmediate(continuation, this.lastError, res?.handle); });
} // HashSequenceStart()
/** This command is used to add data to a hash or HMAC sequence. The amount of data in
* buffer may be any size up to the limits of the TPM.
* @param sequenceHandle Handle for the sequence object
* Auth Index: 1
* Auth Role: USER
* @param buffer Data to be added to hash
*/
SequenceUpdate(sequenceHandle: tt.TPM_HANDLE, buffer: Buffer,
continuation: (err: TpmError, res?: void) => void)
{
let req = new tt.TPM2_SequenceUpdate_REQUEST(sequenceHandle, buffer);
this.dispatchCommand(tt.TPM_CC.SequenceUpdate, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf);
setImmediate(continuation, this.lastError); });
} // SequenceUpdate()
/** This command adds the last part of data, if any, to a hash/HMAC sequence and returns
* the result.
* @param sequenceHandle Authorization for the sequence
* Auth Index: 1
* Auth Role: USER
* @param buffer Data to be added to the hash/HMAC
* @param hierarchy Hierarchy of the ticket for a hash
* @return result - The returned HMAC or digest in a sized buffer<br>
* validation - Ticket indicating that the sequence of octets used to compute
* outDigest did not start with TPM_GENERATED_VALUE
* This is a NULL Ticket when the sequence is HMAC.
*/
SequenceComplete(sequenceHandle: tt.TPM_HANDLE, buffer: Buffer, hierarchy: tt.TPM_HANDLE,
continuation: (err: TpmError, res?: tt.SequenceCompleteResponse) => void)
{
let req = new tt.TPM2_SequenceComplete_REQUEST(sequenceHandle, buffer, hierarchy);
this.dispatchCommand(tt.TPM_CC.SequenceComplete, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.SequenceCompleteResponse);
setImmediate(continuation, this.lastError, res); });
} // SequenceComplete()
/** This command adds the last part of data, if any, to an Event Sequence and returns the
* result in a digest list. If pcrHandle references a PCR and not TPM_RH_NULL, then the
* returned digest list is processed in the same manner as the digest list input
* parameter to TPM2_PCR_Extend(). That is, if a bank contains a PCR associated with
* pcrHandle, it is extended with the associated digest value from the list.
* @param pcrHandle PCR to be extended with the Event data
* Auth Index: 1
* Auth Role: USER
* @param sequenceHandle Authorization for the sequence
* Auth Index: 2
* Auth Role: USER
* @param buffer Data to be added to the Event
* @return results - List of digests computed for the PCR
*/
EventSequenceComplete(pcrHandle: tt.TPM_HANDLE, sequenceHandle: tt.TPM_HANDLE, buffer: Buffer,
continuation: (err: TpmError, res?: tt.TPMT_HA[]) => void)
{
let req = new tt.TPM2_EventSequenceComplete_REQUEST(pcrHandle, sequenceHandle, buffer);
this.dispatchCommand(tt.TPM_CC.EventSequenceComplete, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.EventSequenceCompleteResponse);
setImmediate(continuation, this.lastError, res?.results); });
} // EventSequenceComplete()
/** The purpose of this command is to prove that an object with a specific Name is loaded
* in the TPM. By certifying that the object is loaded, the TPM warrants that a public
* area with a given Name is self-consistent and associated with a valid sensitive area.
* If a relying party has a public area that has the same Name as a Name certified with
* this command, then the values in that public area are correct.
* @param objectHandle Handle of the object to be certified
* Auth Index: 1
* Auth Role: ADMIN
* @param signHandle Handle of the key used to sign the attestation structure
* Auth Index: 2
* Auth Role: USER
* @param qualifyingData User provided qualifying data
* @param inScheme Signing scheme to use if the scheme for signHandle is TPM_ALG_NULL
* One of: TPMS_SIG_SCHEME_RSASSA, TPMS_SIG_SCHEME_RSAPSS, TPMS_SIG_SCHEME_ECDSA,
* TPMS_SIG_SCHEME_ECDAA, TPMS_SIG_SCHEME_SM2, TPMS_SIG_SCHEME_ECSCHNORR,
* TPMS_SCHEME_HMAC, TPMS_SCHEME_HASH, TPMS_NULL_SIG_SCHEME.
* @return certifyInfo - The structure that was signed<br>
* signature - The asymmetric signature over certifyInfo using the key referenced
* by signHandle
*/
Certify(objectHandle: tt.TPM_HANDLE, signHandle: tt.TPM_HANDLE, qualifyingData: Buffer, inScheme: tt.TPMU_SIG_SCHEME,
continuation: (err: TpmError, res?: tt.CertifyResponse) => void)
{
let req = new tt.TPM2_Certify_REQUEST(objectHandle, signHandle, qualifyingData, inScheme);
this.dispatchCommand(tt.TPM_CC.Certify, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.CertifyResponse);
setImmediate(continuation, this.lastError, res); });
} // Certify()
/** This command is used to prove the association between an object and its creation data.
* The TPM will validate that the ticket was produced by the TPM and that the ticket
* validates the association between a loaded public area and the provided hash of the
* creation data (creationHash).
* @param signHandle Handle of the key that will sign the attestation block
* Auth Index: 1
* Auth Role: USER
* @param objectHandle The object associated with the creation data
* Auth Index: None
* @param qualifyingData User-provided qualifying data
* @param creationHash Hash of the creation data produced by TPM2_Create() or TPM2_CreatePrimary()
* @param inScheme Signing scheme to use if the scheme for signHandle is TPM_ALG_NULL
* One of: TPMS_SIG_SCHEME_RSASSA, TPMS_SIG_SCHEME_RSAPSS, TPMS_SIG_SCHEME_ECDSA,
* TPMS_SIG_SCHEME_ECDAA, TPMS_SIG_SCHEME_SM2, TPMS_SIG_SCHEME_ECSCHNORR,
* TPMS_SCHEME_HMAC, TPMS_SCHEME_HASH, TPMS_NULL_SIG_SCHEME.
* @param creationTicket Ticket produced by TPM2_Create() or TPM2_CreatePrimary()
* @return certifyInfo - The structure that was signed<br>
* signature - The signature over certifyInfo
*/
CertifyCreation(signHandle: tt.TPM_HANDLE, objectHandle: tt.TPM_HANDLE, qualifyingData: Buffer, creationHash: Buffer, inScheme: tt.TPMU_SIG_SCHEME, creationTicket: tt.TPMT_TK_CREATION,
continuation: (err: TpmError, res?: tt.CertifyCreationResponse) => void)
{
let req = new tt.TPM2_CertifyCreation_REQUEST(signHandle, objectHandle, qualifyingData, creationHash, inScheme, creationTicket);
this.dispatchCommand(tt.TPM_CC.CertifyCreation, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.CertifyCreationResponse);
setImmediate(continuation, this.lastError, res); });
} // CertifyCreation()
/** This command is used to quote PCR values.
* @param signHandle Handle of key that will perform signature
* Auth Index: 1
* Auth Role: USER
* @param qualifyingData Data supplied by the caller
* @param inScheme Signing scheme to use if the scheme for signHandle is TPM_ALG_NULL
* One of: TPMS_SIG_SCHEME_RSASSA, TPMS_SIG_SCHEME_RSAPSS, TPMS_SIG_SCHEME_ECDSA,
* TPMS_SIG_SCHEME_ECDAA, TPMS_SIG_SCHEME_SM2, TPMS_SIG_SCHEME_ECSCHNORR,
* TPMS_SCHEME_HMAC, TPMS_SCHEME_HASH, TPMS_NULL_SIG_SCHEME.
* @param PCRselect PCR set to quote
* @return quoted - The quoted information<br>
* signature - The signature over quoted
*/
Quote(signHandle: tt.TPM_HANDLE, qualifyingData: Buffer, inScheme: tt.TPMU_SIG_SCHEME, PCRselect: tt.TPMS_PCR_SELECTION[],
continuation: (err: TpmError, res?: tt.QuoteResponse) => void)
{
let req = new tt.TPM2_Quote_REQUEST(signHandle, qualifyingData, inScheme, PCRselect);
this.dispatchCommand(tt.TPM_CC.Quote, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.QuoteResponse);
setImmediate(continuation, this.lastError, res); });
} // Quote()
/** This command returns a digital signature of the audit session digest.
* @param privacyAdminHandle Handle of the privacy administrator (TPM_RH_ENDORSEMENT)
* Auth Index: 1
* Auth Role: USER
* @param signHandle Handle of the signing key
* Auth Index: 2
* Auth Role: USER
* @param sessionHandle Handle of the audit session
* Auth Index: None
* @param qualifyingData User-provided qualifying data may be zero-length
* @param inScheme Signing scheme to use if the scheme for signHandle is TPM_ALG_NULL
* One of: TPMS_SIG_SCHEME_RSASSA, TPMS_SIG_SCHEME_RSAPSS, TPMS_SIG_SCHEME_ECDSA,
* TPMS_SIG_SCHEME_ECDAA, TPMS_SIG_SCHEME_SM2, TPMS_SIG_SCHEME_ECSCHNORR,
* TPMS_SCHEME_HMAC, TPMS_SCHEME_HASH, TPMS_NULL_SIG_SCHEME.
* @return auditInfo - The audit information that was signed<br>
* signature - The signature over auditInfo
*/
GetSessionAuditDigest(privacyAdminHandle: tt.TPM_HANDLE, signHandle: tt.TPM_HANDLE, sessionHandle: tt.TPM_HANDLE, qualifyingData: Buffer, inScheme: tt.TPMU_SIG_SCHEME,
continuation: (err: TpmError, res?: tt.GetSessionAuditDigestResponse) => void)
{
let req = new tt.TPM2_GetSessionAuditDigest_REQUEST(privacyAdminHandle, signHandle, sessionHandle, qualifyingData, inScheme);
this.dispatchCommand(tt.TPM_CC.GetSessionAuditDigest, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.GetSessionAuditDigestResponse);
setImmediate(continuation, this.lastError, res); });
} // GetSessionAuditDigest()
/** This command returns the current value of the command audit digest, a digest of the
* commands being audited, and the audit hash algorithm. These values are placed in an
* attestation structure and signed with the key referenced by signHandle.
* @param privacyHandle Handle of the privacy administrator (TPM_RH_ENDORSEMENT)
* Auth Index: 1
* Auth Role: USER
* @param signHandle The handle of the signing key
* Auth Index: 2
* Auth Role: USER
* @param qualifyingData Other data to associate with this audit digest
* @param inScheme Signing scheme to use if the scheme for signHandle is TPM_ALG_NULL
* One of: TPMS_SIG_SCHEME_RSASSA, TPMS_SIG_SCHEME_RSAPSS, TPMS_SIG_SCHEME_ECDSA,
* TPMS_SIG_SCHEME_ECDAA, TPMS_SIG_SCHEME_SM2, TPMS_SIG_SCHEME_ECSCHNORR,
* TPMS_SCHEME_HMAC, TPMS_SCHEME_HASH, TPMS_NULL_SIG_SCHEME.
* @return auditInfo - The auditInfo that was signed<br>
* signature - The signature over auditInfo
*/
GetCommandAuditDigest(privacyHandle: tt.TPM_HANDLE, signHandle: tt.TPM_HANDLE, qualifyingData: Buffer, inScheme: tt.TPMU_SIG_SCHEME,
continuation: (err: TpmError, res?: tt.GetCommandAuditDigestResponse) => void)
{
let req = new tt.TPM2_GetCommandAuditDigest_REQUEST(privacyHandle, signHandle, qualifyingData, inScheme);
this.dispatchCommand(tt.TPM_CC.GetCommandAuditDigest, req, (respBuf: TpmBuffer): void => {
let res = this.processResponse(respBuf, tt.GetCommandAuditDigestResponse);
setImmediate(continuation, this.lastError, res); });
} // GetCommandAuditDigest()