]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Include/Library/TcgStorageCoreLib.h
SecurityPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / SecurityPkg / Include / Library / TcgStorageCoreLib.h
CommitLineData
085dcf01
ED
1/** @file\r
2 Public API for the Tcg Core library to perform the lowest level TCG Data encoding.\r
b3548d32 3\r
4b806739 4 (TCG Storage Architecture Core Specification, Version 2.01, Revision 1.00,\r
4b8552d7 5 https://trustedcomputinggroup.org/tcg-storage-architecture-core-specification/)\r
085dcf01 6\r
4b806739
ED
7 Check http://trustedcomputinggroup.org for latest specification updates.\r
8\r
9Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
289b714b 10SPDX-License-Identifier: BSD-2-Clause-Patent\r
085dcf01
ED
11\r
12**/\r
13\r
14#ifndef _TCG_CORE_H_\r
15#define _TCG_CORE_H_\r
16\r
17#include <IndustryStandard/TcgStorageCore.h>\r
18\r
19#define ERROR_CHECK(arg) \\r
20 { \\r
21 TCG_RESULT ret = (arg); \\r
22 if (ret != TcgResultSuccess) { \\r
0ca81c0d 23 DEBUG ((DEBUG_INFO, "ERROR_CHECK failed at %a:%u\n", __FILE__, __LINE__)); \\r
085dcf01
ED
24 return ret; \\r
25 } \\r
26 }\r
27\r
28#define METHOD_STATUS_ERROR_CHECK(arg, failRet) \\r
29 if ((arg) != TCG_METHOD_STATUS_CODE_SUCCESS) { \\r
0ca81c0d 30 DEBUG ((DEBUG_INFO, "Method Status error: 0x%02X (%a)\n", arg, TcgMethodStatusString(arg))); \\r
085dcf01
ED
31 return (failRet); \\r
32 }\r
33\r
34#define NULL_CHECK(arg) \\r
35 do { \\r
36 if ((arg) == NULL) { \\r
0ca81c0d 37 DEBUG ((DEBUG_INFO, "NULL_CHECK(%a) failed at %a:%u\n", #arg, __FILE__, __LINE__)); \\r
085dcf01
ED
38 return TcgResultFailureNullPointer; \\r
39 } \\r
40 } while (0)\r
41\r
42#pragma pack(1)\r
43\r
44/**\r
45Tcg result codes.\r
46\r
47The result code indicates if the Tcg function call was successful or not\r
48**/\r
49typedef enum {\r
50 //\r
51 // This is the return result upon successful completion of a Tcg function call\r
52 //\r
53 TcgResultSuccess,\r
54\r
55 //\r
56 // This is the return "catchall" result for the failure of a Tcg function call\r
57 //\r
58 TcgResultFailure,\r
59\r
60 //\r
61 // This is the return result if a required parameter was Null for a Tcg function call\r
62 //\r
63 TcgResultFailureNullPointer,\r
64\r
65 //\r
66 // This is the return result if a required buffersize was 0 for a Tcg function call\r
67 //\r
68 TcgResultFailureZeroSize,\r
69\r
70 //\r
71 // This is the return result if a Tcg function call was executed out of order.\r
72 // For instance, starting a Tcg subpacket before starting its Tcg packet.\r
73 //\r
74 TcgResultFailureInvalidAction,\r
75\r
76 //\r
77 // This is the return result if the buffersize provided is not big enough to add a requested Tcg encoded item.\r
78 //\r
79 TcgResultFailureBufferTooSmall,\r
80\r
81 //\r
82 // This is the return result for a Tcg parse function if the end of the parsed Buffer is reached, yet Data is still attempted to be retrieved.\r
83 // For instance, attempting to retrieve another Tcg token from the Buffer after it has reached the end of the Tcg subpacket payload.\r
84 //\r
85 TcgResultFailureEndBuffer,\r
86\r
87 //\r
88 // This is the return result for a Tcg parse function if the Tcg Token item requested is not the expected type.\r
89 // For instance, the caller requested to receive an integer and the Tcg token was a byte sequence.\r
90 //\r
91 TcgResultFailureInvalidType,\r
92} TCG_RESULT;\r
93\r
94//\r
95// Structure that is used to build the Tcg ComPacket. It contains the start Buffer pointer and the current position of the\r
96// Tcg ComPacket, current Tcg Packet and Tcg SubPacket. This structure must be initialized\r
97// by calling tcgInitTcgCreateStruct before it is used as parameter to any other Tcg function.\r
98// This structure should NOT be directly modified by the client of this library.\r
99//\r
100// NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES\r
101// INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY\r
102//\r
103// tcgInitTcgCreateStruct\r
104//\r
105typedef struct {\r
106 //\r
107 // Buffer allocated and freed by the client of the Tcg library.\r
108 // This is the Buffer that shall contain the final Tcg encoded compacket.\r
109 //\r
110 VOID *Buffer;\r
111\r
112 //\r
113 // Size of the Buffer provided.\r
114 //\r
115 UINT32 BufferSize;\r
116\r
117 //\r
118 //Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.\r
119 //\r
120 TCG_COM_PACKET *ComPacket;\r
121\r
122 //\r
123 // Current Tcg Packet that is being created. It should point to a location within Buffer.\r
124 //\r
125 TCG_PACKET *CurPacket;\r
126\r
127 //\r
128 // Current Tcg SubPacket that is being created. It should point to a location within Buffer.\r
129 //\r
130 TCG_SUB_PACKET *CurSubPacket;\r
131\r
132 //\r
133 // Flag used to indicate if the Buffer of the structure should be filled out.\r
134 // This is intended to be used to support a use-case where the client of library\r
135 // can perform all the desired tcg calls to determine what the actual Size of the final compacket will be.\r
136 // Then the client can allocate the required Buffer Size and re-run the tcg calls.\r
137 // THIS MAY NOT BE IMPLEMENTED... REQUIRES MORE THOUGHT BECAUSE YOU CANNOT SOLVE ISSUE FOR RECEIVE\r
138 //\r
139 BOOLEAN DryRun;\r
140} TCG_CREATE_STRUCT;\r
141\r
142//\r
143// Structure that is used to parse the Tcg response received. It contains the response Buffer pointer\r
144// and the current position of the Tcg ComPacket, current Tcg Packet and Tcg SubPacket being parsed.\r
145// This structure must be initialized by calling tcgInitTcgParseStruct before it is used as parameter to any other Tcg parse function.\r
146// This structure should NOT be directly modified by the client of this library.\r
147//\r
148// NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES\r
149// INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY\r
150//\r
151// @sa tcgInitTcgParseStruct\r
152//\r
153typedef struct {\r
154 //\r
155 // Buffer allocated and freed by the client of the Tcg library.\r
156 // This is the Buffer that contains the Tcg response to decode/parse.\r
157 //\r
158 const VOID* Buffer;\r
159\r
160 //\r
161 //Size of the Buffer provided.\r
162 //\r
163 UINT32 BufferSize;\r
164\r
165 //\r
166 // Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.\r
167 //\r
168 TCG_COM_PACKET *ComPacket;\r
169\r
170 //\r
171 // Current Tcg Packet that is being created. It should point to a location within Buffer.\r
172 //\r
173 TCG_PACKET *CurPacket;\r
174\r
175 //\r
176 // Current Tcg SubPacket that is being created. It should point to a location within Buffer.\r
177 //\r
178 TCG_SUB_PACKET *CurSubPacket;\r
179\r
180 //\r
181 // Current pointer within the current subpacket payload.\r
182 //\r
183 UINT8 *CurPtr;\r
184} TCG_PARSE_STRUCT ;\r
185\r
186\r
187//\r
188// Structure that is used to represent a Tcg Token that is retrieved by Tcg parse functions.\r
189//\r
190typedef struct {\r
191 //\r
192 // Describes the type of Tcg token the Hdr start points to.\r
193 //\r
194 TCG_TOKEN_TYPE Type;\r
195\r
196 //\r
197 // Pointer to the beginning of the Header of the Tcg token\r
198 //\r
199 UINT8 *HdrStart;\r
200} TCG_TOKEN ;\r
201\r
202/**\r
203\r
204 Required to be called before calling any other Tcg functions with the TCG_CREATE_STRUCT.\r
205 Initializes the packet variables to NULL. Additionally, the buffer will be memset.\r
206\r
207 @param[in/out] CreateStruct Structure to initialize\r
208 @param[in] Buffer Buffer allocated by client of library. It will contain the Tcg encoded packet. This cannot be null.\r
209 @param[in] BufferSize Size of buffer provided. It cannot be 0.\r
210\r
211**/\r
212TCG_RESULT\r
213EFIAPI\r
214TcgInitTcgCreateStruct(\r
215 TCG_CREATE_STRUCT *CreateStruct,\r
216 VOID *Buffer,\r
217 UINT32 BufferSize\r
218 );\r
219\r
220\r
221/**\r
222\r
223 Encodes the ComPacket header to the data structure.\r
224\r
225 @param[in/out] CreateStruct Structure to initialize\r
226 @param[in] ComId ComID of the Tcg ComPacket.\r
227 @param[in] ComIdExtension ComID Extension of the Tcg ComPacket.\r
228\r
229**/\r
230TCG_RESULT\r
231EFIAPI\r
232TcgStartComPacket(\r
233 TCG_CREATE_STRUCT *CreateStruct,\r
234 UINT16 ComId,\r
235 UINT16 ComIdExtension\r
236 );\r
237\r
238\r
239/**\r
240\r
241 Starts a new ComPacket in the Data structure.\r
242\r
243 @param[in/out] CreateStruct Structure used to add Tcg Packet\r
244 @param[in] Tsn Packet Tper session number\r
245 @param[in] Hsn Packet Host session number\r
246 @param[in] SeqNumber Packet Sequence Number\r
247 @param[in] AckType Packet Acknowledge Type\r
248 @param[in] Ack Packet Acknowledge\r
249\r
250**/\r
251TCG_RESULT\r
252EFIAPI\r
253TcgStartPacket(\r
254 TCG_CREATE_STRUCT *CreateStruct,\r
255 UINT32 Tsn,\r
256 UINT32 Hsn,\r
257 UINT32 SeqNumber,\r
258 UINT16 AckType,\r
259 UINT32 Ack\r
260 );\r
261\r
262/**\r
263\r
264 Starts a new SubPacket in the Data structure.\r
265\r
266 @param[in/out] CreateStruct Structure used to start Tcg SubPacket\r
267 @param[in] Kind SubPacket kind\r
268\r
269**/\r
270TCG_RESULT\r
271EFIAPI\r
272TcgStartSubPacket(\r
273 TCG_CREATE_STRUCT *CreateStruct,\r
274 UINT16 Kind\r
275 );\r
276\r
277\r
278/**\r
279\r
280 Ends the current SubPacket in the Data structure. This function will also perform the 4-byte padding\r
281 required for Subpackets.\r
282\r
283 @param[in/out] CreateStruct Structure used to end the current Tcg SubPacket\r
284\r
285**/\r
286TCG_RESULT\r
287EFIAPI\r
288TcgEndSubPacket(\r
289 TCG_CREATE_STRUCT *CreateStruct\r
290 );\r
291\r
292\r
293/**\r
294\r
295 Ends the current Packet in the Data structure.\r
296\r
297 @param[in/out] CreateStruct Structure used to end the current Tcg Packet\r
298\r
299**/\r
300TCG_RESULT\r
301EFIAPI\r
302TcgEndPacket(\r
303 TCG_CREATE_STRUCT *CreateStruct\r
304 );\r
305\r
306\r
307/**\r
308\r
309 Ends the ComPacket in the Data structure and ret\r
310\r
311 @param[in/out] CreateStruct Structure used to end the Tcg ComPacket\r
312 @param[in/out] Size Describes the Size of the entire ComPacket (Header and payload). Filled out by function.\r
313\r
314**/\r
315TCG_RESULT\r
316EFIAPI\r
317TcgEndComPacket(\r
318 TCG_CREATE_STRUCT *CreateStruct,\r
319 UINT32 *Size\r
320 );\r
321\r
322/**\r
323 Adds a single raw token byte to the Data structure.\r
324\r
325 @param[in/out] CreateStruct Structure used to add the byte\r
326 @param [in] Byte Byte to add\r
327\r
328**/\r
329TCG_RESULT\r
330EFIAPI\r
331TcgAddRawByte(\r
332 TCG_CREATE_STRUCT *CreateStruct,\r
333 UINT8 Byte\r
334 );\r
335\r
336\r
337/**\r
338\r
339 Adds the Data parameter as a byte sequence to the Data structure.\r
340\r
341 @param [in/out] CreateStruct Structure used to add the byte sequence\r
342 @param[in] Data Byte sequence that will be encoded and copied into Data structure\r
343 @param[in] DataSize Length of Data provided\r
344 @param[in] Continued TRUE if byte sequence is continued or\r
345 FALSE if the Data contains the entire byte sequence to be encoded\r
346\r
347**/\r
348TCG_RESULT\r
349EFIAPI\r
350TcgAddByteSequence(\r
351 TCG_CREATE_STRUCT *CreateStruct,\r
352 const VOID *Data,\r
353 UINT32 DataSize,\r
354 BOOLEAN Continued\r
355 );\r
356\r
357\r
358/**\r
359\r
360 Adds an arbitrary-Length integer to the Data structure.\r
361\r
362 The integer will be encoded using the shortest possible atom.\r
363\r
364 @param[in/out] CreateStruct Structure used to add the integer\r
365 @param[in] Data Integer in host byte order that will be encoded and copied into Data structure\r
366 @param[in] DataSize Length in bytes of the Data provided\r
367 @param[in] SignedInteger TRUE if the integer is signed or FALSE if the integer is unsigned\r
368\r
369**/\r
370TCG_RESULT\r
371EFIAPI\r
372TcgAddInteger(\r
373 TCG_CREATE_STRUCT *CreateStruct,\r
374 const VOID *Data,\r
375 UINT32 DataSize,\r
376 BOOLEAN SignedInteger\r
377 );\r
378\r
379\r
380/**\r
381 Adds an 8-bit unsigned integer to the Data structure.\r
382\r
383 @param[in/out] CreateStruct Structure used to add the integer\r
384 @param[in] Value Integer Value to add\r
385\r
386**/\r
387TCG_RESULT\r
388EFIAPI\r
389TcgAddUINT8(\r
390 TCG_CREATE_STRUCT *CreateStruct,\r
391 UINT8 Value\r
392 );\r
393\r
394/**\r
395\r
396 Adds a 16-bit unsigned integer to the Data structure.\r
397\r
398 @param[in/out] CreateStruct Structure used to add the integer\r
399 @param[in] Value Integer Value to add\r
400\r
401**/\r
402TCG_RESULT\r
403EFIAPI\r
404TcgAddUINT16 (\r
405 TCG_CREATE_STRUCT *CreateStruct,\r
406 UINT16 Value\r
407 );\r
408\r
409/**\r
410\r
411 Adds a 32-bit unsigned integer to the Data structure.\r
412\r
413 @param[in/out] CreateStruct Structure used to add the integer\r
414 @param[in] Value Integer Value to add\r
415\r
416**/\r
417TCG_RESULT\r
418EFIAPI\r
419TcgAddUINT32(\r
420 TCG_CREATE_STRUCT *CreateStruct,\r
421 UINT32 Value\r
422 );\r
423\r
424\r
425/**\r
426\r
427 Adds a 64-bit unsigned integer to the Data structure.\r
428\r
429 @param[in/out] CreateStruct Structure used to add the integer\r
430 @param[in] Value Integer Value to add\r
431\r
432**/\r
433TCG_RESULT\r
434EFIAPI\r
435TcgAddUINT64(\r
436 TCG_CREATE_STRUCT *CreateStruct,\r
437 UINT64 Value\r
438 );\r
439\r
440/**\r
441 Adds a BOOLEAN to the Data structure.\r
442\r
443 @param[in/out] CreateStruct Structure used to add the integer\r
444 @param[in] Value BOOLEAN Value to add\r
445\r
446**/\r
447TCG_RESULT\r
448EFIAPI\r
449TcgAddBOOLEAN(\r
450 TCG_CREATE_STRUCT *CreateStruct,\r
451 BOOLEAN Value\r
452 );\r
453\r
454/**\r
455 Add tcg uid info.\r
456\r
457 @param [in/out] CreateStruct Structure used to add the integer\r
458 @param Uid Input uid info.\r
459\r
460 @retval return the action result.\r
461\r
462**/\r
463TCG_RESULT\r
464EFIAPI\r
465TcgAddTcgUid(\r
466 TCG_CREATE_STRUCT *CreateStruct,\r
467 TCG_UID Uid\r
468 );\r
469\r
470/**\r
471 Adds a Start List token to the Data structure.\r
472\r
473 @param[in/out] CreateStruct Structure used to add the token\r
474\r
475**/\r
476TCG_RESULT\r
477EFIAPI\r
478TcgAddStartList(\r
479 TCG_CREATE_STRUCT *CreateStruct\r
480 );\r
481\r
482\r
483/**\r
484\r
485 Adds an End List token to the Data structure.\r
486\r
487 @param [in/out] CreateStruct Structure used to add the token\r
488\r
489**/\r
490TCG_RESULT\r
491EFIAPI\r
492TcgAddEndList(\r
493 TCG_CREATE_STRUCT *CreateStruct\r
494 );\r
495\r
496\r
497/**\r
498 Adds a Start Name token to the Data structure.\r
499\r
500 @param[in/out] CreateStruct Structure used to add the token\r
501\r
502**/\r
503TCG_RESULT\r
504EFIAPI\r
505TcgAddStartName(\r
506 TCG_CREATE_STRUCT *CreateStruct\r
507 );\r
508\r
509\r
510/**\r
511\r
512 Adds an End Name token to the Data structure.\r
513\r
514 @param [in/out] CreateStruct Structure used to add the token\r
515\r
516**/\r
517TCG_RESULT\r
518EFIAPI\r
519TcgAddEndName(\r
520 TCG_CREATE_STRUCT *CreateStruct\r
521 );\r
522\r
523\r
524/**\r
525 Adds a Call token to the Data structure.\r
526\r
527 @param [in/out] CreateStruct Structure used to add the token\r
528\r
529**/\r
530TCG_RESULT\r
531EFIAPI\r
532TcgAddCall(\r
533 TCG_CREATE_STRUCT *CreateStruct\r
534 );\r
535\r
536\r
537/**\r
538\r
539Adds an End of Data token to the Data structure.\r
540\r
541@param[in/out] CreateStruct Structure used to add the token\r
542\r
543**/\r
544TCG_RESULT\r
545EFIAPI\r
546TcgAddEndOfData(\r
547 TCG_CREATE_STRUCT *CreateStruct\r
548 );\r
549\r
550\r
551/**\r
552\r
553Adds an End of Session token to the Data structure.\r
554\r
555@param [in/out] CreateStruct Structure used to add the token\r
556\r
557**/\r
558TCG_RESULT\r
559EFIAPI\r
560TcgAddEndOfSession(\r
561 TCG_CREATE_STRUCT *CreateStruct\r
562 );\r
563\r
564\r
565/**\r
566 Adds a Start Transaction token to the Data structure.\r
567\r
568 @param [in/out] CreateStruct Structure used to add the token\r
569\r
570**/\r
571TCG_RESULT\r
572EFIAPI\r
573TcgAddStartTransaction(\r
574 TCG_CREATE_STRUCT *CreateStruct\r
575 );\r
576\r
577\r
578/**\r
579 Adds an End Transaction token to the Data structure.\r
580\r
581 @param[in/out] CreateStruct Structure used to add the token\r
582\r
583**/\r
584TCG_RESULT\r
585EFIAPI\r
586TcgAddEndTransaction(\r
587 TCG_CREATE_STRUCT *CreateStruct\r
588 );\r
589\r
590/**\r
591 Initial the tcg parse stucture.\r
592\r
593 @param ParseStruct Input parse structure.\r
594 @param Buffer Input buffer data.\r
595 @param BufferSize Input buffer size.\r
596\r
597 @retval return the action result.\r
598\r
599**/\r
600TCG_RESULT\r
601EFIAPI\r
602TcgInitTcgParseStruct(\r
603 TCG_PARSE_STRUCT *ParseStruct,\r
604 const VOID *Buffer,\r
605 UINT32 BufferSize\r
606 );\r
607\r
608/**\r
609 Get next token info.\r
610\r
611 @param ParseStruct Input parse structure info.\r
612 @param TcgToken return the tcg token info.\r
613\r
614 @retval return the action result.\r
615\r
616**/\r
617TCG_RESULT\r
618EFIAPI\r
619TcgGetNextToken(\r
620 TCG_PARSE_STRUCT *ParseStruct,\r
621 TCG_TOKEN *TcgToken\r
622 );\r
623\r
624/**\r
625 Get next token Type.\r
626\r
627 @param ParseStruct Input parse structure.\r
628 @param Type Input the type need to check.\r
629\r
630 @retval return the action result.\r
631\r
632**/\r
633TCG_RESULT\r
634EFIAPI\r
635TcgGetNextTokenType(\r
636 TCG_PARSE_STRUCT *ParseStruct,\r
637 TCG_TOKEN_TYPE Type\r
638 );\r
639\r
640/**\r
641 Get atom info.\r
642\r
643 @param TcgToken Input token info.\r
644 @param HeaderLength return the header length.\r
645 @param DataLength return the data length.\r
646 @param ByteOrInt return the atom Type.\r
647 @param SignOrCont return the sign or count info.\r
648\r
649 @retval return the action result.\r
650\r
651**/\r
652TCG_RESULT\r
653EFIAPI\r
654TcgGetAtomInfo(\r
655 const TCG_TOKEN *TcgToken,\r
656 UINT32 *HeaderLength,\r
657 UINT32 *DataLength,\r
658 UINT8 *ByteOrInt,\r
659 UINT8 *SignOrCont\r
660 );\r
661\r
662/**\r
663 Get token byte sequence.\r
664\r
665 @param TcgToken Input token info.\r
666 @param Length Input the length info.\r
667\r
668 @retval Return the value data.\r
669\r
670**/\r
671UINT8*\r
672EFIAPI\r
673TcgGetTokenByteSequence(\r
674 const TCG_TOKEN *TcgToken,\r
675 UINT32 *Length\r
676 );\r
677\r
678/**\r
679 Get token specified value.\r
680\r
681 @param TcgToken Input token info.\r
682 @param Value return the value.\r
683\r
684 @retval return the action result.\r
685\r
686**/\r
687TCG_RESULT\r
688EFIAPI\r
689TcgGetTokenUINT64(\r
690 const TCG_TOKEN *TcgToken,\r
691 UINT64 *Value\r
692 );\r
693\r
694\r
695/**\r
696 Get next specify value.\r
697\r
698 @param ParseStruct Input parse structure.\r
699 @param Value Return vlaue.\r
700\r
701 @retval return the action result.\r
702\r
703**/\r
704TCG_RESULT\r
705EFIAPI\r
706TcgGetNextUINT8(\r
707 TCG_PARSE_STRUCT *ParseStruct,\r
708 UINT8 *Value\r
709 );\r
710\r
711\r
712/**\r
713 Get next specify value.\r
714\r
715 @param ParseStruct Input parse structure.\r
716 @param Value Return vlaue.\r
717\r
718 @retval return the action result.\r
719\r
720**/\r
721TCG_RESULT\r
722EFIAPI\r
723TcgGetNextUINT16(\r
724 TCG_PARSE_STRUCT *ParseStruct,\r
725 UINT16 *Value\r
726 );\r
727\r
728/**\r
729 Get next specify value.\r
730\r
731 @param ParseStruct Input parse structure.\r
732 @param Value Return vlaue.\r
733\r
734 @retval return the action result.\r
735\r
736**/\r
737TCG_RESULT\r
738EFIAPI\r
739TcgGetNextUINT32(\r
740 TCG_PARSE_STRUCT *ParseStruct,\r
741 UINT32 *Value\r
742 );\r
743\r
744/**\r
745 Get next specify value.\r
746\r
747 @param ParseStruct Input parse structure.\r
748 @param Value Return vlaue.\r
749\r
750 @retval return the action result.\r
751\r
752**/\r
753TCG_RESULT\r
754EFIAPI\r
755TcgGetNextUINT64(\r
756 TCG_PARSE_STRUCT *ParseStruct,\r
757 UINT64 *Value\r
758 );\r
759\r
760/**\r
761 Get next specify value.\r
762\r
763 @param ParseStruct Input parse structure.\r
764 @param Value Return vlaue.\r
765\r
766 @retval return the action result.\r
767\r
768**/\r
769TCG_RESULT\r
770EFIAPI\r
771TcgGetNextBOOLEAN(\r
772 TCG_PARSE_STRUCT *ParseStruct,\r
773 BOOLEAN *Value\r
774 );\r
775\r
776/**\r
777 Get next tcg uid info.\r
778\r
779 @param ParseStruct Input parse structure.\r
780 @param Uid Get the uid info.\r
781\r
782 @retval return the action result.\r
783\r
784**/\r
785TCG_RESULT\r
786EFIAPI\r
787TcgGetNextTcgUid(\r
788 TCG_PARSE_STRUCT *ParseStruct,\r
789 TCG_UID *Uid\r
790 );\r
791\r
792/**\r
793 Get next byte sequence.\r
794\r
795 @param ParseStruct Input parse structure.\r
796 @param Data return the data.\r
797 @param Length return the length.\r
798\r
799 @retval return the action result.\r
800\r
801**/\r
802TCG_RESULT\r
803EFIAPI\r
804TcgGetNextByteSequence(\r
805 TCG_PARSE_STRUCT *ParseStruct,\r
806 const VOID **Data,\r
807 UINT32 *Length\r
808 );\r
809\r
810/**\r
811 Get next start list.\r
812\r
813 @param ParseStruct Input parse structure.\r
814\r
815 @retval return the action result.\r
816\r
817**/\r
818TCG_RESULT\r
819EFIAPI\r
820TcgGetNextStartList(\r
821 TCG_PARSE_STRUCT *ParseStruct\r
822 );\r
823\r
824/**\r
825 Get next end list.\r
826\r
827 @param ParseStruct Input parse structure.\r
828\r
829 @retval return the action result.\r
830\r
831**/\r
832TCG_RESULT\r
833EFIAPI\r
834TcgGetNextEndList(\r
835 TCG_PARSE_STRUCT *ParseStruct\r
836 );\r
837\r
838/**\r
839 Get next start name.\r
840\r
841 @param ParseStruct Input parse structure.\r
842\r
843 @retval return the action result.\r
844\r
845**/\r
846TCG_RESULT\r
847EFIAPI\r
848TcgGetNextStartName(\r
849 TCG_PARSE_STRUCT *ParseStruct\r
850 );\r
851\r
852/**\r
853 Get next end name.\r
854\r
855 @param ParseStruct Input parse structure.\r
856\r
857 @retval return the action result.\r
858\r
859**/\r
860TCG_RESULT\r
861EFIAPI\r
862TcgGetNextEndName(\r
863 TCG_PARSE_STRUCT *ParseStruct\r
864 );\r
865\r
866/**\r
867 Get next call.\r
868\r
869 @param ParseStruct Input parse structure.\r
870\r
871 @retval return the action result.\r
872\r
873**/\r
874TCG_RESULT\r
875EFIAPI\r
876TcgGetNextCall(\r
877 TCG_PARSE_STRUCT *ParseStruct\r
878 );\r
879\r
880/**\r
881 Get next end data.\r
882\r
883 @param ParseStruct Input parse structure.\r
884\r
885 @retval return the action result.\r
886\r
887**/\r
888TCG_RESULT\r
889EFIAPI\r
890TcgGetNextEndOfData(\r
891 TCG_PARSE_STRUCT *ParseStruct\r
892 );\r
893\r
894/**\r
895 Get next end of session.\r
896\r
897 @param ParseStruct Input parse structure.\r
898\r
899 @retval return the action result.\r
900\r
901**/\r
902TCG_RESULT\r
903EFIAPI\r
904TcgGetNextEndOfSession(\r
905 TCG_PARSE_STRUCT *ParseStruct\r
906 );\r
907\r
908/**\r
909 Get next start transaction.\r
910\r
911 @param ParseStruct Input parse structure.\r
912\r
913 @retval return the action result.\r
914\r
915**/\r
916TCG_RESULT\r
917EFIAPI\r
918TcgGetNextStartTransaction(\r
919 TCG_PARSE_STRUCT *ParseStruct\r
920 );\r
921\r
922/**\r
923 Get next end transaction.\r
924\r
925 @param ParseStruct Input parse structure.\r
926\r
927 @retval return the action result.\r
928\r
929**/\r
930TCG_RESULT\r
931EFIAPI\r
932TcgGetNextEndTransaction(\r
933 TCG_PARSE_STRUCT *ParseStruct\r
934 );\r
935\r
936// end of parse functions\r
937\r
938\r
939typedef\r
940BOOLEAN\r
941(EFIAPI* TCG_LEVEL0_ENUM_CALLBACK) (\r
942 const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,\r
943 TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature,\r
944 UINTN FeatureSize, // includes header\r
945 VOID *Context\r
946);\r
947\r
948/**\r
949 Adds call token and method Header (invoking id, and method id).\r
950\r
951 @param CreateStruct The input create structure.\r
952 @param InvokingId Invoking id.\r
953 @param MethodId Method id.\r
954\r
955**/\r
956TCG_RESULT\r
957EFIAPI\r
958TcgStartMethodCall(\r
959 TCG_CREATE_STRUCT *CreateStruct,\r
960 TCG_UID InvokingId,\r
961 TCG_UID MethodId\r
962 );\r
963\r
964/**\r
965 Adds START LIST token.\r
966\r
967 @param CreateStruct The input create structure.\r
968\r
969**/\r
970TCG_RESULT\r
971EFIAPI\r
972TcgStartParameters(\r
973 TCG_CREATE_STRUCT *CreateStruct\r
974 );\r
975\r
976/**\r
977 Adds END LIST token.\r
978\r
979 @param CreateStruct The input create structure.\r
980\r
981**/\r
982TCG_RESULT\r
983EFIAPI\r
984TcgEndParameters(\r
985 TCG_CREATE_STRUCT *CreateStruct\r
986 );\r
987\r
988/**\r
989 Adds END Data token and method list.\r
990\r
991 @param CreateStruct The input create structure.\r
992\r
993**/\r
994TCG_RESULT\r
995EFIAPI\r
996TcgEndMethodCall(\r
997 TCG_CREATE_STRUCT *CreateStruct\r
998 );\r
999\r
1000/**\r
1001\r
1002 Adds Start Session call to the data structure. This creates the entire ComPacket structure and\r
1003 returns the size of the entire compacket in the size parameter.\r
1004\r
1005 @param [in/out] CreateStruct Structure used to add the start session call\r
1006 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
1007 @param [in] ComId ComID for the ComPacket\r
1008 @param [in] ComIdExtension Extended ComID for the ComPacket\r
1009 @param [in] HostSessionId Host Session ID\r
1010 @param [in] SpId Security Provider to start session with\r
1011 @param [in] Write Write option for start session. TRUE = start session requests write access\r
1012 @param [in] HostChallengeLength Length of the host challenge. Length should be 0 if hostChallenge is NULL\r
1013 @param [in] HostChallenge Host challenge for Host Signing Authority. If NULL, then no Host Challenge shall be sent.\r
1014 @param [in] HostSigningAuthority Host Signing Authority used for start session. If NULL, then no Host Signing Authority shall be sent.\r
1015\r
1016**/\r
1017TCG_RESULT\r
1018EFIAPI\r
1019TcgCreateStartSession(\r
1020 TCG_CREATE_STRUCT *CreateStruct,\r
1021 UINT32 *Size,\r
1022 UINT16 ComId,\r
1023 UINT16 ComIdExtension,\r
1024 UINT32 HostSessionId,\r
1025 TCG_UID SpId,\r
1026 BOOLEAN Write,\r
1027 UINT32 HostChallengeLength,\r
1028 const VOID *HostChallenge,\r
1029 TCG_UID HostSigningAuthority\r
1030 );\r
1031\r
1032/**\r
1033 Creates ComPacket with a Method call that sets the PIN column for the row specified.\r
1034 This assumes a start session has already been opened with the desired SP.\r
1035\r
1036 @param [in/out] CreateStruct Structure used to add method call.\r
1037 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
1038 @param [in] ComId ComID for the ComPacket\r
1039 @param [in] ComIdExtension Extended ComID for the ComPacket\r
1040 @param [in] TperSession Tper Session ID for the Packet\r
1041 @param [in] HostSession Host Session ID for the Packet\r
1042 @param [in] SidRow UID of row of current SP to set PIN column\r
1043 @param [in] Password value of PIN to set\r
1044 @param [in] PasswordSize Size of PIN\r
1045\r
1046**/\r
1047TCG_RESULT\r
1048EFIAPI\r
1049TcgCreateSetCPin(\r
1050 TCG_CREATE_STRUCT *CreateStruct,\r
1051 UINT32 *Size,\r
1052 UINT16 ComId,\r
1053 UINT16 ComIdExtension,\r
1054 UINT32 TperSession,\r
1055 UINT32 HostSession,\r
1056 TCG_UID SidRow,\r
1057 const VOID *Password,\r
1058 UINT32 PasswordSize\r
1059 );\r
1060\r
1061/**\r
1062 Creates ComPacket with a Method call that sets the "Enabled" column for the row specified using the value specified.\r
1063 This assumes a start session has already been opened with the desired SP.\r
1064\r
1065 @param [in/out] CreateStruct Structure used to add method call\r
1066 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
1067 @param [in] ComId ComID for the ComPacket\r
1068 @param [in] ComIdExtension Extended ComID for the ComPacket\r
1069 @param [in] TperSession Tper Session ID for the Packet\r
1070 @param [in] HostSession Host Session ID for the Packet\r
1071 @param [in] AuthorityUid Authority UID to modify the "Enabled" column for\r
1072 @param [in] Enabled Value to set the "Enabled" column to\r
1073\r
1074**/\r
1075TCG_RESULT\r
1076EFIAPI\r
1077TcgSetAuthorityEnabled(\r
1078 TCG_CREATE_STRUCT *CreateStruct,\r
1079 UINT32 *Size,\r
1080 UINT16 ComId,\r
1081 UINT16 ComIdExtension,\r
1082 UINT32 TperSession,\r
1083 UINT32 HostSession,\r
1084 TCG_UID AuthorityUid,\r
1085 BOOLEAN Enabled\r
1086 );\r
1087\r
1088/**\r
1089\r
1090 Creates ComPacket with EndSession.\r
1091 This assumes a start session has already been opened.\r
1092\r
1093 @param [in/out] CreateStruct Structure used to add Endsession\r
1094 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
1095 @param [in] ComId ComID for the ComPacket\r
1096 @param [in] ComIdExtension Extended ComID for the ComPacket\r
1097 @param [in] HostSessionId Host Session ID for the Packet\r
1098 @param [in] TpSessionId Tper Session ID for the Packet\r
1099\r
1100**/\r
1101TCG_RESULT\r
1102EFIAPI\r
1103TcgCreateEndSession(\r
1104 TCG_CREATE_STRUCT *CreateStruct,\r
1105 UINT32 *Size,\r
1106 UINT16 ComId,\r
1107 UINT16 ComIdExtension,\r
1108 UINT32 HostSessionId,\r
1109 UINT32 TpSessionId\r
1110 );\r
1111\r
1112\r
1113/**\r
1114\r
1115 Retrieves human-readable token type name.\r
1116\r
1117 @param[in] Type Token type to retrieve\r
1118\r
1119**/\r
1120CHAR8*\r
1121EFIAPI\r
1122TcgTokenTypeString(\r
1123 TCG_TOKEN_TYPE Type\r
1124 );\r
1125\r
1126/**\r
1127 Returns the method status of the current subpacket. Does not affect the current position\r
1128 in the ComPacket. In other words, it can be called whenever you have a valid SubPacket.\r
1129\r
1130 @param [in/out] ParseStruct Structure used to parse received TCG response\r
1131 @param [in/out] MethodStatus Method status retrieved of the current SubPacket\r
1132\r
1133**/\r
1134TCG_RESULT\r
1135EFIAPI\r
1136TcgGetMethodStatus(\r
1137 const TCG_PARSE_STRUCT *ParseStruct,\r
1138 UINT8 *MethodStatus\r
1139 );\r
1140\r
1141/**\r
1142 Returns a human-readable string representing a method status return code.\r
1143\r
1144 @param[in] MethodStatus Method status to translate to a string\r
1145\r
1146\r
1147 @retval return the string info.\r
1148**/\r
1149CHAR8*\r
1150EFIAPI\r
1151TcgMethodStatusString(\r
1152 UINT8 MethodStatus\r
1153 );\r
1154\r
1155\r
1156/**\r
1157 Retrieves the comID and Extended comID of the ComPacket in the Tcg response.\r
1158 It is intended to be used to confirm the received Tcg response is intended for user that received it.\r
1159\r
1160 @param [in] ParseStruct Structure used to parse received TCG response.\r
1161 @param [in/out] ComId comID retrieved from received ComPacket.\r
1162 @param [in/out] ComIdExtension Extended comID retrieved from received ComPacket\r
1163\r
1164**/\r
1165TCG_RESULT\r
1166EFIAPI\r
1167TcgGetComIds(\r
1168 const TCG_PARSE_STRUCT *ParseStruct,\r
1169 UINT16 *ComId,\r
1170 UINT16 *ComIdExtension\r
1171 );\r
1172\r
1173/**\r
1174 Checks if the ComIDs of the response match the expected values.\r
1175\r
1176 @param[in] ParseStruct Structure used to parse received TCG response\r
1177 @param[in] ExpectedComId Expected comID\r
1178 @param[in] ExpectedComIdExtension Expected extended comID\r
1179\r
1180**/\r
1181TCG_RESULT\r
1182EFIAPI\r
1183TcgCheckComIds(\r
1184 const TCG_PARSE_STRUCT *ParseStruct,\r
1185 UINT16 ExpectedComId,\r
1186 UINT16 ExpectedComIdExtension\r
1187 );\r
1188\r
1189/**\r
1190 Parses the Sync Session response contained in the parseStruct to retrieve Tper session ID. If the Sync Session response\r
1191 parameters do not match the comID, extended ComID and host session ID then a failure is returned.\r
1192\r
1193 @param[in/out] ParseStruct Structure used to parse received TCG response, contains Sync Session response.\r
1194 @param[in] ComId Expected ComID that is compared to actual ComID of response\r
1195 @param[in] ComIdExtension Expected Extended ComID that is compared to actual Extended ComID of response\r
1196 @param[in] HostSessionId Expected Host Session ID that is compared to actual Host Session ID of response\r
1197 @param[in/out] TperSessionId Tper Session ID retrieved from the Sync Session response.\r
1198\r
1199**/\r
1200TCG_RESULT\r
1201EFIAPI\r
1202TcgParseSyncSession(\r
1203 const TCG_PARSE_STRUCT *ParseStruct,\r
1204 UINT16 ComId,\r
1205 UINT16 ComIdExtension,\r
1206 UINT32 HostSessionId,\r
1207 UINT32 *TperSessionId\r
1208 );\r
1209\r
1210/**\r
1211 Create set ace.\r
1212\r
1213 @param CreateStruct Input create structure.\r
1214 @param Size size info.\r
1215 @param ComId ComId info.\r
1216 @param ComIdExtension ComId extension info.\r
1217 @param TperSession Tper session data.\r
1218 @param HostSession Host session data.\r
1219 @param AceRow Ace row info.\r
1220 @param Authority1 Authority 1 info.\r
1221 @param LogicalOperator Logiccal operator info.\r
1222 @param Authority2 Authority 2 info.\r
1223\r
1224 @retval Return the action result.\r
1225\r
1226**/\r
1227TCG_RESULT\r
1228EFIAPI\r
1229TcgCreateSetAce(\r
1230 TCG_CREATE_STRUCT *CreateStruct,\r
1231 UINT32 *Size,\r
1232 UINT16 ComId,\r
1233 UINT16 ComIdExtension,\r
1234 UINT32 TperSession,\r
1235 UINT32 HostSession,\r
1236 TCG_UID AceRow,\r
1237 TCG_UID Authority1,\r
1238 BOOLEAN LogicalOperator,\r
1239 TCG_UID Authority2\r
1240 );\r
1241\r
1242/**\r
1243 Enum level 0 discovery.\r
1244\r
1245 @param DiscoveryHeader Discovery header.\r
1246 @param Callback Callback function.\r
1247 @param Context The context for the function.\r
1248\r
1249 @retval return true if the callback return TRUE, else return FALSE.\r
1250\r
1251**/\r
1252BOOLEAN\r
1253EFIAPI\r
1254TcgEnumLevel0Discovery(\r
1255 const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,\r
1256 TCG_LEVEL0_ENUM_CALLBACK Callback,\r
1257 VOID *Context\r
1258 );\r
1259\r
1260/**\r
1261 Get Feature code from the header.\r
1262\r
1263 @param DiscoveryHeader The discovery header.\r
1264 @param FeatureCode reutrn the Feature code.\r
1265 @param FeatureSize return the Feature size.\r
1266\r
1267 @retval return the Feature code data.\r
1268**/\r
1269TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER*\r
1270EFIAPI\r
1271TcgGetFeature(\r
1272 const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,\r
1273 UINT16 FeatureCode,\r
1274 UINTN *FeatureSize\r
1275 );\r
1276\r
1277/**\r
1278 Determines if the protocol provided is part of the provided supported protocol list.\r
1279\r
1280 @param[in] ProtocolList Supported protocol list to investigate\r
1281 @param[in] Protocol Protocol value to determine if supported\r
1282\r
1283 @return TRUE = protocol is supported, FALSE = protocol is not supported\r
1284**/\r
1285BOOLEAN\r
1286EFIAPI\r
1287TcgIsProtocolSupported(\r
1288 const TCG_SUPPORTED_SECURITY_PROTOCOLS *ProtocolList,\r
1289 UINT16 Protocol\r
1290 );\r
1291\r
1292/**\r
1293 Determines if the Locking Feature "Locked" bit is set in the level 0 discovery response.\r
1294\r
1295 @param[in] Discovery Level 0 discovery response\r
1296\r
1297 @return TRUE = Locked is set, FALSE = Locked is false\r
1298\r
1299**/\r
1300BOOLEAN\r
1301EFIAPI\r
1302TcgIsLocked(\r
1303 const TCG_LEVEL0_DISCOVERY_HEADER *Discovery\r
1304 );\r
1305\r
1306#pragma pack()\r
1307\r
1308\r
1309#endif // _TCG_CORE_H_\r