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