tpm2-tss

AUTHOR
Version 4.0.1

Table of Contents

Table of contents

tpm2-tss
           
Overview
This repository hosts source code implementing the Trusted Computing Group's (TCG) TPM2 Software Stack (TSS). This stack consists of the following layers from top to bottom:

Feature API (FAPI) as described in the TCG Feature API (FAPI) Specification along with TCG TSS 2.0 JSON Data Types and Policy Language Specification This API is designed to be very high-level API, intended to make programming with the TPM as simple as possible. The API functions are exposed through a single library: libtss2-fapi.
Enhanced System API (ESAPI) as described in the TCG TSS 2.0 Enhanced System API (ESAPI) Specification This API is a 1-to-1 mapping of the TPM2 commands documented in Part 3 of the TPM2 specification. Additionally there are asynchronous versions of each command. In addition to SAPI, the ESAPI performs tracking of meta data for TPM object and automatic calculation of session based authorization and encryption values. Both the synchronous and asynchronous API are exposed through a single library: libtss2-esys.
System API (SAPI) as described in the TCG TSS 2.0 System Level API (SAPI) Specification This API is a 1-to-1 mapping of the TPM2 commands documented in Part 3 of the TPM2 specification. Additionally there are asynchronous versions of each command. These asynchronous variants may be useful for integration into event-driven programming environments. Both the synchronous and asynchronous API are exposed through a single library: libtss2-sys.
Marshaling/Unmarshaling (MU) as described in the TCG TSS 2.0 Marshaling/Unmarshaling API Specification This API provides a set of marshaling and unmarshaling functions for all data types define by the TPM library specification. The Marshaling/Unmarshaling API is exposed through a library called libtss2-mu.
TPM Command Transmission Interface (TCTI) as described in the TCG TSS 2.0 TPM Command Transmission Interface (TCTI) API Specification. This API provides a standard interface to transmit / receive TPM command / response buffers. It is expected that any number of libraries implementing the TCTI API will be implemented as a way to abstract various platform specific IPC mechanisms. Currently this repository provides several TCTI implementations: libtss2-tcti-device, libtss2-tcti-tbs (for Windows), libtss2-tcti-swtpm and libtss2-tcti-mssim. The former should be used for direct access to the TPM through the Linux kernel driver. The latter implements the protocol exposed by the Microsoft software TPM2 simulator.
The TCG TSS 2.0 Overview and Common Structures Specification forms the basis for all implementations in this project. NOTE: We deviate from this specification by increasing the value of TPM2_NUM_PCR_BANKS from 3 to 16 to ensure compatibility with TPM2 implementations that have enabled a larger than typical number of PCR banks. This larger value for TPM2_NUM_PCR_BANKS is expected to be included in a future revision of the specification.

Build and Installation Instructions:
Instructions to build and install tpm2-tss are available in the INSTALL file.
Getting in Touch:
If you're looking to discuss the source code in this project or get some questions answered you should join the 01.org TPM2 mailing list:
https://lists.linuxfoundation.org/mailman/listinfo/tpm2

We also have an IRC channel set up on FreeNode called #tpm2.0-tss. You can also try Gitter 
You can join a weekly online call at TPM.dev, where we are discussing the tpm2-tss stack, the tpm2-pkcs11 project and other Linux TPM2 & TSS2-Software.
In case you want to contribute to the project, please also have a look at the Contribution Guidelines.
Documentation
The doxygen documentation can either be built by oneself (see the INSTALL file) or browsed directly on tpm2-tss.readthedocs.io.
Test Suite
This repository contains a test suite intended to exercise the TCTI, SAPI and ESAPI code. This test suite is not  intended to test a TPM implementation, so this test suite should only be run against a TPM simulator. If this test suite is executed against a TPM other than the software simulator it may cause damage to the TPM (NV storage wear out, etc.). You have been warned.
Simulator
The TPM library specification contains reference code sufficient to construct a software TPM 2.0 simulator. This code was provided by Microsoft and they provide a binary download for Windows here.
There are two implementations that enable building and running this code on Linux. Issues building or running the simulator should be reported to respective project.
Software TPM
The Software TPM is an open-source TPM emulator with different front-end interfaces such as socket and character device. Its code is hosted on GitHub and building is faciliated by the GNU Autotools. The TCTI module for using this simulator is called swtpm .
Since tpm2-tss v3.0 swtpm is the default simulator used by this project.
IBM's Software Simulator
IBM has also repackaged this code with a few Makefiles so that the Microsoft code can be built and run on Linux systems. The Linux version of the Microsoft TPM 2.0 simulator can be obtained on SourceForge. Once you've downloaded and successfully built and execute the simulator it will, by default, be accepting connections on the localhost, TCP ports 2321 and 2322. The TCTI module for using this simulator is called mssim .

Testing
To test the various TCTI, SAPI and ESAPI api calls, unit and integration tests can be run by configuring the build to enable unit testing and running the "check" build target. It is recommended to use a simulator for testing, and the simulator will be automatically launched by the tests. Please review the dependency list in INSTALL for dependencies when building the test suite. 
$ ./configure --enable-unit --enable-integration
$ make -j$(nproc) check
 This will generate a file called "test-suite.log" in the root of the build directory.
Please report failures in a Github 'issue' with a full log of the test run.
NOTE: The unit and integration tests can be enabled independently. The –enable-unit option controls unit tests, and –enable-integration controls the integration tests.
Running tests on physical TPM device
To run integration tests on a physical TPM device, including a TPM hardware or a software TPM implemented in platform firmware the configure script provides two options. The first option is called –with-device and it is used to point to the TPM device interface exposed by the OS, for example:

$ ./configure  --with-device=/dev/tpm0
 The second option, –with-devicetests, enables a "class" of test. There are three classes:
1.	destructive - these tests can affect TPM capability or lifespan
2.	mandatory - these tests check all the functionality that is mandatory per the TCG specification (default).
3.	optional - these tests are for functionality that is optional per the TCG specification.

For example to enable both mandatory and optional test cases during configure one needs to set this flag as follows:

$ ./configure --with-devicetests="mandatory,optional"
 Tht default value for the flag is "mandatory" Any combination of the three is valid. The two flags are only valid when the integration tests are enabled with –enable-integration flag.
After that the following command is used to run the test on the configured TPM device:

$ sudo make check-device
 or 
$ sudo make check -j 1

Note: The tests can not be run in paralel.
Running valgrind check
The unit and integration tests can be run under the valgrind tool, which performs additional checks on the library and test code, such as memory leak checks etc. The following command is used to run the tests under valgrind:
$ make check-valgrind
This command will enable all valgrind "tools" and kick off as many test as they support. It is possible to enable different valgrind tools (checks) in more granularity. This can be controlled by invoking different tools separately using check-valgrind-<tool>, for instance:

$ make check-valgrind-memcheck
 or 
$ make check-valgrind-drd

Currently the the following tools are supported:
memcheck - Performs memory related checks. This is the default tool. helgrind - Performs synchronization errors checks. drd - Performs thread related checks. sgcheck - Performs stack overrun related checks.
Note that the valgring tool can also be invoked manually using the standard libtool:

$ libtool exec valgrind --tool=memcheck --leak-check=full \
  test/integration/esys-auto-session-flags.int

This allows for more control on what checks are performed.
Logging
While investigating issues it might be helpful to enable extra debug/trace output. It can be enabled separately for different components. The description how to do this can be found in the logging file.
Fuzzing
All system API function calls can be tested using a fuzzing library. The description how to do this can be found in the fuzzing file.

Architecture/Block Diagram
SAPI library, TAB/RM, and Test Code Block Diagram:    Image  
Project Layout

|-- doc     : various bits of documentation\
|-- include : header files installed in $(includedir)\
|   +-- tss2      : all public headers for this project\
|-- lib     : data files used by the build or installed into $(libdir)\
|-- m4      : autoconf support macros\
|-- man     : man pages\
|-- script  : scripts used by the build or CI\
|-- src     : all source files\
|   |-- tss2-esys : enhanced system API (ESAPI) implementation\
|   |   +-- api   : ESAPI TPM API implementation\
|   |-- tss2-mu   : TPM2 type marshaling/unmarshaling (MU) API implementation\
|   |-- tss2-sys  : system API (SAPI) implementation\
|   |   +-- api   : SAPI public API implementation\
|   |-- tss2-tcti : TCTI implementations for device and mssim\
|   +-- util      : Internal utility library (e.g. logging framework)\
+-- test    : test code\
    |-- integration : integration test harness and test cases\
    |-- tpmclient   : monolithic, legacy test application\
    +-- unit        : unit tests

Coding Standard
The coding standard followed in this code base is similar in most ways to the style followed by the Linux kernel. Naturally there are exceptions. Most notably is the indentation (more on this later). Above all else we ask that when modifying the code that you follow the most important rule: check the surrounding code and imitate its style [1].
C Standard and Compiler Stuff
Code should hold as close to the C99 standard as possible with the exception that GCC specific extensions are generally accepted. The code must compile without warnings for the primary target compiler when all warnings are enabled. If a warning is unavoidable, the offending line must be documented with an explanation of why said code can not be modified to appease the compiler [2].
It is worth noting however that this code base has yet to run into a compiler warning that wasn't the authors fault. It is likely that if you do find yourself disabling -Werror  you're probably doing something wrong.
Comments
There are two acceptable commenting styles: block, line. Block comments are used to document a largeish block of code, typically a function. Sometimes block comments are useful with a function to document a loop or a particularly tricky part of an algorithm. Line comments are typically a single sentence on a single line. They provide some brief explanation of a line or two of code.
NOTE: Comments are most useful to convey the purpose, parameters and results from functions and objects in a system. Excessive use of comments within a function is indicative of two things: over documentation and code that needs to be refactored. To combat the first case let's say that it's safe to assume that your code will be read by competent C programmers. The second case can be tricky and there's no rule of thumb. Follow your instincts and keep in mind that excessive line comments are a sort of "code smell" that may mean your code would benefit from some restructuring.
Examples

/*
 * This block comment could apply to some function and describe its inner
 * workings.  Notice these sentences have traditional capitalization and
 * punctuation... that's because it has to be read in a way completely
 * unlike the Post-It style content of next-line and line comments.
 */
 
// This is *not* an acceptable block comment.
// Don't do this.
// Please.
 
/* This is a line comment */

Whitespace
All indentation must be spaces, not tabs. Lines are indented in multiples of 4 spaces. Each line of code and documentation will end with a non-whitespace character. There must not  be any whitespace between the last line of code or documentation in a file and the end of the file.
Naming Variables, Functions and Other Stuff
Names should clearly convey the purpose of whatever is being named. While the data type of a variable conveys some information, this alone is insufficient. Multiple word names are descriptive and most easily read if words are separated with the underscore character, "_".
Variable and function names must be lowercase. Words in each name must be separated by an underscore character: "_". Macros and constants (anything declared with #define) must be in all-caps, again with words separated by underscores.
Objects created using the GObject system follow the GObject naming convention with individual words in object names as upper case characters.
Exceptions
Exceptions to these rules are made for compliance with the TCG specifications. All function names, parameters, and other data types must be implemented faithfully to the specification and so may violate the naming conventions defined here.
Examples

unsigned int table_index = find_index(jacket_table, "color", COLOR_RED);
 
int last_item = 0;
while (!last_item) {
     /* ... */
}
 
int char_found = is_alpha (c);

Single letter variable names should be avoided. Exceptions are:
"i", "j", and "k" are loop counters or temporary array indexes
"m" and "n" are row and column indexes for multidimensional arrays
"c" and "s" are temporary/parameter characters or strings
"r", "g", "b", and "a" are red, green, blue, and alpha levels, but only when
they are used together
"x", "y", and "z" are coordinate values

Abbreviated words in variable names should be avoided. Exceptions are:
"char" = character
"col" = column. Typically there is also "row" so it is not confused with color
"cnt" = count
"pos" = position
"rem" = remainder
"ctx" = context

Function names should follow the naming conventions of variables and clearly describe not only what the function does, but also the nature of what it returns (if anything). Functions that return boolean integers should be named to reflect the true condition even if they are created to detect false conditions. Functions should never be hidden in conditional statements, with the exception of loops where it makes the code more simple. 
bool is_number_prime = is_prime(i);
 
if (is_number_prime) {
    /* ... */
}
 
while (!labeled_correctly(sample[i])) {
    /* ... */
}

A function that is exported for use in multiple source files should be prefixed with the source file (or object module) name where it is defined. For example, the file list.c may contain the implementation of a dynamic list ADT including an exported method for creating a list instance and an internal (static) method for overflow checking. The first function might be named "list_create", and the second, "is_overflowed".
The use of the static keyword when defining functions is a useful way to scope the visibility of the function to the same translation unit. A negative side effect of this is preventing the testing of the function through the unit testing harness. Generally we accept exposing symbols to get better test coverage.

Files
Typically every header file has the same base filename as an associated source file. Exceptions to this rule are generally limited to modules that will expose a separate set symbols to external consumers. In this case the internal version of the header should be suffixed with '-priv'.
Files names are formatted in the same way as described above with the exception of hyphens "-" separating words.
The body of each header file must be surrounded by an include guard (aka "header guard"). These guards shall be given the same name as the file in which they reside. Their names shall be all caps, with words separated by the underscore character "_".
Header files should never define functions or variables.
Header files should only #include what is necessary to allow a file that includes it to compile. Associated source files will always #include the header of the same name, but should #include files whose resources are used within the source even if they are already included in that header. This provides a complete context for readers of the source file... i.e., they don't have to search through headers to determine where a resource came from.
Files included by all source files must conform to the following format and order. Each entry in the list below defines a contiguous block of include  directives separated by a blank line:
System headers - These are headers provided by the core c libraries (typically from libc).
External dependencies - These are headers installed on the platform defining interfaces to external libraries.
Standard TSS2 headers - These are headers that define the public TSS2 types and interfaces. They are all located under /include/* and will be installed as part of the install  build target. These must  be included using the quoted include variant (using "</tt> instead of the angle brackets).* Internal headers - These are headers defining the interfaces to code modulesthat are internal to the project.Headers in each block must listed in alphabetical order.@subsection autotoc_md9 Exampleheader: <tt>example-module.h</tt>@icode /* * BSD license block */#ifndef EXAMPLE_MODULE_H#define EXAMPLE_MODULE_H#include <stdint.h>#include <sys/types.h>#include "tss2/tss2_tpm2_types.h"#include "internal-module.h"/* * preprocess or directives and declarations using stuff from included headers */#endif /* EXAMPLE_MODULE_H */@endicode implementation: <tt>example-module.c</tt>@icode /* * BSD license block */#include <inttypes.h>#include <stdint.h>#include <foo/bar.h>#include "tss2/tss2_tcti.h"#include "tss2/tss2_tpm2_types.h"#include "example-module.h"#include "internal-module.h"/* * Implementation / code using headers listed above. */@endicode @section autotoc_md10 TypesTypes shall be selected for their use case. Variables should only be of asigned type if something should ever be negative. A common, incorrect use, isto declare loop counters as int instead of unsigned, or to use an int to holdthe size of some object.@section autotoc_md11 FormattingAlways use space characters, 4 spaces per level of indentation.Conditional statements (such as if, else, while, for, switch, etc) must placethe opening brace on the same line after the end of the control flow statement.The closing brace should be placed at the same column position as the beginningof the associated control flow statement on a line by itself.Function definitions specify the return type on a line, followed by thefunction name followed by the first parameter. Each additional parameter islisted on a separate line aligned with the line above. The opening bracedefning the functions scope must be on the following line at column position 0.A space must separate a control flow statement or function and the openingparenthesis.Line length should not exceed 80 characters and should be split on the nearestwhitespace or delimiter character. When splitting lines with@subsection autotoc_md12 Example@icode{c} if (some_int > 0) {    statement1;    statement2;}@endicode @icode{c} voidsome_function (short_t       arg_1,               longer_name_t arg_2){    statement1;    statement2;}@endicode @icode{c} some_long_variable_name =    some_long_function_name (lots_of_parameters_1, lots_of_parameters_2);@endicode @icode{c} some_long_variable_name = some_long_function_name (lots_of_parameters_1,                                                   lots_of_parameters_2,                                                   lots_of_parameters_3);@endicode These formatting conditions are contrary to Kernighan and Ritchie's "one true brace style" [3]. 

References

1.	GNOME C Coding Style : https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en
2.	Alan Bridger, Mick Brooks, and Jim Pisano, C Coding Standards, 2001, http://www.alma.nrao.edu/development/computing/docs/joint/0009/2001-02-28.pdf
3.	Brian Kernighan, Dennis Ritchie, The C Programing Language, 1988 

Compile time log levels
 At compile time the maximum log level can be specified. This allows distros to disable the overhead code and reduce overall code size.
Runtime log level
At runtime, the log level is determined by an environment variable. The default log level is WARNING. The level can be changed by setting the TSS2_LOG  environment variable.
Possible levels are: NONE, ERROR, WARNING, INFO, DEBUG, TRACE
The level can be set for all module using the all  module name or individually per module. The environment variable is evaluated left to right.
Example: TSS2_LOG=all+ERROR,marshal+TRACE,tcti+DEBUG 
Log file
By default, logs are written to standard error (stderr ). If the environment variable TSS2_LOGFILE  is set, the TSS will log to the file at the given path instead. If the file does not yet exist, it will be created. Otherwise, the TSS will append to it.
The special value stderr  will result in default behavior while stdout  and -  will have the TSS write to standard output.
Implementation
Each source code file specifies its corresponding module before including log.h. 
#define LOGMODULE tcti
#include "log.h"
 Optionally, the default log-level for this module can be set: 
#define LOGMODULE tcti
#define LOGDEFAULT ERROR
#include "log.h"

Todo List
Module iesys_util  
Description and Documentat of functions

Module Index
Modules
Here is a list of all modules:
Enhanced System API	pagenum
Esys Context ESYS_CONTEXT	pagenum
Esys Tpm Resource ESYS_TR	pagenum
Global ESYS_TR objects	pagenum

Esys TPM Commands	pagenum
The ESAPI function for the TPM2_ActivateCredential command.	pagenum
The ESAPI function for the TPM2_Certify command.	pagenum
The ESAPI function for the TPM2_CertifyCreation command.	pagenum
The ESAPI function for the TPM2_ChangeEPS command.	pagenum
The ESAPI function for the TPM2_ChangePPS command.	pagenum
The ESAPI function for the TPM2_Clear command.	pagenum
The ESAPI function for the TPM2_ClearControl command.	pagenum
The ESAPI function for the TPM2_ClockRateAdjust command.	pagenum
The ESAPI function for the TPM2_ClockSet command.	pagenum
The ESAPI function for the TPM2_Commit command.	pagenum
The ESAPI function for the TPM2_ContextLoad command.	pagenum
The ESAPI function for the TPM2_ContextSave command.	pagenum
The ESAPI function for the TPM2_Create command.	pagenum
The ESAPI function for the TPM2_CreatePrimary command.	pagenum
The ESAPI function for the TPM2_DictionaryAttackLockReset command.	pagenum
The ESAPI function for the TPM2_DictionaryAttackParameters command.	pagenum
The ESAPI function for the TPM2_Duplicate command.	pagenum
The ESAPI function for the TPM2_ECC_Parameters command.	pagenum
The ESAPI function for the TPM2_ECDH_KeyGen command.	pagenum
The ESAPI function for the TPM2_ECDH_ZGen command.	pagenum
The ESAPI function for the TPM2_EC_Ephemeral command.	pagenum
The ESAPI function for the TPM2_EncryptDecrypt command.	pagenum
The ESAPI function for the TPM2_EventSequenceComplete command.	pagenum
The ESAPI function for the TPM2_EvictControl command.	pagenum
The ESAPI function for the TPM2_FlushContext command.	pagenum
The ESAPI function for the TPM2_GetCapability command.	pagenum
The ESAPI function for the TPM2_GetCommandAuditDigest command.	pagenum
The ESAPI function for the TPM2_GetRandom command.	pagenum
The ESAPI function for the TPM2_GetSessionAuditDigest command.	pagenum
The ESAPI function for the TPM2_GetTestResult command.	pagenum
The ESAPI function for the TPM2_GetTime command.	pagenum
The ESAPI function for the TPM2_Hash command.	pagenum
The ESAPI function for the TPM2_HashSequenceStart command.	pagenum
The ESAPI function for the TPM2_HierarchyChangeAuth command.	pagenum
The ESAPI function for the TPM2_HierarchyControl command.	pagenum
The ESAPI function for the TPM2_HMAC command.	pagenum
The ESAPI function for the TPM2_HMAC_Start command.	pagenum
The ESAPI function for the TPM2_Import command.	pagenum
The ESAPI function for the TPM2_IncrementalSelfTest command.	pagenum
The ESAPI function for the TPM2_Load command.	pagenum
The ESAPI function for the TPM2_LoadExternal command.	pagenum
The ESAPI function for the TPM2_MakeCredential command.	pagenum
The ESAPI function for the TPM2_NV_Certify command.	pagenum
The ESAPI function for the TPM2_NV_ChangeAuth command.	pagenum
The ESAPI function for the TPM2_NV_DefineSpace command.	pagenum
The ESAPI function for the TPM2_NV_Extend command.	pagenum
The ESAPI function for the TPM2_NV_GlobalWriteLock command.	pagenum
The ESAPI function for the TPM2_NV_Increment command.	pagenum
The ESAPI function for the TPM2_NV_Read command.	pagenum
The ESAPI function for the TPM2_NV_ReadLock command.	pagenum
The ESAPI function for the TPM2_NV_ReadPublic command.	pagenum
The ESAPI function for the TPM2_NV_SetBits command.	pagenum
The ESAPI function for the TPM2_NV_UndefineSpace command.	pagenum
The ESAPI function for the TPM2_NV_UndefineSpaceSpecial command.	pagenum
The ESAPI function for the TPM2_NV_Write command.	pagenum
The ESAPI function for the TPM2_NV_WriteLock command.	pagenum
The ESAPI function for the TPM2_ObjectChangeAuth command.	pagenum
The ESAPI function for the TPM2_PCR_Allocate command.	pagenum
The ESAPI function for the TPM2_PCR_Event command.	pagenum
The ESAPI function for the TPM2_PCR_Extend command.	pagenum
The ESAPI function for the TPM2_PCR_Read command.	pagenum
The ESAPI function for the TPM2_PCR_Reset command.	pagenum
The ESAPI function for the TPM2_PCR_SetAuthPolicy command.	pagenum
The ESAPI function for the TPM2_PCR_SetAuthValue command.	pagenum
The ESAPI function for the TPM2_PolicyAuthorize command.	pagenum
The ESAPI function for the TPM2_PolicyAuthValue command.	pagenum
The ESAPI function for the TPM2_PolicyCommandCode command.	pagenum
The ESAPI function for the TPM2_PolicyCounterTimer command.	pagenum
The ESAPI function for the TPM2_PolicyCpHash command.	pagenum
The ESAPI function for the TPM2_PolicyDuplicationSelect command.	pagenum
The ESAPI function for the TPM2_PolicyGetDigest command.	pagenum
The ESAPI function for the TPM2_PolicyLocality command.	pagenum
The ESAPI function for the TPM2_PolicyNameHash command.	pagenum
The ESAPI function for the TPM2_PolicyNV command.	pagenum
The ESAPI function for the TPM2_PolicyNvWritten command.	pagenum
The ESAPI function for the TPM2_PolicyOR command.	pagenum
The ESAPI function for the TPM2_PolicyPassword command.	pagenum
The ESAPI function for the TPM2_PolicyPCR command.	pagenum
The ESAPI function for the TPM2_PolicyPhysicalPresence command.	pagenum
The ESAPI function for the TPM2_PolicyRestart command.	pagenum
The ESAPI function for the TPM2_PolicySecret command.	pagenum
The ESAPI function for the TPM2_PolicySigned command.	pagenum
The ESAPI function for the TPM2_PolicyTicket command.	pagenum
The ESAPI function for the TPM2_PP_Commands command.	pagenum
The ESAPI function for the TPM2_Quote command.	pagenum
The ESAPI function for the TPM2_ReadClock command.	pagenum
The ESAPI function for the TPM2_ReadPublic command.	pagenum
The ESAPI function for the TPM2_Rewrap command.	pagenum
The ESAPI function for the TPM2_RSA_Decrypt command.	pagenum
The ESAPI function for the TPM2_RSA_Encrypt command.	pagenum
The ESAPI function for the TPM2_SelfTest command.	pagenum
The ESAPI function for the TPM2_SequenceComplete command.	pagenum
The ESAPI function for the TPM2_SequenceUpdate command.	pagenum
The ESAPI function for the TPM2_SetAlgorithmSet command.	pagenum
The ESAPI function for the TPM2_SetCommandCodeAuditStatus command.	pagenum
The ESAPI function for the TPM2_SetPrimaryPolicy command.	pagenum
The ESAPI function for the TPM2_Shutdown command.	pagenum
The ESAPI function for the TPM2_Sign command.	pagenum
The ESAPI function for the TPM2_StartAuthSession command.	pagenum
The ESAPI function for the TPM2_Startup command.	pagenum
The ESAPI function for the TPM2_StirRandom command.	pagenum
The ESAPI function for the TPM2_TestParms command.	pagenum
The ESAPI function for the TPM2_Unseal command.	pagenum
The ESAPI function for the TPM2_Vendor_TCG_Test command.	pagenum
The ESAPI function for the TPM2_VerifySignature command.	pagenum
The ESAPI function for the TPM2_ZGen_2Phase command.	pagenum

Internals of Enhanced System API	pagenum
Internal ESAPI Types	pagenum
Internal Cryptographic Backend	pagenum
Internal ESAPI utility functions.	pagenum

Testing	pagenum
Esys-Testing	pagenum
Fapi-Testing	pagenum

Feature API	pagenum
Fapi_Initialize	pagenum
Fapi_Finalize	pagenum
Fapi_GetTcti	pagenum
Fapi_GetPollHandles	pagenum
Fapi_Free	pagenum
Fapi_GetInfo	pagenum
Fapi_Provision	pagenum
Fapi_GetPlatformCertificates	pagenum
Fapi_GetEsysBlobs	pagenum
Fapi_GetRandom	pagenum
Fapi_Import	pagenum
Fapi_List	pagenum
Fapi_Delete	pagenum
Fapi_ChangeAuth	pagenum
Fapi_SetDescription	pagenum
Fapi_GetDescription	pagenum
Fapi_SetAppData	pagenum
Fapi_GetAppData	pagenum
Fapi_GetTpmBlobs	pagenum
Fapi_CreateKey	pagenum
Fapi_Sign	pagenum
Fapi_VerifySignature	pagenum
Fapi_Encrypt	pagenum
Fapi_Decrypt	pagenum
Fapi_SetCertificate	pagenum
Fapi_GetCertificate	pagenum
Fapi_ExportKey	pagenum
Fapi_CreateSeal	pagenum
Fapi_Unseal	pagenum
Fapi_ExportPolicy	pagenum
Fapi_AuthorizePolicy	pagenum
Fapi_WriteAuthorizeNv	pagenum
Fapi_PcrRead	pagenum
Fapi_PcrExtend	pagenum
Fapi_Quote	pagenum
Fapi_VerifyQuote	pagenum
Fapi_CreateNv	pagenum
Fapi_NvRead	pagenum
Fapi_NvWrite	pagenum
Fapi_NvExtend	pagenum
Fapi_NvIncrement	pagenum
Fapi_NvSetBits	pagenum
Fapi_SetAuthCB	pagenum
Fapi_SetBranchCB	pagenum
Fapi_SetSignCB	pagenum
Internals of Feature API	pagenum
Internal Cryptographic Backend	pagenum
Policy instantiation module	pagenum
Policy calculation module	pagenum
Policy callback functions.	pagenum
Policy execution functions.	pagenum
Policy utilitiy module	pagenum
Helper functions module	pagenum
Utility module	pagenum
Basic IO module	pagenum
Key store module	pagenum
Policy store module	pagenum
Configuration utilities.	pagenum
Event log utilities.	pagenum
Profile module	pagenum
FAPI object serialization module	pagenum
FAPI object deserialization module	pagenum
Vendor specific module	pagenum

Data Structure Index
Data Structures
Here are the data structures with brief descriptions:
_IFAPI_CRYPTO_CONTEXT  	pagenum
_IFAPI_OBJECT  	pagenum
callback_data  	pagenum
cb_data  	pagenum
CurlBufferStruct  	pagenum
ESYS_CRYPTO_CALLBACKS  	pagenum
ESYS_CRYPTO_CONTEXT_BLOB  	pagenum
event_callbacks  	pagenum
FAPI_CONTEXT  	pagenum
FAPI_QUOTE_INFO  	pagenum
IFAPI_api_WriteAuthorizeNv  	pagenum
IFAPI_CALLBACKS  	pagenum
IFAPI_CAP_INFO  	pagenum
IFAPI_CMD_STATE  	pagenum
IFAPI_CONFIG  	pagenum
IFAPI_CreatePrimary  	pagenum
IFAPI_Data_EncryptDecrypt  	pagenum
IFAPI_DUPLICATE  	pagenum
IFAPI_Entities_List  	pagenum
IFAPI_Entity_ChangeAuth  	pagenum
IFAPI_Entity_Delete  	pagenum
IFAPI_EVENT  	pagenum
IFAPI_EVENT_TYPE_ASSIGN  	pagenum
IFAPI_EVENT_UNION  	pagenum
IFAPI_EVENTLOG  	pagenum
IFAPI_ExportKey  	pagenum
IFAPI_ExportPolicy  	pagenum
IFAPI_EXT_PUB_KEY  	pagenum
IFAPI_Fapi_AuthorizePolicy  	pagenum
IFAPI_FILE_SEARCH_CTX  	pagenum
IFAPI_FIRMWARE_EVENT  	pagenum
IFAPI_GetEsysBlob  	pagenum
IFAPI_GetInfo  	pagenum
IFAPI_GetRandom  	pagenum
IFAPI_HIERARCHY  	pagenum
IFAPI_IFAPI_EVENT_TYPE_ASSIGN  	pagenum
IFAPI_IFAPI_IMA_EVENT_TYPE_ASSIGN  	pagenum
IFAPI_IMA_EVENT  	pagenum
IFAPI_IMA_TEMPLATE  	pagenum
IFAPI_ImportKey  	pagenum
IFAPI_INFO  	pagenum
IFAPI_INFO_CAP  	pagenum
IFAPI_INITIALIZE  	pagenum
IFAPI_IO  	pagenum
IFAPI_KEY  	pagenum
IFAPI_Key_Create  	pagenum
IFAPI_KEY_SEARCH  	pagenum
IFAPI_Key_SetCertificate  	pagenum
IFAPI_Key_Sign  	pagenum
IFAPI_KEY_TEMPLATE  	pagenum
IFAPI_Key_VerifySignature  	pagenum
IFAPI_KEYSTORE  	pagenum
IFAPI_LoadKey  	pagenum
IFAPI_MAX_BUFFER  	pagenum
IFAPI_NV  	pagenum
IFAPI_NV_Cmds  	pagenum
IFAPI_NV_TEMPLATE  	pagenum
IFAPI_OBJECT_UNION  	pagenum
IFAPI_Path_SetDescription  	pagenum
IFAPI_PCR  	pagenum
IFAPI_POLICY_CTX  	pagenum
IFAPI_POLICY_EVAL_INST_CTX  	pagenum
IFAPI_POLICY_EXEC_CB_CTX  	pagenum
IFAPI_POLICY_EXEC_CTX  	pagenum
IFAPI_POLICY_STORE  	pagenum
IFAPI_POLICYUTIL_STACK  	pagenum
IFAPI_PROFILE  	pagenum
IFAPI_PROFILE_ENTRY  	pagenum
IFAPI_PROFILES  	pagenum
IFAPI_Provision  	pagenum
IFAPI_TPMI_POLICYTYPE_ASSIGN  	pagenum
IFAPI_TSS_EVENT  	pagenum
IFAPI_Unseal  	pagenum
object_node  	pagenum
PACKED  	pagenum
POLICY_LIST  	pagenum
policy_object_node  	pagenum
str_node  	pagenum
TCG_EVENT_TYPE_ASSIGN  	pagenum
template_description  	pagenum
template_field  	pagenum
tpm2_eventlog_context  	pagenum
tpm_getekcertificate_ctx  	pagenum
TPMI_POLICYTYPE_ASSIGN  	pagenum
TPML_POLICYAUTHORIZATIONS  	pagenum
TPML_POLICYBRANCHES  	pagenum
TPML_POLICYELEMENTS  	pagenum
TPMS_CEL_VERSION  	pagenum
TPMS_EVENT_CELMGT  	pagenum
TPMS_POLICY  	pagenum
TPMS_POLICYACTION  	pagenum
TPMS_POLICYAUTHORIZATION  	pagenum
TPMS_POLICYAUTHORIZE  	pagenum
TPMS_POLICYAUTHORIZENV  	pagenum
TPMS_POLICYAUTHVALUE  	pagenum
TPMS_POLICYBRANCH  	pagenum
TPMS_POLICYCOMMANDCODE  	pagenum
TPMS_POLICYCOUNTERTIMER  	pagenum
TPMS_POLICYCPHASH  	pagenum
TPMS_POLICYDUPLICATIONSELECT  	pagenum
TPMS_POLICYLOCALITY  	pagenum
TPMS_POLICYNAMEHASH  	pagenum
TPMS_POLICYNV  	pagenum
TPMS_POLICYNVWRITTEN  	pagenum
TPMS_POLICYOR  	pagenum
TPMS_POLICYPASSWORD  	pagenum
TPMS_POLICYPCR  	pagenum
TPMS_POLICYPHYSICALPRESENCE  	pagenum
TPMS_POLICYSECRET  	pagenum
TPMS_POLICYSIGNED  	pagenum
TPMS_POLICYTEMPLATE  	pagenum
TPMT_POLICYELEMENT  	pagenum
TPMU_CELMGT  	pagenum
TPMU_POLICYELEMENT  	pagenum
UINT8_ARY  	pagenum

File Index
File List
Here is a list of all documented files with brief descriptions:
include/tss2/tss2_esys.h  	pagenum
include/tss2/tss2_fapi.h  	pagenum
src/tss2-esys/esys_crypto.h  	pagenum
src/tss2-esys/esys_crypto_mbed.h  	pagenum
src/tss2-esys/esys_crypto_ossl.h  	pagenum
src/tss2-esys/esys_int.h  	pagenum
src/tss2-esys/esys_iutil.h  	pagenum
src/tss2-esys/esys_mu.h  	pagenum
src/tss2-esys/esys_types.h  	pagenum
src/tss2-fapi/efi_event.h  	pagenum
src/tss2-fapi/fapi_certificates.h  	pagenum
src/tss2-fapi/fapi_crypto.h  	pagenum
src/tss2-fapi/fapi_int.h  	pagenum
src/tss2-fapi/fapi_policy.h  	pagenum
src/tss2-fapi/fapi_types.h  	pagenum
src/tss2-fapi/fapi_util.h  	pagenum
src/tss2-fapi/ifapi_config.h  	pagenum
src/tss2-fapi/ifapi_curl.h  	pagenum
src/tss2-fapi/ifapi_eventlog.h  	pagenum
src/tss2-fapi/ifapi_eventlog_system.h  	pagenum
src/tss2-fapi/ifapi_get_intl_cert.h  	pagenum
src/tss2-fapi/ifapi_helpers.h  	pagenum
src/tss2-fapi/ifapi_ima_eventlog.h  	pagenum
src/tss2-fapi/ifapi_io.h  	pagenum
src/tss2-fapi/ifapi_json_deserialize.h  	pagenum
src/tss2-fapi/ifapi_json_eventlog_deserialize.h  	pagenum
src/tss2-fapi/ifapi_json_eventlog_serialize.h  	pagenum
src/tss2-fapi/ifapi_json_serialize.h  	pagenum
src/tss2-fapi/ifapi_keystore.h  	pagenum
src/tss2-fapi/ifapi_macros.h  	pagenum
src/tss2-fapi/ifapi_policy.h  	pagenum
src/tss2-fapi/ifapi_policy_calculate.h  	pagenum
src/tss2-fapi/ifapi_policy_callbacks.h  	pagenum
src/tss2-fapi/ifapi_policy_execute.h  	pagenum
src/tss2-fapi/ifapi_policy_instantiate.h  	pagenum
src/tss2-fapi/ifapi_policy_json_deserialize.h  	pagenum
src/tss2-fapi/ifapi_policy_json_serialize.h  	pagenum
src/tss2-fapi/ifapi_policy_store.h  	pagenum
src/tss2-fapi/ifapi_policy_types.h  	pagenum
src/tss2-fapi/ifapi_policyutil_execute.h  	pagenum
src/tss2-fapi/ifapi_profiles.h  	pagenum
src/tss2-fapi/tpm_json_deserialize.h  	pagenum
src/tss2-fapi/tpm_json_serialize.h  	pagenum

Module Documentation
Enhanced System API
Modules
Esys Context ESYS_CONTEXTEsys Tpm Resource ESYS_TR
Esys TPM Commands
Internals of Enhanced System API

Detailed Description
Enhanced System API (ESAPI) as described in the TSS 2.0 Enhanced System API (ESAPI) Specification. This API is a 1-to-1 mapping of the TPM2 commands documented in Part 3 of the TPM2 specification. Additionally there are asynchronous versions of each command. In addition to SAPI, the ESAPI performs tracking of meta data for TPM object and automatic calculation of session based authorization and encryption values. Both the synchronous and asynchronous API are exposed through a single library: libtss2-esys. 

Esys Context ESYS_CONTEXT
An ESYS_CONTEXT holds tdata for the connection to the TPM as well as the metadata for TPM Resource; such as Transient key, Persistent objects, NV spaces, Sessions or PCRs. 

Esys Tpm Resource ESYS_TR
Modules
Global ESYS_TR objects
Detailed Description
Virtual objects with meta data for Tpm Resources. The Esys TPM Resources are the virtual objects inside the ESYSCONTEXT that hold the metadata for corresponding TPM Resources.
There are a set of global ESYS_TR objects such as ESYS_TR_NON or for the various PCRs and hierarchies. ESYS_TR_MIN_OBJECT denotes the first non-global ESYS_TR object. 

Global ESYS_TR objects
A set of defines for global virtual objects that are always present in every ESYS_CONTEXT. 

Esys TPM Commands
Modules
The ESAPI function for the TPM2_ActivateCredential command.The ESAPI function for the TPM2_Certify command.
The ESAPI function for the TPM2_CertifyCreation command.
The ESAPI function for the TPM2_ChangeEPS command.
The ESAPI function for the TPM2_ChangePPS command.
The ESAPI function for the TPM2_Clear command.
The ESAPI function for the TPM2_ClearControl command.
The ESAPI function for the TPM2_ClockRateAdjust command.
The ESAPI function for the TPM2_ClockSet command.
The ESAPI function for the TPM2_Commit command.
The ESAPI function for the TPM2_ContextLoad command.
The ESAPI function for the TPM2_ContextSave command.
The ESAPI function for the TPM2_Create command.
The ESAPI function for the TPM2_CreatePrimary command.
The ESAPI function for the TPM2_DictionaryAttackLockReset command.
The ESAPI function for the TPM2_DictionaryAttackParameters command.
The ESAPI function for the TPM2_Duplicate command.
The ESAPI function for the TPM2_ECC_Parameters command.
The ESAPI function for the TPM2_ECDH_KeyGen command.
The ESAPI function for the TPM2_ECDH_ZGen command.
The ESAPI function for the TPM2_EC_Ephemeral command.
The ESAPI function for the TPM2_EncryptDecrypt command.
The ESAPI function for the TPM2_EventSequenceComplete command.
The ESAPI function for the TPM2_EvictControl command.
The ESAPI function for the TPM2_FlushContext command.
The ESAPI function for the TPM2_GetCapability command.
The ESAPI function for the TPM2_GetCommandAuditDigest command.
The ESAPI function for the TPM2_GetRandom command.
The ESAPI function for the TPM2_GetSessionAuditDigest command.
The ESAPI function for the TPM2_GetTestResult command.
The ESAPI function for the TPM2_GetTime command.
The ESAPI function for the TPM2_Hash command.
The ESAPI function for the TPM2_HashSequenceStart command.
The ESAPI function for the TPM2_HierarchyChangeAuth command.
The ESAPI function for the TPM2_HierarchyControl command.
The ESAPI function for the TPM2_HMAC command.
The ESAPI function for the TPM2_HMAC_Start command.
The ESAPI function for the TPM2_Import command.
The ESAPI function for the TPM2_IncrementalSelfTest command.
The ESAPI function for the TPM2_Load command.
The ESAPI function for the TPM2_LoadExternal command.
The ESAPI function for the TPM2_MakeCredential command.
The ESAPI function for the TPM2_NV_Certify command.
The ESAPI function for the TPM2_NV_ChangeAuth command.
The ESAPI function for the TPM2_NV_DefineSpace command.
The ESAPI function for the TPM2_NV_Extend command.
The ESAPI function for the TPM2_NV_GlobalWriteLock command.
The ESAPI function for the TPM2_NV_Increment command.
The ESAPI function for the TPM2_NV_Read command.
The ESAPI function for the TPM2_NV_ReadLock command.
The ESAPI function for the TPM2_NV_ReadPublic command.
The ESAPI function for the TPM2_NV_SetBits command.
The ESAPI function for the TPM2_NV_UndefineSpace command.
The ESAPI function for the TPM2_NV_UndefineSpaceSpecial command.
The ESAPI function for the TPM2_NV_Write command.
The ESAPI function for the TPM2_NV_WriteLock command.
The ESAPI function for the TPM2_ObjectChangeAuth command.
The ESAPI function for the TPM2_PCR_Allocate command.
The ESAPI function for the TPM2_PCR_Event command.
The ESAPI function for the TPM2_PCR_Extend command.
The ESAPI function for the TPM2_PCR_Read command.
The ESAPI function for the TPM2_PCR_Reset command.
The ESAPI function for the TPM2_PCR_SetAuthPolicy command.
The ESAPI function for the TPM2_PCR_SetAuthValue command.
The ESAPI function for the TPM2_PolicyAuthorize command.
The ESAPI function for the TPM2_PolicyAuthValue command.
The ESAPI function for the TPM2_PolicyCommandCode command.
The ESAPI function for the TPM2_PolicyCounterTimer command.
The ESAPI function for the TPM2_PolicyCpHash command.
The ESAPI function for the TPM2_PolicyDuplicationSelect command.
The ESAPI function for the TPM2_PolicyGetDigest command.
The ESAPI function for the TPM2_PolicyLocality command.
The ESAPI function for the TPM2_PolicyNameHash command.
The ESAPI function for the TPM2_PolicyNV command.
The ESAPI function for the TPM2_PolicyNvWritten command.
The ESAPI function for the TPM2_PolicyOR command.
The ESAPI function for the TPM2_PolicyPassword command.
The ESAPI function for the TPM2_PolicyPCR command.
The ESAPI function for the TPM2_PolicyPhysicalPresence command.
The ESAPI function for the TPM2_PolicyRestart command.
The ESAPI function for the TPM2_PolicySecret command.
The ESAPI function for the TPM2_PolicySigned command.
The ESAPI function for the TPM2_PolicyTicket command.
The ESAPI function for the TPM2_PP_Commands command.
The ESAPI function for the TPM2_Quote command.
The ESAPI function for the TPM2_ReadClock command.
The ESAPI function for the TPM2_ReadPublic command.
The ESAPI function for the TPM2_Rewrap command.
The ESAPI function for the TPM2_RSA_Decrypt command.
The ESAPI function for the TPM2_RSA_Encrypt command.
The ESAPI function for the TPM2_SelfTest command.
The ESAPI function for the TPM2_SequenceComplete command.
The ESAPI function for the TPM2_SequenceUpdate command.
The ESAPI function for the TPM2_SetAlgorithmSet command.
The ESAPI function for the TPM2_SetCommandCodeAuditStatus command.
The ESAPI function for the TPM2_SetPrimaryPolicy command.
The ESAPI function for the TPM2_Shutdown command.
The ESAPI function for the TPM2_Sign command.
The ESAPI function for the TPM2_StartAuthSession command.
The ESAPI function for the TPM2_Startup command.
The ESAPI function for the TPM2_StirRandom command.
The ESAPI function for the TPM2_TestParms command.
The ESAPI function for the TPM2_Unseal command.
The ESAPI function for the TPM2_Vendor_TCG_Test command.
The ESAPI function for the TPM2_VerifySignature command.
The ESAPI function for the TPM2_ZGen_2Phase command.

Detailed Description
The following function represent interactions with the corresponding TPM commands. 

The ESAPI function for the TPM2_ActivateCredential command.
ESAPI function to invoke the TPM2_ActivateCredential command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Certify command.
ESAPI function to invoke the TPM2_Certify command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_CertifyCreation command.
ESAPI function to invoke the TPM2_CertifyCreation command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ChangeEPS command.
ESAPI function to invoke the TPM2_ChangeEPS command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ChangePPS command.
ESAPI function to invoke the TPM2_ChangePPS command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Clear command.
ESAPI function to invoke the TPM2_Clear command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ClearControl command.
ESAPI function to invoke the TPM2_ClearControl command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ClockRateAdjust command.
ESAPI function to invoke the TPM2_ClockRateAdjust command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ClockSet command.
ESAPI function to invoke the TPM2_ClockSet command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Commit command.
ESAPI function to invoke the TPM2_Commit command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ContextLoad command.
ESAPI function to invoke the TPM2_ContextLoad command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ContextSave command.
ESAPI function to invoke the TPM2_ContextSave command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Create command.
ESAPI function to invoke the TPM2_Create command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_CreatePrimary command.
ESAPI function to invoke the TPM2_CreatePrimary command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_DictionaryAttackLockReset command.
ESAPI function to invoke the TPM2_DictionaryAttackLockReset command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_DictionaryAttackParameters command.
ESAPI function to invoke the TPM2_DictionaryAttackParameters command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Duplicate command.
ESAPI function to invoke the TPM2_Duplicate command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ECC_Parameters command.
ESAPI function to invoke the TPM2_ECC_Parameters command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ECDH_KeyGen command.
ESAPI function to invoke the TPM2_ECDH_KeyGen command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ECDH_ZGen command.
ESAPI function to invoke the TPM2_ECDH_ZGen command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_EC_Ephemeral command.
ESAPI function to invoke the TPM2_EC_Ephemeral command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_EncryptDecrypt command.
ESAPI function to invoke the TPM2_EncryptDecrypt command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_EventSequenceComplete command.
ESAPI function to invoke the TPM2_EventSequenceComplete command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_EvictControl command.
ESAPI function to invoke the TPM2_EvictControl command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_FlushContext command.
ESAPI function to invoke the TPM2_FlushContext command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_GetCapability command.
ESAPI function to invoke the TPM2_GetCapability command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_GetCommandAuditDigest command.
ESAPI function to invoke the TPM2_GetCommandAuditDigest command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_GetRandom command.
ESAPI function to invoke the TPM2_GetRandom command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_GetSessionAuditDigest command.
ESAPI function to invoke the TPM2_GetSessionAuditDigest command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_GetTestResult command.
ESAPI function to invoke the TPM2_GetTestResult command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_GetTime command.
ESAPI function to invoke the TPM2_GetTime command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Hash command.
ESAPI function to invoke the TPM2_Hash command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_HashSequenceStart command.
ESAPI function to invoke the TPM2_HashSequenceStart command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_HierarchyChangeAuth command.
ESAPI function to invoke the TPM2_HierarchyChangeAuth command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_HierarchyControl command.
ESAPI function to invoke the TPM2_HierarchyControl command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_HMAC command.
ESAPI function to invoke the TPM2_HMAC command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_HMAC_Start command.
ESAPI function to invoke the TPM2_HMAC_Start command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Import command.
ESAPI function to invoke the TPM2_Import command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_IncrementalSelfTest command.
ESAPI function to invoke the TPM2_IncrementalSelfTest command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Load command.
ESAPI function to invoke the TPM2_Load command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_LoadExternal command.
ESAPI function to invoke the TPM2_LoadExternal command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_MakeCredential command.
ESAPI function to invoke the TPM2_MakeCredential command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_Certify command.
ESAPI function to invoke the TPM2_NV_Certify command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_ChangeAuth command.
ESAPI function to invoke the TPM2_NV_ChangeAuth command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_DefineSpace command.
ESAPI function to invoke the TPM2_NV_DefineSpace command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_Extend command.
ESAPI function to invoke the TPM2_NV_Extend command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_GlobalWriteLock command.
ESAPI function to invoke the TPM2_NV_GlobalWriteLock command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_Increment command.
ESAPI function to invoke the TPM2_NV_Increment command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_Read command.
ESAPI function to invoke the TPM2_NV_Read command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_ReadLock command.
ESAPI function to invoke the TPM2_NV_ReadLock command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_ReadPublic command.
ESAPI function to invoke the TPM2_NV_ReadPublic command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_SetBits command.
ESAPI function to invoke the TPM2_NV_SetBits command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_UndefineSpace command.
ESAPI function to invoke the TPM2_NV_UndefineSpace command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_UndefineSpaceSpecial command.
ESAPI function to invoke the TPM2_NV_UndefineSpaceSpecial command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_Write command.
ESAPI function to invoke the TPM2_NV_Write command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_NV_WriteLock command.
ESAPI function to invoke the TPM2_NV_WriteLock command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ObjectChangeAuth command.
ESAPI function to invoke the TPM2_ObjectChangeAuth command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PCR_Allocate command.
ESAPI function to invoke the TPM2_PCR_Allocate command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PCR_Event command.
ESAPI function to invoke the TPM2_PCR_Event command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PCR_Extend command.
ESAPI function to invoke the TPM2_PCR_Extend command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PCR_Read command.
ESAPI function to invoke the TPM2_PCR_Read command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PCR_Reset command.
ESAPI function to invoke the TPM2_PCR_Reset command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PCR_SetAuthPolicy command.
ESAPI function to invoke the TPM2_PCR_SetAuthPolicy command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PCR_SetAuthValue command.
ESAPI function to invoke the TPM2_PCR_SetAuthValue command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyAuthorize command.
ESAPI function to invoke the TPM2_PolicyAuthorize command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyAuthValue command.
ESAPI function to invoke the TPM2_PolicyAuthValue command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyCommandCode command.
ESAPI function to invoke the TPM2_PolicyCommandCode command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyCounterTimer command.
ESAPI function to invoke the TPM2_PolicyCounterTimer command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyCpHash command.
ESAPI function to invoke the TPM2_PolicyCpHash command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyDuplicationSelect command.
ESAPI function to invoke the TPM2_PolicyDuplicationSelect command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyGetDigest command.
ESAPI function to invoke the TPM2_PolicyGetDigest command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyLocality command.
ESAPI function to invoke the TPM2_PolicyLocality command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyNameHash command.
ESAPI function to invoke the TPM2_PolicyNameHash command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyNV command.
ESAPI function to invoke the TPM2_PolicyNV command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyNvWritten command.
ESAPI function to invoke the TPM2_PolicyNvWritten command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyOR command.
ESAPI function to invoke the TPM2_PolicyOR command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyPassword command.
ESAPI function to invoke the TPM2_PolicyPassword command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyPCR command.
ESAPI function to invoke the TPM2_PolicyPCR command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyPhysicalPresence command.
ESAPI function to invoke the TPM2_PolicyPhysicalPresence command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyRestart command.
ESAPI function to invoke the TPM2_PolicyRestart command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicySecret command.
ESAPI function to invoke the TPM2_PolicySecret command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicySigned command.
ESAPI function to invoke the TPM2_PolicySigned command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PolicyTicket command.
ESAPI function to invoke the TPM2_PolicyTicket command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_PP_Commands command.
ESAPI function to invoke the TPM2_PP_Commands command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Quote command.
ESAPI function to invoke the TPM2_Quote command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ReadClock command.
ESAPI function to invoke the TPM2_ReadClock command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ReadPublic command.
ESAPI function to invoke the TPM2_ReadPublic command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Rewrap command.
ESAPI function to invoke the TPM2_Rewrap command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_RSA_Decrypt command.
ESAPI function to invoke the TPM2_RSA_Decrypt command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_RSA_Encrypt command.
ESAPI function to invoke the TPM2_RSA_Encrypt command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_SelfTest command.
ESAPI function to invoke the TPM2_SelfTest command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_SequenceComplete command.
ESAPI function to invoke the TPM2_SequenceComplete command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_SequenceUpdate command.
ESAPI function to invoke the TPM2_SequenceUpdate command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_SetAlgorithmSet command.
ESAPI function to invoke the TPM2_SetAlgorithmSet command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_SetCommandCodeAuditStatus command.
ESAPI function to invoke the TPM2_SetCommandCodeAuditStatus command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_SetPrimaryPolicy command.
ESAPI function to invoke the TPM2_SetPrimaryPolicy command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Shutdown command.
ESAPI function to invoke the TPM2_Shutdown command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Sign command.
ESAPI function to invoke the TPM2_Sign command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_StartAuthSession command.
ESAPI function to invoke the TPM2_StartAuthSession command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Startup command.
ESAPI function to invoke the TPM2_Startup command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_StirRandom command.
ESAPI function to invoke the TPM2_StirRandom command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_TestParms command.
ESAPI function to invoke the TPM2_TestParms command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Unseal command.
ESAPI function to invoke the TPM2_Unseal command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_Vendor_TCG_Test command.
ESAPI function to invoke the TPM2_Vendor_TCG_Test command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_VerifySignature command.
ESAPI function to invoke the TPM2_VerifySignature command either as a one-call or in an asynchronous manner. 

The ESAPI function for the TPM2_ZGen_2Phase command.
ESAPI function to invoke the TPM2_ZGen_2Phase command either as a one-call or in an asynchronous manner. 

Internals of Enhanced System API
Modules
Internal ESAPI TypesInternal Cryptographic Backend
Internal ESAPI utility functions.

Detailed Description
This module holds internal APIs of the ESAPI implementation. 

Internal ESAPI Types
Data Structures
struct RSRC_NODE_Tstruct ESYS_CONTEXT
struct IESYS_SESSION
union IESYS_RSRC_UNION
struct IESYS_RESOURCE
struct IESYS_METADATA
struct IESYS_CONTEXT_DATA
Macros
#define _ESYS_MAX_SUBMISSIONS  5
#define _ESYS_ASSERT_NON_NULL(x)
#define IESYSC_KEY_RSRC  1
#define IESYSC_NV_RSRC  2
#define IESYSC_SESSION_RSRC  3
#define IESYSC_WITHOUT_MISC_RSRC  0
#define ENCRYPT  1
#define NO_ENCRYPT  0
#define DECRYPT  1
#define NO_DECRYPT  0
#define POLICY_PASSWORD  2
#define POLICY_AUTH  1
#define NO_POLICY_AUTH  0

Detailed Description
The ESAPI implementation requires a set of internal type definitions. 

Data Structure Documentation
struct RSRC_NODE_T
Linked list type for object meta data.
This structure represents a linked list to store meta data information of type IESYS_RESOURCE. 
Data Fields
ESYS_TR esys_handle
TPM2B_AUTH auth
IESYS_RESOURCE rsrc
struct RSRC_NODE_T * next

Field Documentation
TPM2B_AUTH auth
The authValue for this resource object. 
ESYS_TR esys_handle
The ESYS_TR handle used by the application to reference this entry. 
struct RSRC_NODE_T* next
The next object in the linked list. 
IESYS_RESOURCE rsrc
The meta data for this resource object. 
struct ESYS_CONTEXT
The data structure holding internal state information.
Each ESYS_CONTEXT respresents a logically independent connection to the TPM. It stores meta data information about object in order to calculate session auths and similar things. 
Data Fields
enum _ESYS_STATE state
TSS2_SYS_CONTEXT * sys
ESYS_TR esys_handle_cnt
RSRC_NODE_T * rsrc_list
int32_t timeout
ESYS_TR session_type [3]
RSRC_NODE_T * session_tab [3]
int encryptNonceIdx
TPM2B_NONCE * encryptNonce
int authsCount
int submissionCount
TPM2B_DATA salt
IESYS_CMD_IN_PARAM in
ESYS_TR esys_handle
TSS2_TCTI_CONTEXT * tcti_app_param
void * dlhandle
IESYS_SESSION * enc_session
ESYS_TR sav_session1
ESYS_TR sav_session2
ESYS_TR sav_session3
ESYS_CRYPTO_CALLBACKS crypto_backend

Field Documentation
int authsCount
The number of session provided during the command. 
ESYS_CRYPTO_CALLBACKS crypto_backend
The backend function pointers to use for crypto operations 
void* dlhandle
The handle of dlopen if the tcti was automatically loaded. 
IESYS_SESSION* enc_session
Ptr to the enc param session. Used to restore session attributes 
TPM2B_NONCE* encryptNonce
The nonce of the encrypt session, or NULL if no encrypt session exists. 
int encryptNonceIdx
The index of the encrypt session. 
ESYS_TR esys_handle
Temporary storage for the object's TPM handle during Esys_TR_FromTPMPublic. 
ESYS_TR esys_handle_cnt
The next free ESYS_TR number. 
IESYS_CMD_IN_PARAM in
Temporary storage for Input parameters needed in corresponding _Finish function 
RSRC_NODE_T* rsrc_list
The linked list of all ESYS_TR objects. 
TPM2B_DATA salt
The salt used during a StartAuthSession. 
ESYS_TR sav_session1
Used to store session for cases where call with ESYS_TR_NONE is needed to determine object name 
RSRC_NODE_T* session_tab[3]
The list of TPM session meta data in the current command execution. 
ESYS_TR session_type[3]
The list of TPM session handles in the current command execution. 
enum _ESYS_STATE state
The current state of the ESAPI context. 
int submissionCount
The current number of submissions of this command to the TPM. 
TSS2_SYS_CONTEXT* sys
The SYS context used internally to talk to the TPM. 
TSS2_TCTI_CONTEXT* tcti_app_param
The TCTI context provided by the application during Esys_Initialize() to be returned from Esys_GetTcti(). 
int32_t timeout
The timeout to be used during Tss2_Sys_ExecuteFinish. 
struct IESYS_SESSION
Type for representing TPM-Session 
Data Fields
TPM2B_NAME bound_entity
TPM2B_ENCRYPTED_SECRET encryptedSalt
TPM2B_DATA salt
TPMT_SYM_DEF symmetric
TPMI_ALG_HASH authHash
TPM2B_DIGEST sessionKey
TPM2_SE sessionType
TPMA_SESSION sessionAttributes
TPMA_SESSION origSessionAttributes
TPM2B_NONCE nonceCaller
TPM2B_NONCE nonceTPM
IESYSC_PARAM_ENCRYPT encrypt
IESYSC_PARAM_DECRYPT decrypt
IESYSC_TYPE_POLICY_AUTH type_policy_session
UINT16 sizeSessionValue
BYTE sessionValue [2 *sizeof(TPMU_HA)]
UINT16 sizeHmacValue

Field Documentation
TPMI_ALG_HASH authHash
Hashalg used for authorization 
TPM2B_NAME bound_entity
Entity to which the session is bound 
IESYSC_PARAM_DECRYPT decrypt
Indicate parameter decryption by the TPM 
IESYSC_PARAM_ENCRYPT encrypt
Indicate parameter encryption by the TPM 
TPM2B_ENCRYPTED_SECRET encryptedSalt
Encrypted salt which can be provided by application 
TPM2B_NONCE nonceCaller
Nonce computed by the ESAPI for every session call 
TPM2B_NONCE nonceTPM
Nonce which is returned by the TPM for every session call 
TPMA_SESSION origSessionAttributes
Copy of flags which define the session behaviour 
TPM2B_DATA salt
Salt computed if no encrypted salt is provided 
TPMA_SESSION sessionAttributes
Flags which define the session behaviour 
TPM2B_DIGEST sessionKey
sessionKey used for KDFa to compute symKey 
TPM2_SE sessionType
Type of the session (HMAC, Policy) 
BYTE sessionValue[2 *sizeof(TPMU_HA)]
sessionKey || AuthValue 
UINT16 sizeHmacValue
Size of sessionKey plus optionally authValue 
UINT16 sizeSessionValue
Size of sessionKey plus optionally authValue 
TPMT_SYM_DEF symmetric
Algorithm selection for parameter encryption 
IESYSC_TYPE_POLICY_AUTH type_policy_session
Field to store markers for policy sessions 
union IESYS_RSRC_UNION
Type for representing public info of a TPM-Resource 
Data Fields
TPM2B_PUBLIC rsrc_key_pub
TPM2B_NV_PUBLIC rsrc_nv_pub
IESYS_SESSION rsrc_session
TPMS_EMPTY rsrc_empty

Field Documentation
TPMS_EMPTY rsrc_empty
no specialized date for resource 
TPM2B_PUBLIC rsrc_key_pub
Public info for key objects 
TPM2B_NV_PUBLIC rsrc_nv_pub
Public info for NV ram objects 
IESYS_SESSION rsrc_session
Internal esapi session information 
struct IESYS_RESOURCE
Type for representing TPM-Resource 
Data Fields
TPM2_HANDLE handle
TPM2B_NAME name
IESYSC_RESOURCE_TYPE rsrcType
IESYS_RSRC_UNION misc

Field Documentation
TPM2_HANDLE handle
Handle used by TPM 
IESYS_RSRC_UNION misc
Resource specific information 
TPM2B_NAME name
TPM name of the object 
IESYSC_RESOURCE_TYPE rsrcType
Selector for resource type 
struct IESYS_METADATA
Esys resource with size field 
Data Fields
UINT16 size
IESYS_RESOURCE data

Field Documentation
IESYS_RESOURCE data
Esys resource data 
UINT16 size
size of the operand buffer 
struct IESYS_CONTEXT_DATA
Type for representing ESYS metadata 
Data Fields
UINT32 reserved
TPM2B_CONTEXT_DATA tpmContext
IESYS_METADATA esysMetadata

Field Documentation
IESYS_METADATA esysMetadata
Meta data of the ESY_TR object 
UINT32 reserved
Must allways be zero 
TPM2B_CONTEXT_DATA tpmContext
Context information computed by tpm 

Macro Definition Documentation
#define _ESYS_ASSERT_NON_NULL( x)
Value:    if (x == NULL) { \
        LOG_ERROR(str(x) " == NULL."); \
        return TSS2_ESYS_RC_BAD_REFERENCE; \
    }
Makro testing parameters against null. 
#define _ESYS_MAX_SUBMISSIONS  5
The number of authomatic resubmissions.
The number of resubmissions before a TPM's TPM2_RC_YIELDED is forwarded to the application. 
#define DECRYPT  1
Parameter decryption by TPM 
#define ENCRYPT  1
Parameter encryption by TPM 
#define IESYSC_KEY_RSRC  1
Tag for key resource 
#define IESYSC_NV_RSRC  2
Tag for NV Ram resource 
#define IESYSC_SESSION_RSRC  3
Tag for session resources 
#define IESYSC_WITHOUT_MISC_RSRC  0
Tag for other resources, e.g. PCR register, hierarchies 
#define NO_DECRYPT  0
No parameter decryption by TPM 
#define NO_ENCRYPT  0
No parameter encryption by TPM 
#define NO_POLICY_AUTH  0
no special handling 
#define POLICY_AUTH  1
Marker to include the auth value in the HMAC key 
#define POLICY_PASSWORD  2
Marker to include auth value of the authorized object 

Internal Cryptographic Backend
The types and functions used internally by ESAPI for cryptographic operations. Multiple implementations of these functions may exist for different cryptographic backends. 

Internal ESAPI utility functions.
Data Structures
struct HASH_TAB_ITEM
Detailed Description

Todo:
Description and Documentat of functions

Data Structure Documentation
struct HASH_TAB_ITEM
An entry in a cpHash or rpHash table. 
Data Fields
TPM2_ALG_ID alg
size_t size
uint8_t digest [sizeof(TPMU_HA)]

Field Documentation
TPM2_ALG_ID alg
The hash algorithm. 
uint8_t digest[sizeof(TPMU_HA)]
The digest. 
size_t size
The digest size. 

Testing
Modules
Esys-TestingFor every integration test a function with a name corresponding to the name of the source code file of the test is created: test_esys_<test_name>(ESYS_CONTEXT * esys_context). This function is called by the standard function test_invoke_esapi in every integration test. 
Fapi-Testing
Detailed Description
Description of the test plan. 

Esys-Testing

For every integration test a function with a name corresponding to the name of the source code file of the test is created: test_esys_<test_name>(ESYS_CONTEXT * esys_context). This function is called by the standard function test_invoke_esapi in every integration test. 
For every integration test a function with a name corresponding to the name of the source code file of the test is created: test_esys_<test_name>(ESYS_CONTEXT * esys_context). This function is called by the standard function test_invoke_esapi in every integration test. 
For some tests different test cases can be created with compiler defines to avoid duplicate code in different test cases.The following defines are used and listed in the function's documentation if used:
TEST_ECC Create an ECC key instead of an RSA key.
TEST_SESSION Use session authentication instead of password authentication.
TEST_READ_LOCK Activate test of Esys_NV_ReadLock.
TEST_WRITE_LOCK Activate test of Esys_NV_WriteLock.
TEST_XOR_OBFUSCATION Use xor obfuscation for parameter encryption.
TEST_AES_ENCRYPTION Use AES for parameter encryption.
TEST_BOUND_SESSION Run test with a bound session.

The ESAPI command calls which are used in a test are listed in the function's documentation and are marked according to the PC Client Profile Revision 01.03 v22:
(M) Mandatory
(O) Optional
(F) Commands added after TPM Specification Rev. 1.16 is integrated. 

Fapi-Testing
Testing of FAPI functionality. The tested FAPI functions are listed in each of the testcase functions' descriptions. 

Feature API
Modules
Fapi_InitializeFapi_Finalize
Fapi_GetTcti
Fapi_GetPollHandles
Fapi_Free
Fapi_GetInfo
Fapi_Provision
Fapi_GetPlatformCertificates
Fapi_GetEsysBlobs
Fapi_GetRandom
Fapi_Import
Fapi_List
Fapi_Delete
Fapi_ChangeAuth
Fapi_SetDescription
Fapi_GetDescription
Fapi_SetAppData
Fapi_GetAppData
Fapi_GetTpmBlobs
Fapi_CreateKey
Fapi_Sign
Fapi_VerifySignature
Fapi_Encrypt
Fapi_Decrypt
Fapi_SetCertificate
Fapi_GetCertificate
Fapi_ExportKey
Fapi_CreateSeal
Fapi_Unseal
Fapi_ExportPolicy
Fapi_AuthorizePolicy
Fapi_WriteAuthorizeNv
Fapi_PcrRead
Fapi_PcrExtend
Fapi_Quote
Fapi_VerifyQuote
Fapi_CreateNv
Fapi_NvRead
Fapi_NvWrite
Fapi_NvExtend
Fapi_NvIncrement
Fapi_NvSetBits
Fapi_SetAuthCB
Fapi_SetBranchCB
Fapi_SetSignCB
Internals of Feature API

Detailed Description
Feature API (FAPI) as described in the TSS 2.0 Feature API (FAPI) Specification. This API provides a very abstract view on TPM functionalities most suitable for 80 percent of applications. In mostly uses standard types in its parameter list. Policies are encoded in JSON, whereas most key material is encoded as PEM. Both the synchronous and asynchronous API are exposed through a single library: libtss2-fapi. In order to perform an asynchronous invocation of FAPI functions, the following code serves as a template: do { r = Fapi_GetPollHandles(fc, &ph, &nph); if (r == TSS2_RC_SUCCESS) { poll(ph, nph, -1); Fapi_Free(ph); } r = Fapi_*_Finish(fc, ...); } while (r == TSS2_FAPI_RC_TRY_AGAIN); 

Fapi_Initialize
FAPI functions to invoke Initialize either as one-call or in an asynchronous manner. 

Fapi_Finalize
FAPI function to invoke Finalize. 

Fapi_GetTcti
FAPI function to retrieve the TSS2_TCTI_CONTEXT currently used by the corresponding FAPI_CONTEXT. 

Fapi_GetPollHandles
FAPI function to retrieve the poll handles currently used by the corresponding FAPI_CONTEXT. 

Fapi_Free
FAPI function to invoke Free. 

Fapi_GetInfo
FAPI functions to invoke GetInfo either as one-call or in an asynchronous manner. 

Fapi_Provision
FAPI functions to invoke Provision either as one-call or in an asynchronous manner. 

Fapi_GetPlatformCertificates
FAPI functions to invoke GetPlatformCertificates either as one-call or in an asynchronous manner. 

Fapi_GetEsysBlobs
FAPI functions to invoke GetEsysBlobs either as one-call or in an asynchronous manner. 

Fapi_GetRandom
FAPI functions to invoke GetRandom either as one-call or in an asynchronous manner. 

Fapi_Import
FAPI functions to invoke Import either as one-call or in an asynchronous manner. 

Fapi_List
FAPI functions to invoke List either as one-call or in an asynchronous manner. 

Fapi_Delete
FAPI functions to invoke Delete either as one-call or in an asynchronous manner. 

Fapi_ChangeAuth
FAPI functions to invoke ChangeAuth either as one-call or in an asynchronous manner. 

Fapi_SetDescription
FAPI functions to invoke SetDescription either as one-call or in an asynchronous manner. 

Fapi_GetDescription
FAPI functions to invoke GetDescription either as one-call or in an asynchronous manner. 

Fapi_SetAppData
FAPI functions to invoke SetAppData either as one-call or in an asynchronous manner. 

Fapi_GetAppData
FAPI functions to invoke GetAppData either as one-call or in an asynchronous manner. 

Fapi_GetTpmBlobs
FAPI functions to invoke GetTPMBlobs either as one-call or in an asynchronous manner. 

Fapi_CreateKey
FAPI functions to invoke CreateKey either as one-call or in an asynchronous manner. 

Fapi_Sign
FAPI functions to invoke Sign either as one-call or in an asynchronous manner. 

Fapi_VerifySignature
FAPI functions to invoke VerifySignature either as one-call or in an asynchronous manner. 

Fapi_Encrypt
FAPI functions to invoke Encrypt either as one-call or in an asynchronous manner. 

Fapi_Decrypt
FAPI functions to invoke Decrypt either as one-call or in an asynchronous manner. 

Fapi_SetCertificate
FAPI functions to invoke SetCertificate either as one-call or in an asynchronous manner. 

Fapi_GetCertificate
FAPI functions to invoke GetCertificate either as one-call or in an asynchronous manner. 

Fapi_ExportKey
FAPI functions to invoke ExportKey either as one-call or in an asynchronous manner. 

Fapi_CreateSeal
FAPI functions to invoke CreateSeal either as one-call or in an asynchronous manner. 

Fapi_Unseal
FAPI functions to invoke Unseal either as one-call or in an asynchronous manner. 

Fapi_ExportPolicy
FAPI functions to invoke ExportPolicy either as one-call or in an asynchronous manner. 

Fapi_AuthorizePolicy
FAPI functions to invoke AuthorizePolicy either as one-call or in an asynchronous manner. 

Fapi_WriteAuthorizeNv
FAPI functions to invoke WriteAuthorizeNv either as one-call or in an asynchronous manner. 

Fapi_PcrRead
FAPI functions to invoke PcrRead either as one-call or in an asynchronous manner. 

Fapi_PcrExtend
FAPI functions to invoke PcrExtend either as one-call or in an asynchronous manner. 

Fapi_Quote
FAPI functions to invoke Quote either as one-call or in an asynchronous manner. 

Fapi_VerifyQuote
FAPI functions to invoke VerifyQuote either as one-call or in an asynchronous manner. 

Fapi_CreateNv
FAPI functions to invoke CreateNv either as one-call or in an asynchronous manner. 

Fapi_NvRead
FAPI functions to invoke NvRead either as one-call or in an asynchronous manner. 

Fapi_NvWrite
FAPI functions to invoke NvWrite either as one-call or in an asynchronous manner. 

Fapi_NvExtend
FAPI functions to invoke NvExtend either as one-call or in an asynchronous manner. 

Fapi_NvIncrement
FAPI functions to invoke NvIncrement either as one-call or in an asynchronous manner. 

Fapi_NvSetBits
FAPI functions to invoke NvSetBits either as one-call or in an asynchronous manner. 

Fapi_SetAuthCB
FAPI functions to invoke SetAuthCB. 

Fapi_SetBranchCB
FAPI functions to invoke SetBranchCB. 

Fapi_SetSignCB
FAPI functions to invoke SetSignCB. 

Internals of Feature API
Modules
Internal Cryptographic BackendPolicy instantiation module
Policy calculation module
Policy callback functions.
Policy execution functions.
Policy utilitiy module
Helper functions module
Utility module
Basic IO module
Key store module
Policy store module
Configuration utilities.
Event log utilities.
Profile module
FAPI object serialization module
FAPI object deserialization module
Vendor specific module

Detailed Description
This module holds internal APIs of the FAPI implementation.
Async programming style:
The tss2-fapi implementation uses an asynchronous programming style internally. This means that whenever a piece of code performs a potentially blocking operation it will instead return TSS2_FAPI_RC_TRY_AGAIN (similarly to ESAPI). Then this function is called again once the Poll returns ok. In order to carry the state of execution information over between the different invocation of the same function, the current state is stored in a state variable and all variables are stored in some kind of context variables. On the next entry to the function the state is evaluated using a swtich() statement and execution is resumed.
In order to understand the functional flow of code in FAPI, one can read the functions continuously over all fallthrough; and statecase(); statements. The statecase statements are the re-entry points of each function. The return_try_again() and FAPI_SYNC() statements are the preempt statements. 

Internal Cryptographic Backend
The types and functions used internally by FAPI for cryptographic operations. Multiple implementations of these functions for different cryptographic backends may exist. 

Policy instantiation module
Provides functions for instantiation of the policies. The defaults will be initialized according to the given values. 

Policy calculation module
Provides functions for policy calculation (without TPM). 

Policy callback functions.
Provides internal callbacks functions for policy execution. 

Policy execution functions.
Provides internal functions for policy execution. 

Policy utilitiy module
Provides functions for the execution of policies for object authorization. 

Helper functions module
Provides helper functions. 

Utility module
Provides internal utility functions. 

Basic IO module
Provides internal basic IO functions for policy and key store module. 

Key store module
Provides internal fapi functions for reading and writing to the key store. 

Policy store module
Provides internal fapi functions for reading and writing to the policy store. 

Configuration utilities.
Provides internal fapi functions for deserialization of the configuration data and the initialization of the configuration. 

Event log utilities.
Provides internal fapi functions for the handling of event logs 

Profile module
Provides functions for the handling of profiles stored in the object store. 

FAPI object serialization module
Provides functions for the serialization of FAPI objects to JSON. 

FAPI object deserialization module
Provides functions for the deserialization from JSON to FAPI objects. 

Vendor specific module
Provides functions implementing vendor specific extensions. 

Data Structure Documentation
_IFAPI_CRYPTO_CONTEXT Struct Reference
Data Fields
const EVP_MD * osslHashAlgorithm
EVP_MD_CTX * osslContext
size_t hashSize

Detailed Description
Context to hold temporary values for ifapi_crypto 

Field Documentation
size_t hashSize
The size of the hash's digest 
EVP_MD_CTX* osslContext
The hash engine's context 
const EVP_MD* osslHashAlgorithm
The currently used hash algorithm 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_crypto.c

_IFAPI_OBJECT Struct Reference

#include <ifapi_keystore.h>
Data Fields
TSS2_OBJECT public
TPMS_POLICY * policy
IFAPI_OBJECT_TYPE_CONSTANT objectType
IFAPI_OBJECT_UNION misc
TPMI_YES_NO system
enum IFAPI_AUTHORIZATION_STATE authorization_state
enum IFAPI_IO_STATE state
const char * rel_path

Detailed Description
Type for representing TPM-Resource 

Field Documentation
enum IFAPI_AUTHORIZATION_STATE authorization_state
State of object authorization state machine 
IFAPI_OBJECT_UNION misc
Resource specific information 
IFAPI_OBJECT_TYPE_CONSTANT objectType
Selector for object type 
TSS2_OBJECT public
public fields of an IFAPI_OBJECT 
const char* rel_path
The relative path in keystore. 
TPMI_YES_NO system
Store the object in the system wide directory 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

callback_data Struct Reference
Data Fields
json_object * jso_event_list
const uint32_t * pcr_list
size_t pcr_list_size
bool skip_event
size_t recnum_tab [TPM2_MAX_PCRS]

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_json_eventlog_serialize.h

cb_data Struct Reference
Data Fields
json_object_iter * jso_event_list
const uint32_t * pcr_list
size_t size_of_pcr_list

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_json_eventlog_serialize.c

CurlBufferStruct Struct Reference
Data Fields
unsigned char * buffer
size_t size

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_curl.c

ESYS_CRYPTO_CALLBACKS Struct Reference
Data Fields
ESYS_CRYPTO_PK_RSA_ENCRYPT_FNP rsa_pk_encrypt
ESYS_CRYPTO_HASH_START_FNP hash_start
ESYS_CRYPTO_HASH_UPDATE_FNP hash_update
ESYS_CRYPTO_HASH_FINISH_FNP hash_finish
ESYS_CRYPTO_HASH_ABORT_FNP hash_abort
ESYS_CRYPTO_HMAC_START_FNP hmac_start
ESYS_CRYPTO_HMAC_UPDATE_FNP hmac_update
ESYS_CRYPTO_HMAC_FINISH_FNP hmac_finish
ESYS_CRYPTO_HMAC_ABORT_FNP hmac_abort
ESYS_CRYPTO_GET_RANDOM2B_FNP get_random2b
ESYS_CRYPTO_GET_ECDH_POINT_FNP get_ecdh_point
ESYS_CRYPTO_AES_ENCRYPT_FNP aes_encrypt
ESYS_CRYPTO_AES_DECRYPT_FNP aes_decrypt
ESYS_CRYPTO_INIT_FNP init
void * userdata

The documentation for this struct was generated from the following file:
include/tss2/tss2_esys.h

ESYS_CRYPTO_CONTEXT_BLOB Struct Reference
Public Types
enum { IESYS_CRYPTMBED_TYPE_HASH = 1, IESYS_CRYPTMBED_TYPE_HMAC }
enum { IESYS_CRYPTOSSL_TYPE_HASH = 1, IESYS_CRYPTOSSL_TYPE_HMAC }
Data Fields
enum ESYS_CRYPTO_CONTEXT_BLOB:: { ... }  type
union {
  struct {
    mbedtls_md_context_t mbed_context
    size_t hash_len
  } hash
  struct {
    mbedtls_md_context_t mbed_context
    size_t hmac_len
  } hmac
}; 
enum ESYS_CRYPTO_CONTEXT_BLOB:: { ... }  type
union {
  struct {
    const EVP_MD * ossl_hash_alg
    EVP_MD_CTX * ossl_context
    size_t hash_len
  } hash
}; 

Detailed Description
Context to hold temporary values for iesys_crypto 

Field Documentation
struct  { ... }  hash
the state variables for a hash context 
struct  { ... }  hash
the state variables for a HASH or HMAC context 
struct  { ... }  hmac
the state variables for an hmac context 
enum  { ... }  type
The type of context to hold; hash or hmac 
enum  { ... }  type
The type of context to hold; hash or hmac 

The documentation for this struct was generated from the following files:
src/tss2-esys/esys_crypto_mbed.c
src/tss2-esys/esys_crypto_ossl.c

event_callbacks Struct Reference
Data Fields
TSS2_RC(* init_list_cb )(json_object **jso)
TSS2_RC(* add_header_cb )(size_t recnum, UINT32 pcr, const char *ima_type, UINT8 *digest, size_t digest_size, json_object *jso_list, json_object **jso_current_event)

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_ima_eventlog.c

FAPI_CONTEXT Struct Reference

#include <fapi_int.h>
Data Fields
ESYS_CONTEXT * esys
struct IFAPI_CALLBACKS callbacks
struct IFAPI_IO io
struct IFAPI_EVENTLOG eventlog
struct IFAPI_KEYSTORE keystore
struct IFAPI_POLICY_STORE pstore
struct IFAPI_PROFILES profiles
TPMS_TIME_INFO init_time
enum _FAPI_STATE state
enum _FAPI_STATE_PRIMARY primary_state
enum _FAPI_STATE_SESSION session_state
enum _FAPI_STATE_GET_RANDOM get_random_state
enum IFAPI_HIERACHY_AUTHORIZATION_STATE hierarchy_state
enum IFAPI_HIERACHY_POLICY_AUTHORIZATION_STATE hierarchy_policy_state
enum IFAPI_GET_CERT_STATE get_cert_state
enum _FAPI_FLUSH_STATE flush_object_state
enum IFAPI_CLEANUP_STATE cleanup_state
enum IFAPI_READ_NV_PUBLIC_STATE read_nv_public_state
IFAPI_CONFIG config
UINT32 nv_buffer_max
IFAPI_CMD_STATE cmd
IFAPI_NV_Cmds nv_cmd
IFAPI_GetRandom get_random
IFAPI_CreatePrimary createPrimary
IFAPI_LoadKey loadKey
ESYS_TR session1
ESYS_TR session2
ESYS_TR policy_session
ESYS_TR ek_handle
ESYS_TR srk_handle
TPMI_DH_PERSISTENT ek_persistent
TPMI_DH_PERSISTENT srk_persistent
IFAPI_SESSION_TYPE session_flags
TPMA_SESSION session1_attribute_flags
TPMA_SESSION session2_attribute_flags
IFAPI_MAX_BUFFER aux_data
IFAPI_POLICY_CTX policy
IFAPI_FILE_SEARCH_CTX fsearch
IFAPI_Key_Sign Key_Sign
enum IFAPI_IO_STATE io_state
NODE_OBJECT_T * object_list
IFAPI_OBJECT * duplicate_key
IFAPI_OBJECT * current_auth_object

Detailed Description
The data structure holding internal state information.
Each FAPI_CONTEXT respresents a logically independent connection to the TPM. It stores meta data information about object in order to calculate session auths and similar things. 

Field Documentation
IFAPI_MAX_BUFFER aux_data
tpm2b data to be transferred 
struct IFAPI_CALLBACKS callbacks
Callbacks for user interaction from FAPI 
enum IFAPI_CLEANUP_STATE cleanup_state
The state of cleanup after command execution 
IFAPI_CMD_STATE cmd
The state information of the currently executed command 
IFAPI_CONFIG config
The profile independent configuration data 
IFAPI_OBJECT* duplicate_key
Will be needed for policy execution 
ESYS_CONTEXT* esys
The ESYS context used internally to talk to the TPM. 
enum _FAPI_FLUSH_STATE flush_object_state
The current state of a flush operation 
IFAPI_FILE_SEARCH_CTX fsearch
The context for object search in key/policy store 
enum _FAPI_STATE_GET_RANDOM get_random_state
The current state of get random 
TPMS_TIME_INFO init_time
The current time during FAPI initialization. 
IFAPI_Key_Sign Key_Sign
State information for key signing 
UINT32 nv_buffer_max
The maximal size for transfer of nv buffer content 
IFAPI_POLICY_CTX policy
The context of current policy. 
ESYS_TR policy_session
The policy session used by FAPI 
 
enum _FAPI_STATE_PRIMARY primary_state
The current state of the primary regeneration 
ESYS_TR session1
The first session used by FAPI 
 
ESYS_TR session2
The second session used by FAPI 
 
enum _FAPI_STATE_SESSION session_state
The current state of the session creation 
enum _FAPI_STATE state
The current state of the command execution 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

FAPI_QUOTE_INFO Struct Reference

#include <fapi_int.h>
Data Fields
TPMT_SIG_SCHEME sig_scheme
TPMS_ATTEST attest

Detailed Description
Type for representing a external public key 

Field Documentation
TPMS_ATTEST attest
Attestation data from Quote 
TPMT_SIG_SCHEME sig_scheme
Signature scheme used for quote. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_api_WriteAuthorizeNv Struct Reference

#include <fapi_int.h>
Data Fields
const char * policyPath
TPMI_ALG_HASH * hash_alg
size_t hash_size
size_t digest_idx

Detailed Description
The data structure holding internal state of Fapi_WriteAuthorizeNv. 

Field Documentation
size_t digest_idx
The index of the digest in the policy 
TPMI_ALG_HASH* hash_alg
The hash alg used for digest computation 
size_t hash_size
The digest size 
const char* policyPath
Policy with Policy to be authorized 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_CALLBACKS Struct Reference

#include <fapi_int.h>
Data Fields
Fapi_CB_Auth auth
void * authData
Fapi_CB_Branch branch
void * branchData
Fapi_CB_Sign sign
void * signData
Fapi_CB_PolicyAction action
void * actionData

Detailed Description
Structure holding FAPI callbacks and userData
This structure holds the callback pointers and corresponding userData pointers for each of the three callback types of FAPI. They are set using Fapi_SetAuthCB, Fapi_SetBranchCB and Fapi_SetSignCB. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_CAP_INFO Struct Reference
Data Fields
char * description
TPMS_CAPABILITY_DATA * capability

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_CMD_STATE Union Reference

#include <fapi_int.h>
Data Fields
IFAPI_Provision Provision
IFAPI_Key_Create Key_Create
IFAPI_Key_SetCertificate Key_SetCertificate
IFAPI_Entity_ChangeAuth Entity_ChangeAuth
IFAPI_Entity_Delete Entity_Delete
IFAPI_GetEsysBlob GetEsysBlob
IFAPI_Entities_List Entities_List
IFAPI_Key_VerifySignature Key_VerifySignature
IFAPI_Data_EncryptDecrypt Data_EncryptDecrypt
IFAPI_PCR pcr
IFAPI_INITIALIZE Initialize
IFAPI_Path_SetDescription path_set_info
IFAPI_Fapi_AuthorizePolicy Policy_AuthorizeNewPolicy
IFAPI_api_WriteAuthorizeNv WriteAuthorizeNV
IFAPI_ExportKey ExportKey
IFAPI_ImportKey ImportKey
IFAPI_Unseal Unseal
IFAPI_GetInfo GetInfo
IFAPI_ExportPolicy ExportPolicy

Detailed Description
Union for all input parameters.
The input parameters of a command need to be stored in order to enable resubmission. This type provides the corresponding facilities. 

The documentation for this union was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_CONFIG Struct Reference

#include <ifapi_config.h>
Data Fields
char * profile_dir
char * user_dir
char * keystore_dir
char * profile_name
char * tcti
char * log_dir
TPML_PCR_SELECTION system_pcrs
TPMT_HA ek_fingerprint
char * ek_cert_file
TPMI_YES_NO ek_cert_less
char * intel_cert_service
char * firmware_log_file
char * ima_log_file

Detailed Description
Type for storing FAPI configuration 

Field Documentation
TPMT_HA ek_fingerprint
Fingerprint of EK 
char* intel_cert_service
Certificate service for Intel TPMs 
char* keystore_dir
Directory storing key and NV objects 
char* log_dir
The directory for event logs 
char* profile_dir
Path for profile directory 
char* profile_name
Name the used profile 
TPML_PCR_SELECTION system_pcrs
The PCRs used by IMA etc. 
char* tcti
The used tcti interface 
char* user_dir
Directory storing NV objects 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_config.h

IFAPI_CreatePrimary Struct Reference

#include <fapi_int.h>
Data Fields
char * path
IFAPI_OBJECT hierarchy
IFAPI_OBJECT pkey_object
TPM2B_SENSITIVE_CREATE inSensitive
TPM2B_DATA outsideInfo
TPML_PCR_SELECTION creationPCR
ESYS_TR handle
TPMI_DH_PERSISTENT persistent_handle
TPMS_CAPABILITY_DATA * capabilityData

Detailed Description
The data structure holding internal state of regenerate primary key. 

Field Documentation
IFAPI_OBJECT hierarchy
The current used hierarchy for CreatePrimary 
char* path
Path of the primary (starting with hierarchy) 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_Data_EncryptDecrypt Struct Reference

#include <fapi_int.h>
Data Fields
char const  * keyPath
uint8_t const  * in_data
size_t in_dataSize
IFAPI_OBJECT * key_object
ESYS_TR key_handle
size_t numBytes
size_t decrypt
UINT16 bytesRequested
TPMT_RSA_DECRYPT rsa_scheme
ESYS_TR object_handle
char * policy_path
ESYS_TR auth_session
const IFAPI_PROFILE * profile
uint8_t * plainText
size_t plainTextSize
uint8_t * cipherText
size_t cipherTextSize

Detailed Description
The data structure holding internal state of Fapi_EncryptDecrypt. 

Field Documentation
UINT16 bytesRequested
Bytes currently requested from TPM 
size_t decrypt
Switch whether to encrypt or decrypt 
ESYS_TR key_handle
The ESYS handle of the encryption key 
IFAPI_OBJECT* key_object
The IPAPI object for the encryption key 
char const* keyPath
The implicit key path 
size_t numBytes
The number of bytes of a ESYS request 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_DUPLICATE Struct Reference

#include <ifapi_keystore.h>
Data Fields
TPM2B_PRIVATE duplicate
TPM2B_ENCRYPTED_SECRET encrypted_seed
TPM2B_PUBLIC public
TPM2B_PUBLIC public_parent
char * certificate
TPMS_POLICY * policy

Detailed Description
Type for representing a FAPI object for key duplication. 

Field Documentation
char* certificate
The certificate of the key to be duplicated 
TPM2B_PRIVATE duplicate
The duplicate of the key to export 
TPM2B_ENCRYPTED_SECRET encrypted_seed
Encrypted seed needed for key import 
TPMS_POLICY* policy
The policy of the key to be duplicated 
TPM2B_PUBLIC public
The public information of the key to be duplicated 
TPM2B_PUBLIC public_parent
The public information of the new parent key 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_Entities_List Struct Reference

#include <fapi_int.h>
Data Fields
const char * searchPath

Detailed Description
The data structure holding internal state of list entities. 

Field Documentation
const char* searchPath
The path to searched for objectws 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_Entity_ChangeAuth Struct Reference

#include <fapi_int.h>
Data Fields
const char * entityPath
ESYS_TR handle
IFAPI_OBJECT * key_object
const char * authValue
TPM2B_AUTH newAuthValue
TPM2B_PRIVATE * newPrivate
IFAPI_OBJECT object
IFAPI_OBJECT hiearchy_object
ESYS_TR nv_index
ESYS_TR hierarchy_handle
char ** pathlist
size_t numPaths
size_t numPathsCleanup

Detailed Description
The data structure holding internal state of Fapi_ChangeAuth. 

Field Documentation
const char* authValue
The new auth value 
const char* entityPath
The implicit key path 
ESYS_TR handle
The ESYS handle of the key 
IFAPI_OBJECT hiearchy_object
Used for copying a hierarchy 
 
ESYS_TR hierarchy_handle
NV handle of the hierarchy to be changed 
IFAPI_OBJECT* key_object
The IPAPI object of the key 
TPM2B_AUTH newAuthValue
The new auth value 
TPM2B_PRIVATE* newPrivate
New private data created by parend 
size_t numPaths
Size of array with all keystore objects 
size_t numPathsCleanup
Size of array with all keystore objects 
ESYS_TR nv_index
NV handle of the object to be changed 
IFAPI_OBJECT object
Deserialized NV object or hierarchy 
char** pathlist
The array with all keystore objects 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_Entity_Delete Struct Reference

#include <fapi_int.h>
Data Fields
bool is_key
bool is_persistent_key
ESYS_TR new_object_handle
TPM2_HANDLE permanentHandle
IFAPI_OBJECT auth_object
ESYS_TR auth_index
char * path
IFAPI_OBJECT object
char ** pathlist
size_t numPaths
size_t path_idx

Detailed Description
The data structure holding internal state of entity delete. 

Field Documentation
ESYS_TR auth_index
The ESAPI handle of the nv authorization object 
IFAPI_OBJECT auth_object
Object used for authentication 
bool is_key
Entity to be deleted is a key 
bool is_persistent_key
Entity to be deleted is a key 
size_t numPaths
Size of array with the object files to be deleted 
IFAPI_OBJECT object
Deserialized object 
char* path
The name of the file to be deleted 
size_t path_idx
Index of array with the object files to be deleted 
char** pathlist
The array with the object files to be deleted 
TPM2_HANDLE permanentHandle
The TPM permanent handle 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_EVENT Struct Reference

#include <ifapi_eventlog.h>
Data Fields
UINT32 recnum
TPM2_HANDLE pcr
TPML_DIGEST_VALUES digests
IFAPI_EVENT_TYPE content_type
IFAPI_EVENT_UNION content
bool verify

Detailed Description
Type for representing a FAPI event 

Field Documentation
IFAPI_EVENT_UNION content
The event data 
IFAPI_EVENT_TYPE content_type
Selector for object type 
TPML_DIGEST_VALUES digests
The digest list of the event 
TPM2_HANDLE pcr
PCR register 
UINT32 recnum
Number of event 
bool verify
Switch whether digest can be verified. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog.h

IFAPI_EVENT_TYPE_ASSIGN Struct Reference
Data Fields
IFAPI_EVENT_TYPE in
char * name

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_json_serialize.c

IFAPI_EVENT_UNION Union Reference

#include <ifapi_eventlog.h>
Data Fields
IFAPI_TSS_EVENT tss_event
IFAPI_IMA_EVENT ima_event
IFAPI_FIRMWARE_EVENT firmware_event
TPMS_EVENT_CELMGT cel_event

Detailed Description
Type for representing sub types of FAPI events 

Field Documentation
TPMS_EVENT_CELMGT cel_event
Cononical eventlol management event. 
IFAPI_FIRMWARE_EVENT firmware_event
Firmware event information 
IFAPI_IMA_EVENT ima_event
IMA event information 
IFAPI_TSS_EVENT tss_event
TSS event information 

The documentation for this union was generated from the following file:
src/tss2-fapi/ifapi_eventlog.h

IFAPI_EVENTLOG Struct Reference
Data Fields
enum IFAPI_EVENTLOG_STATE state
char * log_dir
const char * firmware_log_file
const char * ima_log_file
struct IFAPI_EVENT event
TPM2_HANDLE pcrList [TPM2_MAX_PCRS]
size_t pcrListSize
size_t pcrListIdx
json_object * log

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog.h

IFAPI_ExportKey Struct Reference

#include <fapi_int.h>
Data Fields
char const  * pathOfKeyToDuplicate
char const  * pathToPublicKeyOfNewParent
TPM2B_PUBLIC public_parent
IFAPI_OBJECT * key_object
IFAPI_OBJECT export_tree
IFAPI_OBJECT pub_key
IFAPI_OBJECT dup_key
struct TPMS_POLICY policy
ESYS_TR handle_ext_key
char * exportedData

Detailed Description
The data structure holding internal state of export key. 

Field Documentation
IFAPI_OBJECT dup_key
The key to be duplicated or exported 
 
IFAPI_OBJECT export_tree
The complete tree to be exported 
IFAPI_OBJECT* key_object
The IPAPI object of the key to be duplicated 
char const* pathOfKeyToDuplicate
The relative path of the key to be exported 
char const* pathToPublicKeyOfNewParent
The relative path of the new parent 
IFAPI_OBJECT pub_key
The public part of the new parent 
TPM2B_PUBLIC public_parent
The public key of the new parent 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_ExportPolicy Struct Reference

#include <fapi_int.h>
Data Fields
char const  * path
IFAPI_OBJECT object
TPMS_POLICY policy
TPMI_ALG_HASH hashAlg
size_t profile_idx
bool compute_policy

Detailed Description
The data structure holding internal state of export policy. 

Field Documentation
bool compute_policy
Switch whether computation of the policy for the default name hash alg is needed. 
TPMI_ALG_HASH hashAlg
Index of profile used for digest computation. 
IFAPI_OBJECT object
Object corresponding to path 
char const* path
Path of the object with the policy to be exported 
TPMS_POLICY policy
Policy from store be exported 
size_t profile_idx
hashAlg used for policy digest computation. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_EXT_PUB_KEY Struct Reference

#include <ifapi_keystore.h>
Data Fields
char * pem_ext_public
char * certificate
TPM2B_PUBLIC public

Detailed Description
Type for representing a external public key 

Field Documentation
char* certificate
Keys certificate (if any) 
char* pem_ext_public
Public key in PEM format 
TPM2B_PUBLIC public
The pulic information in TPM format 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_Fapi_AuthorizePolicy Struct Reference

#include <fapi_int.h>
Data Fields
const char * policyPath
const char * signingKeyPath
TPM2B_DIGEST policyRef
TPMS_POLICYAUTHORIZATION authorization

Detailed Description
The data structure holding internal state of Fapi_AuthorizePolicy. 

Field Documentation
const char* policyPath
Policy with Policy to be authorized 
const char* signingKeyPath
Key for policy signing 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_FILE_SEARCH_CTX Struct Reference

#include <fapi_int.h>
Data Fields
enum IFAPI_STATE_FILE_SEARCH state
char ** pathlist
size_t path_idx
size_t numPaths
char * current_path

Detailed Description
The data structure holding internal policy state. 

Field Documentation
size_t numPaths
Number of all objects in data store 
size_t path_idx
Index of array of objects to be searched 
char** pathlist
The array of all objects in the search path 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_FIRMWARE_EVENT Struct Reference

#include <ifapi_eventlog_system.h>
Data Fields
UINT32 event_type
UINT8_ARY data

Detailed Description
Firmware event information stored in log 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog_system.h

IFAPI_GetEsysBlob Struct Reference

#include <fapi_int.h>
Data Fields
uint8_t type
uint8_t * data
size_t length
bool is_key
bool is_persistent_key
ESYS_TR new_object_handle
TPM2_HANDLE permanentHandle
IFAPI_OBJECT auth_object
ESYS_TR auth_index
char * path
IFAPI_OBJECT object
IFAPI_OBJECT * key_object

Detailed Description
The data structure holding internal state of esys get blob. 

Field Documentation
ESYS_TR auth_index
The ESAPI handle of the nv authorization object 
IFAPI_OBJECT auth_object
Object used for authentication 
uint8_t* data
data of the blob to be returned 
bool is_key
Object is a key 
bool is_persistent_key
Object is a persistent key 
IFAPI_OBJECT* key_object
Loaded key object 
size_t length
The size of the data to be returned 
IFAPI_OBJECT object
Deserialized object 
char* path
The path of the object 
TPM2_HANDLE permanentHandle
The TPM permanent handle 
uint8_t type
type of blob to be returned 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_GetInfo Struct Reference

#include <fapi_int.h>
Data Fields
TPMS_CAPABILITY_DATA * capability_data
TPMS_CAPABILITY_DATA * fetched_data
size_t idx_info_cap
IFAPI_INFO info_obj
UINT32 property_count
UINT32 property

Detailed Description
The data structure holding internal state of Fapi_GetInfo. 

Field Documentation
TPMS_CAPABILITY_DATA* capability_data
The TPM capability for one property 
TPMS_CAPABILITY_DATA* fetched_data
The data fetched in one TPM command 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_GetRandom Struct Reference

#include <fapi_int.h>
Data Fields
size_t numBytes
size_t idx
UINT16 bytesRequested
uint8_t * data
uint8_t * ret_data

Detailed Description
The data structure holding internal state of Fapi_GetRandom. 

Field Documentation
UINT16 bytesRequested
Byted currently requested from TPM 
uint8_t* data
The buffer for the random data 
size_t idx
Current position in output buffer. 
 
size_t numBytes
The number of random bytes to be generated 
uint8_t* ret_data
The result buffer. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_HIERARCHY Struct Reference

#include <ifapi_keystore.h>
Data Fields
TPMI_YES_NO with_auth
char * description
TPM2B_DIGEST authPolicy
ESYS_TR esysHandle
bool authorized
TPM2B_NAME name

Detailed Description
Type for representing hierarchy 

Field Documentation
bool authorized
Switch whether hiearchy is authorized. 
char* description
Human readable description of hierarchy 
TPM2B_NAME name
Name of the hierarchy 
TPMI_YES_NO with_auth
Authorization provided 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_IFAPI_EVENT_TYPE_ASSIGN Struct Reference
Data Fields
IFAPI_EVENT_TYPE in
char * name

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_json_deserialize.c

IFAPI_IFAPI_IMA_EVENT_TYPE_ASSIGN Struct Reference
Data Fields
IFAPI_IMA_EVENT_TYPE in
char * name

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_ima_eventlog.c

IFAPI_IMA_EVENT Struct Reference

#include <ifapi_ima_eventlog.h>
Data Fields
IFAPI_IMA_EVENT_TYPE template_name
UINT8_ARY template_value

Detailed Description
IMA event information 

Field Documentation
UINT8_ARY template_value
The value to be hashed. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_ima_eventlog.h

IFAPI_IMA_TEMPLATE Struct Reference
Data Fields
struct {
  UINT32 pcr
  UINT8 digest [TPM2_SHA512_DIGEST_SIZE+sizeof(UINT32)+3]
} header
UINT32 ima_type_size
size_t hash_size
TPMI_ALG_HASH hash_alg
char ima_type [TCG_EVENT_NAME_LEN_MAX+1]
char * name
UINT32 event_size
UINT8 * event_buffer

Field Documentation
UINT8* event_buffer
The data after header and name 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_ima_eventlog.h

IFAPI_ImportKey Struct Reference

#include <fapi_int.h>
Data Fields
IFAPI_OBJECT object
TPM2B_NAME parent_name
IFAPI_OBJECT * parent_object
IFAPI_OBJECT new_object
char * parent_path
char * out_path
TPM2B_PRIVATE * private
char * jso_string
const IFAPI_PROFILE * profile

Detailed Description
The data structure holding internal state of import key. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_INFO Struct Reference
Data Fields
char * fapi_version
IFAPI_CONFIG fapi_config
IFAPI_CAP_INFO cap [IFAPI_MAX_CAP_INFO]

Field Documentation
IFAPI_CONFIG fapi_config
The configuration information 
char* fapi_version
The version string of FAPI 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_INFO_CAP Struct Reference
Data Fields
char * description
TPMI_POLICYTYPE capability
UINT32 property
UINT32 max

The documentation for this struct was generated from the following file:
src/tss2-fapi/api/Fapi_GetInfo.c

IFAPI_INITIALIZE Struct Reference

#include <fapi_int.h>
Data Fields
TPMS_CAPABILITY_DATA * capability
char ** pathlist
size_t numPaths
size_t numNullPrimaries
size_t primary_idx
size_t path_idx
IFAPI_OBJECT * null_primaries

Detailed Description
The data structure holding internal state of Fapi_Initialize command. 

Field Documentation
IFAPI_OBJECT* null_primaries
Array of the NULL hierarchy primaries. 
size_t numNullPrimaries
Number of NULL hierarchy primaries stored in keystore 
size_t numPaths
Size of array with all keystore objects 
size_t path_idx
Index of array with the object paths 
char** pathlist
The array with all keystore objects 
size_t primary_idx
Index to the current primary 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_IO Struct Reference
Data Fields
FILE * stream
short pollevents
const char * char_buffer
char * char_rbuffer
size_t buffer_length
size_t buffer_idx

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_io.h

IFAPI_KEY Struct Reference

#include <ifapi_keystore.h>
Data Fields
UINT32 persistent_handle
TPM2B_PUBLIC public
UINT8_ARY serialization
UINT8_ARY private
char * policyInstance
TPM2B_DIGEST creationHash
TPM2B_CREATION_DATA creationData
TPMT_TK_CREATION creationTicket
char * description
UINT8_ARY appData
char * certificate
TPMT_SIG_SCHEME signing_scheme
TPM2B_NAME name
TPMI_YES_NO with_auth
UINT32 reset_count
TPMI_YES_NO delete_prohibited
TPMI_YES_NO ek_profile
TPM2B_DIGEST nonce

Detailed Description
Type for representing a FAPI key 

Field Documentation
UINT8_ARY appData
Application data 
char* certificate
Keys certificate (if any) 
TPM2B_CREATION_DATA creationData
None 
TPM2B_DIGEST creationHash
Hash create by Create or CreatePrimary 
TPMT_TK_CREATION creationTicket
None 
TPMI_YES_NO delete_prohibited
Persistent object should not be deleted. 
 
char* description
Human readable description of key 
TPMI_YES_NO ek_profile
Has to be set if EK is created according to EK credential profile: 
TPM2B_NAME name
Name of the key 
TPM2B_DIGEST nonce
Nonce used to initialize uniqe data 
UINT32 persistent_handle
Persistent TPM Handle 
char* policyInstance
Keys policy 
UINT8_ARY private
None 
TPM2B_PUBLIC public
The wrapped public portion of the object 
UINT32 reset_count
The TPM reset count during key creation 
UINT8_ARY serialization
None 
TPMT_SIG_SCHEME signing_scheme
Signing scheme for the key 
TPMI_YES_NO with_auth
Authorization provided during creation 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_Key_Create Struct Reference

#include <fapi_int.h>
Data Fields
enum IFAPI_KEY_CREATE_STATE state
const char * keyPath
NODE_STR_T * path_list
IFAPI_OBJECT parent
IFAPI_OBJECT object
IFAPI_KEY_TEMPLATE public_templ
TPM2B_PUBLIC public
IFAPI_OBJECT hierarchy
TPM2B_SENSITIVE_CREATE inSensitive
TPM2B_DATA outsideInfo
TPML_PCR_SELECTION creationPCR
ESYS_TR handle
const char * authValue
const char * policyPath
const IFAPI_PROFILE * profile
bool gen_sensitive_random

Detailed Description
The data structure holding internal state of Fapi_CreateKey. 

Field Documentation
bool gen_sensitive_random
Switch whether sensitive ransom data has to be created. 
IFAPI_OBJECT hierarchy
The current used hierarchy for CreatePrimary 
const char* keyPath
The pathname from the application 
IFAPI_OBJECT object
The current object. 
IFAPI_OBJECT parent
The parent of the key for used for creation. 
NODE_STR_T* path_list
The computed explicit path 
TPM2B_PUBLIC public
The public data of the key 
IFAPI_KEY_TEMPLATE public_templ
The template for the keys public data 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_KEY_SEARCH Struct Reference

#include <ifapi_keystore.h>
Data Fields
size_t path_idx
size_t numPaths
char ** pathlist
enum FAPI_SEARCH_STATE state

Detailed Description
The data structure holding internal state for key searching. 

Field Documentation
size_t numPaths
Number of all objects in data store 
size_t path_idx
Index of array of objects to be searched 
char** pathlist
The array of all objects in the search path 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_Key_SetCertificate Struct Reference

#include <fapi_int.h>
Data Fields
const char * pem_cert
char * pem_cert_dup
const char * key_path
NODE_STR_T * path_list
IFAPI_OBJECT key_object

Detailed Description
The data structure holding internal state of Fapi_Key_Setcertificate. 

Field Documentation
IFAPI_OBJECT key_object
The IPAPI object for the certified key 
const char* key_path
The absolute key path 
NODE_STR_T* path_list
The computed explicit path 
const char* pem_cert
The certifificate in pem or format 
char* pem_cert_dup
The allocate certifificate 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_Key_Sign Struct Reference

#include <fapi_int.h>
Data Fields
enum FAPI_SIGN_STATE state
const char * keyPath
ESYS_TR handle
TPM2B_DIGEST digest
TPMT_SIG_SCHEME scheme
IFAPI_OBJECT * key_object
TPMT_SIGNATURE * tpm_signature
TPMI_YES_NO decrypt
TPMT_SIGNATURE * signature
char const  * padding
char * certificate
uint8_t * ret_signature
size_t signatureSize
char * publicKey

Detailed Description
The data structure holding internal state of Fapi_Sign. 

Field Documentation
char* certificate
Certificate of the signing key. 
TPMI_YES_NO decrypt
Switch for symmetric algs 
TPM2B_DIGEST digest
The digest to be signed 
ESYS_TR handle
The ESYS handle of the signing key 
IFAPI_OBJECT* key_object
The IPAPI object of the signing key 
const char* keyPath
The implicit key path 
char const* padding
Optional padding parameter for key sign. 
char* publicKey
Public key of the signing key. 
uint8_t* ret_signature
Result signature 
TPMT_SIG_SCHEME scheme
The signature scheme from profile 
TPMT_SIGNATURE* signature
Produced TPM singature 
enum FAPI_SIGN_STATE state
The state of the signing operation 
TPMT_SIGNATURE* tpm_signature
The signature in TPM format 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_KEY_TEMPLATE Struct Reference

#include <fapi_int.h>
Data Fields
TPMI_YES_NO system
TPMI_YES_NO persistent
UINT32 persistent_handle
TPM2B_PUBLIC public

Detailed Description
Type for representing FAPI template for keys 

Field Documentation
TPMI_YES_NO persistent
Store key persistent in NV ram. 
UINT32 persistent_handle
< Persistent handle which should be used 
TPM2B_PUBLIC public
Template for public data 
TPMI_YES_NO system
Store the object in the system wide directory 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_Key_VerifySignature Struct Reference

#include <fapi_int.h>
Data Fields
const char * keyPath
uint8_t const  * signature
size_t signatureSize
uint8_t const  * digest
size_t digestSize
IFAPI_OBJECT key_object

Detailed Description
The data structure holding internal state of key verify signature. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_KEYSTORE Struct Reference
Data Fields
char * systemdir
char * userdir
char * defaultprofile
IFAPI_KEY_SEARCH key_search
const char * rel_path

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_LoadKey Struct Reference

#include <fapi_int.h>
Data Fields
enum _FAPI_STATE_LOAD_KEY state
enum _FAPI_STATE_PREPARE_LOAD_KEY prepare_state
NODE_STR_T * path_list
NODE_OBJECT_T * key_list
IFAPI_OBJECT auth_object
size_t position
ESYS_TR handle
ESYS_TR parent_handle
bool parent_handle_persistent
IFAPI_OBJECT * key_object
char * key_path
char const  * path

Detailed Description
The data structure holding internal state of loading keys. 

Field Documentation
NODE_STR_T* path_list
The current used hierarchy for CreatePrimary 
enum _FAPI_STATE_LOAD_KEY state
The current state of key loading 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_MAX_BUFFER Struct Reference
Data Fields
UINT16 size
BYTE buffer [IFAPI_MAX_BUFFER_SIZE]

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_NV Struct Reference

#include <ifapi_keystore.h>
Data Fields
TPM2B_NV_PUBLIC public
UINT8_ARY serialization
UINT32 hierarchy
char * policyInstance
char * description
UINT8_ARY appData
TPMI_YES_NO with_auth
char * event_log

Detailed Description
Type for representing a FAPI NV object 

Field Documentation
UINT8_ARY appData
Application data 
char* description
Human readable description of key 
char* event_log
The event log if NV type is pcr 
UINT32 hierarchy
The hierarchy used for NV object creation 
char* policyInstance
Keys policy 
TPM2B_NV_PUBLIC public
The wrapped public portion of the object 
UINT8_ARY serialization
None 
TPMI_YES_NO with_auth
Authorization provided during creation 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_NV_Cmds Struct Reference

#include <fapi_int.h>
Data Fields
char * nvPath
char * policyPath
TPM2B_NV_PUBLIC public
ESYS_TR esys_auth_handle
ESYS_TR esys_handle
TPM2_HANDLE tpm_handle
size_t numBytes
UINT16 bytesRequested
UINT16 offset
size_t data_idx
const uint8_t * data
uint8_t * rdata
size_t size
IFAPI_OBJECT auth_object
IFAPI_OBJECT nv_object
TPM2B_AUTH auth
IFAPI_NV nv_obj
ESYS_TR auth_index
uint64_t bitmap
IFAPI_NV_TEMPLATE public_templ
enum _FAPI_STATE_NV_READ nv_read_state
enum _FAPI_STATE_NV_WRITE nv_write_state
uint8_t * write_data
char * logData
json_object * jso_event_log
TPMI_RH_NV_INDEX maxNvIndex
IFAPI_EVENT pcr_event
TPML_DIGEST_VALUES digests
bool skip_policy_computation

Detailed Description
The data structure holding internal state of Fapi NV commands. 

Field Documentation
TPM2B_AUTH auth
The Password 
ESYS_TR auth_index
The ESAPI handle of the authorization object 
IFAPI_OBJECT auth_object
Object used for authentication 
uint64_t bitmap
The bitmask for the SetBits command 
UINT16 bytesRequested
Bytes currently requested from TPM 
const uint8_t* data
Buffer for data to be written 
size_t data_idx
Offset in the read buffer 
TPML_DIGEST_VALUES digests
Digest for the event data of an extend 
ESYS_TR esys_auth_handle
The ESAPI handle for the NV auth object 
ESYS_TR esys_handle
The ESAPI handle for the NV object 
json_object* jso_event_log
logData in JSON format 
char* logData
The event log for NV objects of type pcr 
TPMI_RH_NV_INDEX maxNvIndex
Max index for search for free index 
 
size_t numBytes
The number of bytes of a ESYS request 
IFAPI_NV nv_obj
The NV Object 
IFAPI_OBJECT nv_object
Deserialized NV object 
enum _FAPI_STATE_NV_READ nv_read_state
The current state of NV read 
enum _FAPI_STATE_NV_WRITE nv_write_state
The current state of NV write 
char* nvPath
The name of the file for object serialization 
UINT16 offset
Offset in TPM memory TPM 
IFAPI_EVENT pcr_event
Event to be added to log 
char* policyPath
The name of the policy file 
TPM2B_NV_PUBLIC public
The public info of the NV object. 
IFAPI_NV_TEMPLATE public_templ
The template for nv creation, adjusted appropriate by the passed flags 
uint8_t* rdata
Buffer for data to be read 
size_t size
size of rdata 
bool skip_policy_computation
switch whether policy needs to be computed 
TPM2_HANDLE tpm_handle
The TPM nv index 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_NV_TEMPLATE Struct Reference

#include <fapi_int.h>
Data Fields
TPMI_YES_NO system
TPMI_RH_HIERARCHY hierarchy
char * description
TPMS_NV_PUBLIC public

Detailed Description
Type for representing template for NV objects 

Field Documentation
char* description
Description of template. 
TPMI_RH_HIERARCHY hierarchy
Hierarchy for NV object. 
TPMS_NV_PUBLIC public
Template for public data 
TPMI_YES_NO system
Store the object in the system wide directory 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_OBJECT_UNION Union Reference

#include <ifapi_keystore.h>
Data Fields
IFAPI_EXT_PUB_KEY ext_pub_key
IFAPI_KEY key
IFAPI_NV nv
IFAPI_DUPLICATE key_tree
IFAPI_HIERARCHY hierarchy

Detailed Description
type for representing public info of a TPM-Resource 

Field Documentation
IFAPI_EXT_PUB_KEY ext_pub_key
Public info for external key. 
IFAPI_HIERARCHY hierarchy
Information related to hierarchies 
IFAPI_KEY key
Public info for key objects 
IFAPI_DUPLICATE key_tree
Information for key duplication 
IFAPI_NV nv
Public info for NV ram objects 

The documentation for this union was generated from the following file:
src/tss2-fapi/ifapi_keystore.h

IFAPI_Path_SetDescription Struct Reference

#include <fapi_int.h>
Data Fields
char * description
UINT8_ARY appData
IFAPI_OBJECT object
char * object_path
json_object * jso
char * jso_string

Detailed Description
The data structure holding internal state of Fapi_SetDescription. 

Field Documentation
UINT8_ARY appData
Application data to be stored in object store. 
char* description
The description of the object 
json_object* jso
JSON object for storing the AppData 
char* jso_string
JSON deserialized buffer 
IFAPI_OBJECT object
The IPAPI object to store the info 
char* object_path
The realative path to the object 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_PCR Struct Reference

#include <fapi_int.h>
Data Fields
TPML_DIGEST_VALUES digest_list
TPML_DIGEST_VALUES * event_digests
ESYS_TR PCR
TPML_PCR_SELECTION pcr_selection
TPML_PCR_SELECTION * pcr_selection_out
UINT32 update_count
TPML_DIGEST * pcrValues
TPM2_HANDLE pcrIndex
TPMI_ALG_HASH hashAlg
const char * keyPath
ESYS_TR handle
IFAPI_OBJECT * key_object
TPMS_CAPABILITY_DATA * capabilityData
uint32_t * pcrList
size_t pcrListSize
TPM2B_DATA qualifyingData
uint8_t const  * eventData
TPM2B_EVENT event
size_t eventDataSize
uint32_t const  * hashAlgs
uint32_t * hashAlgs2
size_t numHashAlgs
char const  * quoteInfo
TPM2B_ATTEST * tpm_quoted
TPMT_SIGNATURE * tpm_signature
uint8_t * signature
size_t signatureSize
char const  * logData
char * pcrLog
IFAPI_EVENT pcr_event
json_object * event_list
FAPI_QUOTE_INFO fapi_quote_info
uint8_t * pcrValue
size_t pcrValueSize
char * event_log_file

Detailed Description
The data structure holding internal state of Fapi_PCR commands. 

Field Documentation
TPML_DIGEST_VALUES digest_list
The digest list computed for the event 
 
TPML_DIGEST_VALUES* event_digests
The digest list computed by TPM2_Event 
 
ESYS_TR handle
The ESYS handle of the signing key 
IFAPI_OBJECT* key_object
The IPAPI object of the signing key 
const char* keyPath
The implicit key path for PCR_Quote 
ESYS_TR PCR
The handle of the PCR register to be extended 
TPML_PCR_SELECTION pcr_selection
Selection used for Read and Quote 
TPML_PCR_SELECTION* pcr_selection_out
Selection returned by PCR_Read 
 
uint32_t* pcrList
Array of PCR numbers 
size_t pcrListSize
Size of PCR array 
TPM2B_DATA qualifyingData
Nonce for quote command 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_POLICY_CTX Struct Reference

#include <fapi_int.h>
Data Fields
enum IFAPI_STATE_POLICY state
struct TPMS_POLICY policy
size_t digest_idx
size_t hash_size
char ** pathlist
TPMI_ALG_HASH hash_alg
IFAPI_POLICY_EXEC_CTX * policy_stack
IFAPI_POLICYUTIL_STACK * util_current_policy
IFAPI_POLICYUTIL_STACK * policyutil_stack
ESYS_TR session
enum FAPI_CREATE_SESSION_STATE create_session_state
char * path
IFAPI_POLICY_EVAL_INST_CTX eval_ctx

Detailed Description
The data structure holding internal policy state. 

Field Documentation
char** pathlist
The array of all objects in the search path 
IFAPI_POLICY_EXEC_CTX* policy_stack
The stack used for storing current policy information. e.g. for retry the current index of policy elements hash to be stored. 
IFAPI_POLICYUTIL_STACK* policyutil_stack
The stack used for storing current policy information. e.g. for retry the current index of policy elements hash to be stored. 
ESYS_TR session
Auxiliary variable to store created policy session. The value will also be stored in the policy stack 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_POLICY_EVAL_INST_CTX Struct Reference

#include <ifapi_policy_instantiate.h>
Data Fields
TPMS_POLICY * policy
NODE_OBJECT_T * policy_elements
TSS2_POLICY_CALC_CALLBACKS callbacks

Detailed Description
Type for representing the context for policy instantiation. 

Field Documentation
TSS2_POLICY_CALC_CALLBACKS callbacks
The policy elements to be instantiated 
TPMS_POLICY* policy
The policy to be instantiated 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_instantiate.h

IFAPI_POLICY_EXEC_CB_CTX Struct Reference

#include <ifapi_policy_callbacks.h>
Data Fields
enum IFAPI_STATE_POL_CB_EXCECUTE cb_state
char * object_path
IFAPI_OBJECT object
ESYS_TR key_handle
ESYS_TR nv_index
ESYS_TR auth_index
ESYS_TR flush_handle
IFAPI_OBJECT auth_object
IFAPI_LoadKey load_ctx_sav
IFAPI_LoadKey load_ctx
IFAPI_CreatePrimary create_primary_ctx_sav
IFAPI_CreatePrimary create_primary_ctx
IFAPI_OBJECT * key_object_ptr
IFAPI_OBJECT * auth_object_ptr
IFAPI_NV_Cmds nv_cmd_state
IFAPI_NV_Cmds nv_cmd_state_sav
TPM2B_DIGEST policy_digest
ESYS_TR session
TPMS_POLICY * policy

Detailed Description
The context of the policy execution 

Field Documentation
ESYS_TR auth_index
Index of authorization object 
IFAPI_OBJECT auth_object
FAPI auth object needed for authorization 
enum IFAPI_STATE_POL_CB_EXCECUTE cb_state
The execution state of the current policy callback 
ESYS_TR flush_handle
Handle which has to be flushed after policy execution 
ESYS_TR key_handle
Handle of a used key 
IFAPI_NV_Cmds nv_cmd_state_sav
backup for state of fapi nv commands 
ESYS_TR nv_index
Index of nv object storing a policy 
IFAPI_OBJECT object
Object to be authorized 
char* object_path
The pathname determined by object search 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_callbacks.h

IFAPI_POLICY_EXEC_CTX Struct Reference

#include <ifapi_policy_execute.h>
Data Fields
enum IFAPI_STATE_POLICY_EXCECUTE state
TPML_DIGEST digest_list
IFAPI_POLICY_EXEC_CTX * next
IFAPI_POLICY_EXEC_CTX * prev
ESYS_TR session
TPMS_POLICY * policy
ESYS_TR policySessionSav
ESYS_TR object_handle
ESYS_TR nv_index
ESYS_TR auth_handle
IFAPI_OBJECT auth_objectNV
IFAPI_OBJECT * auth_object
ESYS_TR auth_session
TPMI_ALG_HASH hash_alg
void * app_data
NODE_OBJECT_T * policy_elements
TPM2B_DIGEST * nonceTPM
uint8_t * buffer
size_t buffer_size
TPM2B_NAME name
char * pem_key
struct POLICY_LIST * policy_list
bool flush_handle
TSS2_POLICY_EXEC_CALLBACKS callbacks

Detailed Description
The context of the policy execution 

Field Documentation
void* app_data
Application data for policy execution callbacks 
IFAPI_OBJECT* auth_object
Object to be authorized 
IFAPI_OBJECT auth_objectNV
Object used for NV authentication 
TSS2_POLICY_EXEC_CALLBACKS callbacks
callbacks used for execution of sub policies and actions which require access to the FAPI context. 
bool flush_handle
Handle to be flushed after policy execution 
IFAPI_POLICY_EXEC_CTX* next
The digest list of policy or Pointer to next policy 
char* pem_key
Pem key recreated during policy execution 
NODE_OBJECT_T* policy_elements
The policy elements to be executed 
struct POLICY_LIST* policy_list
List of policies for authorization selection 
ESYS_TR policySessionSav
Backup policy session 
IFAPI_POLICY_EXEC_CTX* prev
Pointer to previous policy 
ESYS_TR session
The current policy session 
enum IFAPI_STATE_POLICY_EXCECUTE state
The execution state of the current policy command 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_execute.h

IFAPI_POLICY_STORE Struct Reference
Data Fields
char * policydir

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_store.h

IFAPI_POLICYUTIL_STACK Struct Reference

#include <ifapi_policyutil_execute.h>
Data Fields
ESYS_TR policy_session
IFAPI_POLICY_EXEC_CTX * pol_exec_ctx
enum IFAPI_STATE_POLICY_UTIL_EXEC state
IFAPI_POLICYUTIL_STACK * next
IFAPI_POLICYUTIL_STACK * prev

Detailed Description
The context of the policy execution 

Field Documentation
IFAPI_POLICYUTIL_STACK* next
Pointer to next policy 
IFAPI_POLICY_EXEC_CTX* pol_exec_ctx
The execution context for the current policy 
ESYS_TR policy_session
The policy session created for the current evaluation 
 
IFAPI_POLICYUTIL_STACK* prev
Pointer to previous policy 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policyutil_execute.h

IFAPI_PROFILE Struct Reference

#include <ifapi_profiles.h>
Data Fields
TPMI_ALG_PUBLIC type
char * srk_template
char * ek_template
char * srk_description
char * ek_description
TPMT_SIG_SCHEME ecc_signing_scheme
TPMT_SIG_SCHEME rsa_signing_scheme
TPMT_RSA_DECRYPT rsa_decrypt_scheme
TPMI_ALG_CIPHER_MODE sym_mode
TPMT_SYM_DEF_OBJECT sym_parameters
UINT16 sym_block_size
TPML_PCR_SELECTION pcr_selection
TPMI_ALG_HASH nameAlg
TPMI_RSA_KEY_BITS keyBits
UINT32 exponent
TPMI_ECC_CURVE curveID
TPMT_SYM_DEF session_symmetric
TPMS_POLICY * eh_policy
TPMS_POLICY * sh_policy
TPMS_POLICY * ek_policy
TPMS_POLICY * srk_policy
TPMS_POLICY * lockout_policy
UINT32 newMaxTries
UINT32 newRecoveryTime
UINT32 lockoutRecovery
TPMI_YES_NO ignore_ek_template

Detailed Description
Internal structure for FAPI profiles 

Field Documentation
TPMT_SIG_SCHEME ecc_signing_scheme
Signing scheme for the ECC key. 
char* ek_description
EK description 
char* ek_template
EK template 
TPML_PCR_SELECTION pcr_selection
Parameters for symmectric encryption. 
TPMT_RSA_DECRYPT rsa_decrypt_scheme
Decrypt scheme for the RSA key. 
TPMT_SIG_SCHEME rsa_signing_scheme
Signing scheme for the RSA key. 
char* srk_description
SRK description 
char* srk_template
SRK template 
UINT16 sym_block_size
Block size for symmectric encryption. 
TPMI_ALG_CIPHER_MODE sym_mode
Mode for symmectric encryption. 
TPMT_SYM_DEF_OBJECT sym_parameters
Parameters for symmectric encryption. 
TPMI_ALG_PUBLIC type
The algorithm used for key creation 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_profiles.h

IFAPI_PROFILE_ENTRY Struct Reference
Data Fields
char * name
struct IFAPI_PROFILE profile

Field Documentation
char* name
Name of a profile 
struct IFAPI_PROFILE profile
Values for a profile 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_profiles.h

IFAPI_PROFILES Struct Reference
Data Fields
char * default_name
struct IFAPI_PROFILE default_profile
struct IFAPI_PROFILE_ENTRY * profiles
char ** filenames
size_t num_profiles
size_t profiles_idx

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_profiles.h

IFAPI_Provision Struct Reference

#include <fapi_int.h>
Data Fields
IFAPI_OBJECT hierarchy_lockout
IFAPI_OBJECT hierarchy_hs
IFAPI_OBJECT hierarchy_he
IFAPI_OBJECT hierarchy_hn
IFAPI_OBJECT * hierarchy
TPMS_POLICY * hierarchy_policy
IFAPI_KEY_TEMPLATE public_templ
TPM2B_PUBLIC public
char ** pathlist
size_t numPaths
size_t numHierarchyObjects
size_t hiearchy_idx
size_t path_idx
IFAPI_OBJECT * hierarchies
TPM2B_SENSITIVE_CREATE inSensitive
TPM2B_DATA outsideInfo
TPML_PCR_SELECTION creationPCR
ESYS_TR handle
const char * authValueLockout
const char * authValueEh
const char * policyPathEh
const char * authValueSh
const char * policyPathSh
size_t digest_idx
size_t hash_size
TPM2_HANDLE cert_nv_idx
TPM2B_NV_PUBLIC * nvPublic
ESYS_TR esys_nv_cert_handle
char * pem_cert
TPM2_ALG_ID cert_key_type
size_t cert_count
size_t cert_idx
TPMS_CAPABILITY_DATA * capabilityData
IFAPI_OBJECT hierarchy_object
TPM2B_AUTH hierarchy_auth
TPM2B_DIGEST policy_digest
char * intermed_crt
char * root_crt
TPMA_PERMANENT auth_state
ESYS_TR srk_esys_handle
ESYS_TR ek_esys_handle
ESYS_TR srk_tpm_handle
ESYS_TR ek_tpm_handle
bool srk_exists
TPM2_HANDLE template_nv_index
TPM2_HANDLE nonce_nv_index

Detailed Description
The data structure holding internal state of Provisioning. 

Field Documentation
size_t hiearchy_idx
Index to the current hierarchy 
IFAPI_OBJECT* hierarchies
Array of the hierarchies stored in keystore. 
IFAPI_OBJECT* hierarchy
The current hierarchy 
IFAPI_OBJECT hierarchy_he
The endorsement hierarchy 
IFAPI_OBJECT hierarchy_hn
The null hierarchy 
IFAPI_OBJECT hierarchy_hs
The storage hierarchy 
IFAPI_OBJECT hierarchy_lockout
The lockout hierarchy 
TPMS_POLICY* hierarchy_policy
Policy of the current used hierarchy. 
size_t numHierarchyObjects
Number of hierarchies stored in keystore 
size_t numPaths
Size of array with all keystore objects 
size_t path_idx
Index of array with the object paths 
char** pathlist
The array with all keystore objects 
TPM2B_PUBLIC public
The public info of the created primary 
IFAPI_KEY_TEMPLATE public_templ
The basic template for the keys public data 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

IFAPI_TPMI_POLICYTYPE_ASSIGN Struct Reference
Data Fields
TPMI_POLICYTYPE in
char * name

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_json_deserialize.c

IFAPI_TSS_EVENT Struct Reference

#include <ifapi_eventlog.h>
Data Fields
TPM2B_EVENT data
char * event

Detailed Description
TSS event information 

Field Documentation
TPM2B_EVENT data
The event data 
char* event
TSS event information 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog.h

IFAPI_Unseal Struct Reference

#include <fapi_int.h>
Data Fields
const char * keyPath
IFAPI_OBJECT * object
TPM2B_SENSITIVE_DATA * unseal_data

Detailed Description
The data structure holding internal state of Fapi_Unseal. 

Field Documentation
const char* keyPath
The implicit key path 
IFAPI_OBJECT* object
The IPAPI object storing the data to be unsealed 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_int.h

object_node Struct Reference

#include <fapi_types.h>
Data Fields
void * object
size_t size
struct object_node * next

Detailed Description
The data structure storing a linked list of objects.
The structure is used for the processing of file paths 

Field Documentation
struct object_node* next
Pointer to next element 
void* object
The pointer to the object 
 
size_t size
Will be used only for BYTE arrays 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_types.h

PACKED Struct Reference
Data Fields
UINT16 AlgorithmId
UINT8 Digest []
UINT32 EventSize
UINT8 Event []
UINT32 PCRIndex
UINT32 EventType
UINT32 DigestCount
TCG_DIGEST2 Digests []
char16_t c
uuid_t VariableName
UINT64 UnicodeNameLength
UINT64 VariableDataLength
char16_t UnicodeName []
UEFI_PHYSICAL_ADDRESS BlobBase
UINT64 BlobLength
UINT32 pcrIndex
UINT32 eventType
BYTE digest [20]
UINT32 eventDataSize
BYTE event []
UINT16 algorithmId
UINT16 digestSize
UINT8 vendorInfoSize
BYTE vendorInfo []
BYTE Signature [16]
UINT32 platformClass
UINT8 specVersionMinor
UINT8 specVersionMajor
UINT8 specErrata
UINT8 uintnSize
UINT32 numberOfAlgorithms
TCG_SPECID_ALG digestSizes []
UEFI_PHYSICAL_ADDRESS ImageLocationInMemory
UINT64 ImageLengthInMemory
UINT64 ImageLinkTimeAddress
UINT64 LengthOfDevicePath
BYTE DevicePath []

The documentation for this struct was generated from the following file:
src/tss2-fapi/efi_event.h

POLICY_LIST Struct Reference

#include <ifapi_policy_execute.h>
Data Fields
const char * path
TPMS_POLICY policy
struct POLICY_LIST * next

Detailed Description
List of policies which fulfill a certain predicate.
The elements are stored in a linked list. 

Field Documentation
struct POLICY_LIST* next
Pointer to next element 
const char* path
The path of the policy object 
TPMS_POLICY policy
The policy object 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_execute.h

policy_object_node Struct Reference

#include <ifapi_policy_execute.h>
Data Fields
const char * path
TPMS_POLICY policy
struct policy_object_node * next

Detailed Description
List of policies which fulfill a certain predicate.
The elements are stored in a linked list. 

Field Documentation
struct policy_object_node* next
Pointer to next element 
const char* path
The path of the policy object 
TPMS_POLICY policy
The policy object 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_execute.h

str_node Struct Reference

#include <fapi_types.h>
Data Fields
char * str
bool free_string
struct str_node * next

Detailed Description
The data structure storing a linked list of strings.
The structure is used for the processing of file paths 

Field Documentation
bool free_string
Indicates whether a free has to called on cleanup 
struct str_node* next
Pointer to next element 
char* str
A string of the string list 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_types.h

TCG_EVENT_TYPE_ASSIGN Struct Reference
Data Fields
TCG_EVENT_TYPE in
char * name

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog_system.h

template_description Struct Reference
Data Fields
char * ima_type
char * format

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_ima_eventlog.c

template_field Struct Reference
Data Fields
const char * field_id
TSS2_RC(* field_cb )(UINT8 *digest, UINT8 *buffer, size_t *offset, json_object *jso, IFAPI_IMA_TEMPLATE *template)

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_ima_eventlog.c

tpm2_eventlog_context Struct Reference
Data Fields
void * data
SPECID_CALLBACK specid_cb
LOG_EVENT_CALLBACK log_eventhdr_cb
EVENT2_CALLBACK event2hdr_cb
DIGEST2_CALLBACK digest2_cb
EVENT2DATA_CALLBACK event2_cb
uint32_t sha1_used
uint32_t sha256_used
uint32_t sha384_used
uint32_t sha512_used
uint32_t sm3_256_used
uint8_t sha1_pcrs [TPM2_MAX_PCRS][TPM2_SHA1_DIGEST_SIZE]
uint8_t sha256_pcrs [TPM2_MAX_PCRS][TPM2_SHA256_DIGEST_SIZE]
uint8_t sha384_pcrs [TPM2_MAX_PCRS][TPM2_SHA384_DIGEST_SIZE]
uint8_t sha512_pcrs [TPM2_MAX_PCRS][TPM2_SHA512_DIGEST_SIZE]
uint8_t sm3_256_pcrs [TPM2_MAX_PCRS][TPM2_SM3_256_DIGEST_SIZE]

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog_system.h

tpm_getekcertificate_ctx Struct Reference
Data Fields
char * ec_cert_path
FILE * ec_cert_file_handle
char * ek_server_addr
unsigned int SSL_NO_VERIFY
char * ek_path
bool verbose
bool is_tpm2_device_active
TPM2B_PUBLIC * out_public

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_get_intl_cert.c

TPMI_POLICYTYPE_ASSIGN Struct Reference
Data Fields
TPMI_POLICYTYPE in
char * name

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_json_serialize.c

TPML_POLICYAUTHORIZATIONS Struct Reference

#include <ifapi_policy_types.h>
Data Fields
UINT32 count
TPMS_POLICYAUTHORIZATION authorizations []

Detailed Description
Policy type TPML_POLICYAUTHORIZATIONS 

Field Documentation
TPMS_POLICYAUTHORIZATION authorizations[]
Array of policy elements 
UINT32 count
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPML_POLICYBRANCHES Struct Reference

#include <ifapi_policy_types.h>
Data Fields
UINT32 count
TPMS_POLICYBRANCH authorizations []

Detailed Description
Policy type TPML_POLICYBRANCHES 

Field Documentation
TPMS_POLICYBRANCH authorizations[]
Array of policy elements 
UINT32 count
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPML_POLICYELEMENTS Struct Reference

#include <ifapi_policy_types.h>
Data Fields
UINT32 count
TPMT_POLICYELEMENT elements []

Detailed Description
Policy type TPML_POLICYELEMENTS 

Field Documentation
UINT32 count
None 
TPMT_POLICYELEMENT elements[]
Array of policy elements 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_CEL_VERSION Struct Reference
Data Fields
UINT16 major
UINT16 minor

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog.h

TPMS_EVENT_CELMGT Struct Reference
Data Fields
TPMI_CELMGTTYPE type
TPMU_CELMGT data

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_eventlog.h

TPMS_POLICY Struct Reference

#include <ifapi_policy_types.h>
Data Fields
char * description
TPML_DIGEST_VALUES policyDigests
struct TPML_POLICYAUTHORIZATIONS * policyAuthorizations
struct TPML_POLICYELEMENTS * policy

Detailed Description
Policy type TPMS_POLICY 

Field Documentation
char* description
O 
struct TPML_POLICYELEMENTS* policy
X 
struct TPML_POLICYAUTHORIZATIONS* policyAuthorizations
O 
TPML_DIGEST_VALUES policyDigests
O 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYACTION Struct Reference

#include <ifapi_policy_types.h>
Data Fields
char * action

Detailed Description
Policy type TPMS_POLICYACTION 

Field Documentation
char* action
The FAPI will return a string representation of the JSON sub 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYAUTHORIZATION Struct Reference

#include <ifapi_policy_types.h>
Data Fields
char * type
TPMT_PUBLIC key
TPM2B_NONCE policyRef
TPMT_SIGNATURE signature
TPMI_ALG_HASH hashAlg
UINT8_ARY pemSignature
char * keyPEM
TPMT_RSA_SCHEME rsaScheme

Detailed Description
Policy type TPMS_POLICYAUTHORIZATION 

Field Documentation
TPMT_PUBLIC key
Selector of the algorithm used for the signature and the pub 
TPM2B_NONCE policyRef
None 
TPMT_SIGNATURE signature
None 
char* type
tpm 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYAUTHORIZE Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2B_DIGEST approvedPolicy
TPM2B_NONCE policyRef
TPM2B_NAME keyName
TPMT_TK_VERIFIED checkTicket
char * keyPath
TPMT_PUBLIC keyPublic
char * keyPEM
TPMI_ALG_HASH keyPEMhashAlg
TPMT_RSA_SCHEME rsaScheme
TPMT_SIGNATURE signature

Detailed Description
Policy type TPMS_POLICYAUTHORIZE 

Field Documentation
TPM2B_DIGEST approvedPolicy
None 
TPMT_TK_VERIFIED checkTicket
None 
TPM2B_NAME keyName
Not exposed in JSON, but generated from keyPath, keyPublic o 
char* keyPath
A reference to a key inside the FAPI keystore 
char* keyPEM
everyone in favour
 The TPM2B_NAME is constructed w 
TPMI_ALG_HASH keyPEMhashAlg
(optional) Default = SHA256 
TPMT_PUBLIC keyPublic
None 
TPM2B_NONCE policyRef
None 
TPMT_RSA_SCHEME rsaScheme
(optional) Default = TPM2_ALG_RSAPSS 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYAUTHORIZENV Struct Reference

#include <ifapi_policy_types.h>
Data Fields
char * nvPath
TPMS_NV_PUBLIC nvPublic
TPM2B_DIGEST policy
TPMT_HA nv_policy
uint8_t * policy_buffer

Detailed Description
Policy type TPMS_POLICYAUTHORIZENV 

Field Documentation
TPMT_HA nv_policy
Policy stored in NV ram 
char* nvPath
None 
TPMS_NV_PUBLIC nvPublic
None 
TPM2B_DIGEST policy
Policy Digest 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYAUTHVALUE Struct Reference

#include <ifapi_policy_types.h>

Detailed Description
Policy type TPMS_POLICYAUTHVALUE 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYBRANCH Struct Reference

#include <ifapi_policy_types.h>
Data Fields
char * name
char * description
TPML_DIGEST_VALUES policyDigests
struct TPML_POLICYELEMENTS * policy

Detailed Description
Policy type TPMS_POLICYBRANCH 

Field Documentation
char* description
None 
char* name
None 
struct TPML_POLICYELEMENTS* policy
Array of policy elements 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYCOMMANDCODE Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2_CC code

Detailed Description
Policy type TPMS_POLICYCOMMANDCODE 

Field Documentation
TPM2_CC code
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYCOUNTERTIMER Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2B_OPERAND operandB
UINT16 offset
TPM2_EO operation

Detailed Description
Policy type TPMS_POLICYCOUNTERTIMER 

Field Documentation
UINT16 offset
Default is 0 
TPM2B_OPERAND operandB
None 
TPM2_EO operation
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYCPHASH Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2B_DIGEST cpHash

Detailed Description
Policy type TPMS_POLICYCPHASH 

Field Documentation
TPM2B_DIGEST cpHash
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYDUPLICATIONSELECT Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2B_NAME objectName
TPM2B_NAME newParentName
TPMI_YES_NO includeObject
char * newParentPath
TPMT_PUBLIC newParentPublic

Detailed Description
Policy type TPMS_POLICYDUPLICATIONSELECT 

Field Documentation
TPMI_YES_NO includeObject
Always NO 
TPM2B_NAME newParentName
Automatically calculated 
char* newParentPath
None 
TPMT_PUBLIC newParentPublic
None 
TPM2B_NAME objectName
Will not be used (see includeObject) 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYLOCALITY Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPMA_LOCALITY locality

Detailed Description
Policy type TPMS_POLICYLOCALITY 

Field Documentation
TPMA_LOCALITY locality
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYNAMEHASH Struct Reference

#include <ifapi_policy_types.h>
Data Fields
UINT32 count
UINT32 i
TPM2B_NAME objectNames [3]
char * namePaths [3]
TPM2B_DIGEST nameHash

Detailed Description
Policy type TPMS_POLICYNAMEHASH 

Field Documentation
UINT32 count
Computed during instantiation 
UINT32 i
Temporary index for policy calculation 
TPM2B_DIGEST nameHash
computed during policy calculation 
char* namePaths[3]
Paths of objects used for retrieving the names 
TPM2B_NAME objectNames[3]
computed during instantiation (if not initialized) 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYNV Struct Reference

#include <ifapi_policy_types.h>
Data Fields
char * nvPath
TPMI_RH_NV_INDEX nvIndex
TPMS_NV_PUBLIC nvPublic
TPMI_RH_NV_AUTH authHandle
TPM2B_OPERAND operandB
UINT16 offset
TPM2_EO operation

Detailed Description
Policy type TPMS_POLICYNV 

Field Documentation
TPMI_RH_NV_AUTH authHandle
This is determined by FAPI at runtime. 
TPMI_RH_NV_INDEX nvIndex
None 
char* nvPath
None 
TPMS_NV_PUBLIC nvPublic
None 
UINT16 offset
Default value is 0 
TPM2B_OPERAND operandB
None 
TPM2_EO operation
Default value is EQUAL 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYNVWRITTEN Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPMI_YES_NO writtenSet

Detailed Description
Policy type TPMS_POLICYNVWRITTEN 

Field Documentation
TPMI_YES_NO writtenSet
Default is yes 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYOR Struct Reference

#include <ifapi_policy_types.h>
Data Fields
struct TPML_POLICYBRANCHES * branches

Detailed Description
Policy type TPMS_POLICYOR 

Field Documentation
struct TPML_POLICYBRANCHES* branches
An (infinite) array of policy elements. This does not contai 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYPASSWORD Struct Reference

#include <ifapi_policy_types.h>

Detailed Description
Policy type TPMS_POLICYPASSWORD 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYPCR Struct Reference

#include <ifapi_policy_types.h>
Data Fields
struct TPML_PCRVALUES * pcrs
TPMS_PCR_SELECT currentPCRs
TPML_PCR_SELECTION currentPCRandBanks

Detailed Description
Policy type TPMS_POLICYPCR 

Field Documentation
TPML_PCR_SELECTION currentPCRandBanks
Complete selection with banks 
 
TPMS_PCR_SELECT currentPCRs
The hashAlg are inferred from 
struct TPML_PCRVALUES* pcrs
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYPHYSICALPRESENCE Struct Reference

#include <ifapi_policy_types.h>

Detailed Description
Policy type TPMS_POLICYPHYSICALPRESENCE 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYSECRET Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2B_NONCE nonceTPM
TPM2B_DIGEST cpHashA
TPM2B_NONCE policyRef
INT32 expiration
char * objectPath
TPM2B_NAME objectName

Detailed Description
Policy type TPMS_POLICYSECRET 

Field Documentation
TPM2B_DIGEST cpHashA
None 
INT32 expiration
None 
TPM2B_NONCE nonceTPM
None 
TPM2B_NAME objectName
Public name of the object 
char* objectPath
Path of the object 
TPM2B_NONCE policyRef
Default is zero length 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYSIGNED Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2B_NONCE nonceTPM
TPM2B_DIGEST cpHashA
TPM2B_NONCE policyRef
INT32 expiration
TPMT_SIGNATURE auth
TPM2B_NAME publicKey
char * publicKeyHint
char * keyPath
TPMT_PUBLIC keyPublic
char * keyPEM
TPMI_ALG_HASH keyPEMhashAlg
TPMT_RSA_SCHEME rsaScheme
TPMT_SIGNATURE signature_tpm

Detailed Description
Policy type TPMS_POLICYSIGNED 

Field Documentation
TPMT_SIGNATURE auth
This value is generated from at runtime via a callback. 
TPM2B_DIGEST cpHashA
This value will be automatically generated by the FAPI. 
INT32 expiration
This value will be -1 by the FAPI 
char* keyPath
A reference to a key inside the FAPI keystore 
char* keyPEM
The TPM2B_NAME is constructed with a TPMT_PUBLIC from this 
TPMI_ALG_HASH keyPEMhashAlg
(optional) Default = SHA256 
TPMT_PUBLIC keyPublic
None 
TPM2B_NONCE nonceTPM
This is a value returned by TPM2_StartAuthSession and thus n 
TPM2B_NONCE policyRef
Default is zero-length 
TPM2B_NAME publicKey
This will be automatically generated from keyPath, keyPublic 
char* publicKeyHint
A human readable hint to denote which public key to use. 
TPMT_RSA_SCHEME rsaScheme
(optional) Default = TPM2_ALG_RSAPSS 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMS_POLICYTEMPLATE Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPM2B_DIGEST templateHash
TPM2B_PUBLIC templatePublic

Detailed Description
Policy type TPMS_POLICYTEMPLATE 

Field Documentation
TPM2B_DIGEST templateHash
None 
TPM2B_PUBLIC templatePublic
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMT_POLICYELEMENT Struct Reference

#include <ifapi_policy_types.h>
Data Fields
TPMI_POLICYTYPE type
TPML_DIGEST_VALUES policyDigests
TPMU_POLICYELEMENT element

Detailed Description
Policy type TPMT_POLICYELEMENT 

Field Documentation
TPMU_POLICYELEMENT element
The union does is not embedded inside a field. 
TPML_DIGEST_VALUES policyDigests
None 
TPMI_POLICYTYPE type
None 

The documentation for this struct was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

TPMU_CELMGT Union Reference
Data Fields
TPMS_CEL_VERSION cel_version
TPMS_EMPTY firmware_end
UINT64 cel_timestamp

The documentation for this union was generated from the following file:
src/tss2-fapi/ifapi_eventlog.h

TPMU_POLICYELEMENT Union Reference

#include <ifapi_policy_types.h>
Data Fields
TPMS_POLICYOR PolicyOr
TPMS_POLICYSIGNED PolicySigned
TPMS_POLICYSECRET PolicySecret
TPMS_POLICYPCR PolicyPCR
TPMS_POLICYLOCALITY PolicyLocality
TPMS_POLICYNV PolicyNV
TPMS_POLICYCOUNTERTIMER PolicyCounterTimer
TPMS_POLICYCOMMANDCODE PolicyCommandCode
TPMS_POLICYPHYSICALPRESENCE PolicyPhysicalPresence
TPMS_POLICYCPHASH PolicyCpHash
TPMS_POLICYNAMEHASH PolicyNameHash
TPMS_POLICYDUPLICATIONSELECT PolicyDuplicationSelect
TPMS_POLICYAUTHORIZE PolicyAuthorize
TPMS_POLICYAUTHVALUE PolicyAuthValue
TPMS_POLICYPASSWORD PolicyPassword
TPMS_POLICYNVWRITTEN PolicyNvWritten
TPMS_POLICYTEMPLATE PolicyTemplate
TPMS_POLICYAUTHORIZENV PolicyAuthorizeNv
TPMS_POLICYACTION PolicyAction

Detailed Description
[u''] 

Field Documentation
TPMS_POLICYACTION PolicyAction
None 
TPMS_POLICYAUTHORIZE PolicyAuthorize
None 
TPMS_POLICYAUTHORIZENV PolicyAuthorizeNv
None 
TPMS_POLICYAUTHVALUE PolicyAuthValue
None 
TPMS_POLICYCOMMANDCODE PolicyCommandCode
None 
TPMS_POLICYCOUNTERTIMER PolicyCounterTimer
None 
TPMS_POLICYCPHASH PolicyCpHash
None 
TPMS_POLICYDUPLICATIONSELECT PolicyDuplicationSelect
None 
TPMS_POLICYLOCALITY PolicyLocality
None 
TPMS_POLICYNAMEHASH PolicyNameHash
None 
TPMS_POLICYNV PolicyNV
None 
TPMS_POLICYNVWRITTEN PolicyNvWritten
None 
TPMS_POLICYOR PolicyOr
None 
TPMS_POLICYPASSWORD PolicyPassword
None 
TPMS_POLICYPCR PolicyPCR
None 
TPMS_POLICYPHYSICALPRESENCE PolicyPhysicalPresence
None 
TPMS_POLICYSECRET PolicySecret
None 
TPMS_POLICYSIGNED PolicySigned
None 
TPMS_POLICYTEMPLATE PolicyTemplate
None 

The documentation for this union was generated from the following file:
src/tss2-fapi/ifapi_policy_types.h

UINT8_ARY Struct Reference

#include <fapi_types.h>
Data Fields
size_t size
uint8_t * buffer

Detailed Description
The data structure representing an unit8_t array. 

The documentation for this struct was generated from the following file:
src/tss2-fapi/fapi_types.h

File Documentation
tss2_esys.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef TSS2_ESYS_H
7 #define TSS2_ESYS_H
8 
9 #include "tss2_tcti.h"
10 #include "tss2_sys.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef uint32_t ESYS_TR;
17 
18 #define ESYS_TR_NONE     0xfffU
19 #define ESYS_TR_PASSWORD 0x0ffU
20 #define ESYS_TR_PCR0      0U
21 #define ESYS_TR_PCR1      1U
22 #define ESYS_TR_PCR2      2U
23 #define ESYS_TR_PCR3      3U
24 #define ESYS_TR_PCR4      4U
25 #define ESYS_TR_PCR5      5U
26 #define ESYS_TR_PCR6      6U
27 #define ESYS_TR_PCR7      7U
28 #define ESYS_TR_PCR8      8U
29 #define ESYS_TR_PCR9      9U
30 #define ESYS_TR_PCR10    10U
31 #define ESYS_TR_PCR11    11U
32 #define ESYS_TR_PCR12    12U
33 #define ESYS_TR_PCR13    13U
34 #define ESYS_TR_PCR14    14U
35 #define ESYS_TR_PCR15    15U
36 #define ESYS_TR_PCR16    16U
37 #define ESYS_TR_PCR17    17U
38 #define ESYS_TR_PCR18    18U
39 #define ESYS_TR_PCR19    19U
40 #define ESYS_TR_PCR20    20U
41 #define ESYS_TR_PCR21    21U
42 #define ESYS_TR_PCR22    22U
43 #define ESYS_TR_PCR23    23U
44 #define ESYS_TR_PCR24    24U
45 #define ESYS_TR_PCR25    25U
46 #define ESYS_TR_PCR26    26U
47 #define ESYS_TR_PCR27    27U
48 #define ESYS_TR_PCR28    28U
49 #define ESYS_TR_PCR29    29U
50 #define ESYS_TR_PCR30    30U
51 #define ESYS_TR_PCR31    31U
52 
53 /* From TPM_RH_CONSTANTS */
54 #define ESYS_TR_RH_OWNER       0x101U
55 #define ESYS_TR_RH_NULL        0x107U
56 #define ESYS_TR_RH_LOCKOUT     0x10AU
57 #define ESYS_TR_RH_ENDORSEMENT 0x10BU
58 #define ESYS_TR_RH_PLATFORM    0x10CU
59 #define ESYS_TR_RH_PLATFORM_NV 0x10DU
60 
61 #define ESYS_TR_RH_AUTH_FIRST  0x110U
62 #define ESYS_TR_RH_AUTH(x) (ESYS_TR_RH_AUTH_FIRST + (ESYS_TR)(x))
63 #define ESYS_TR_RH_ACT_FIRST  0x120U
64 #define ESYS_TR_RH_ACT(x) (ESYS_TR_RH_ACT_FIRST + (ESYS_TR)(x))
65 #define ESYS_TR_RH_ACT_0       ESYS_TR_RH_ACT_FIRST
66 #define ESYS_TR_RH_ACT_1       0x121U
67 #define ESYS_TR_RH_ACT_2       0x122U
68 #define ESYS_TR_RH_ACT_3       0x123U
69 #define ESYS_TR_RH_ACT_4       0x124U
70 #define ESYS_TR_RH_ACT_5       0x125U
71 #define ESYS_TR_RH_ACT_6       0x126U
72 #define ESYS_TR_RH_ACT_7       0x127U
73 #define ESYS_TR_RH_ACT_8       0x128U
74 #define ESYS_TR_RH_ACT_9       0x129U
75 #define ESYS_TR_RH_ACT_A       0x12AU
76 #define ESYS_TR_RH_ACT_B       0x12BU
77 #define ESYS_TR_RH_ACT_C       0x12CU
78 #define ESYS_TR_RH_ACT_D       0x12DU
79 #define ESYS_TR_RH_ACT_E       0x12EU
80 #define ESYS_TR_RH_ACT_F       0x12FU
81 #define ESYS_TR_RH_ACT_LAST    ESYS_TR_RH_ACT_F
82 #define ESYS_TR_RH_AC_FIRST    0x140U
83 #define ESYS_TR_RH_AC(x)       (ESYS_TR_RH_AC_FIRST + (ESYS_TR)(x))
84 #define ESYS_TR_RH_AC_LAST     (ESYS_TR_RH_AC_FIRST  + 0xFFFFU)
85 
86 typedef struct ESYS_CONTEXT ESYS_CONTEXT;
87 
88 typedef struct ESYS_CRYPTO_CONTEXT_BLOB ESYS_CRYPTO_CONTEXT_BLOB;
89 
90 /*
91  * Crypto Backend Support
92  */
93 
103 typedef TSS2_RC
104     (*ESYS_CRYPTO_HASH_START_FNP)(
105         ESYS_CRYPTO_CONTEXT_BLOB ** context,
106         TPM2_ALG_ID hashAlg,
107         void *userdata);
108 
120 typedef TSS2_RC
121     (*ESYS_CRYPTO_HASH_UPDATE_FNP)(
122         ESYS_CRYPTO_CONTEXT_BLOB * context,
123         const uint8_t *buffer,
124         size_t size,
125         void *userdata);
126 
138 typedef TSS2_RC
139     (*ESYS_CRYPTO_HASH_FINISH_FNP)(
140         ESYS_CRYPTO_CONTEXT_BLOB **context,
141         uint8_t *buffer,
142         size_t *size,
143         void *userdata);
144 
151 typedef void
152     (*ESYS_CRYPTO_HASH_ABORT_FNP)(
153         ESYS_CRYPTO_CONTEXT_BLOB **context,
154         void *userdata);
155 
168 typedef TSS2_RC
169     (*ESYS_CRYPTO_HMAC_START_FNP)(
170         ESYS_CRYPTO_CONTEXT_BLOB **context,
171         TPM2_ALG_ID hashAlg,
172         const uint8_t *key,
173         size_t size,
174         void *userdata);
175 
187 typedef TSS2_RC
188     (*ESYS_CRYPTO_HMAC_UPDATE_FNP)(
189         ESYS_CRYPTO_CONTEXT_BLOB *context,
190         const uint8_t *buffer,
191         size_t size,
192         void *userdata);
193 
205 typedef TSS2_RC
206     (*ESYS_CRYPTO_HMAC_FINISH_FNP)(
207         ESYS_CRYPTO_CONTEXT_BLOB **context,
208         uint8_t *buffer,
209         size_t *size,
210         void *userdata);
211 
218 typedef void
219     (*ESYS_CRYPTO_HMAC_ABORT_FNP)(
220         ESYS_CRYPTO_CONTEXT_BLOB **context,
221         void *userdata);
222 
233 typedef TSS2_RC
234     (*ESYS_CRYPTO_GET_RANDOM2B_FNP)(
235         TPM2B_NONCE *nonce,
236         size_t num_bytes,
237         void *userdata);
238 
256 typedef TSS2_RC
257     (*ESYS_CRYPTO_GET_ECDH_POINT_FNP)(
258         TPM2B_PUBLIC *key,
259         size_t max_out_size,
260         TPM2B_ECC_PARAMETER *Z,
261         TPMS_ECC_POINT *Q,
262         BYTE *out_buffer,
263         size_t *out_size,
264         void *userdata);
265 
281 typedef TSS2_RC
282     (*ESYS_CRYPTO_AES_ENCRYPT_FNP)(
283         uint8_t *key,
284         TPM2_ALG_ID tpm_sym_alg,
285         TPMI_AES_KEY_BITS key_bits,
286         TPM2_ALG_ID tpm_mode,
287         uint8_t *buffer,
288         size_t buffer_size,
289         uint8_t *iv,
290         void *userdata);
291 
307 typedef TSS2_RC
308     (*ESYS_CRYPTO_AES_DECRYPT_FNP)(
309         uint8_t *key,
310         TPM2_ALG_ID tpm_sym_alg,
311         TPMI_AES_KEY_BITS key_bits,
312         TPM2_ALG_ID tpm_mode,
313         uint8_t *buffer,
314         size_t buffer_size,
315         uint8_t *iv,
316         void *userdata);
317 
333 typedef TSS2_RC
334     (*ESYS_CRYPTO_PK_RSA_ENCRYPT_FNP)(
335         TPM2B_PUBLIC * pub_tpm_key,
336         size_t in_size,
337         BYTE *in_buffer,
338         size_t max_out_size,
339         BYTE *out_buffer,
340         size_t *out_size,
341         const char *label,
342         void *userdata);
343 
353 typedef TSS2_RC (*ESYS_CRYPTO_INIT_FNP)(void *userdata);
354 
355 typedef struct ESYS_CRYPTO_CALLBACKS ESYS_CRYPTO_CALLBACKS;
356 struct ESYS_CRYPTO_CALLBACKS {
357     ESYS_CRYPTO_PK_RSA_ENCRYPT_FNP rsa_pk_encrypt;
358     ESYS_CRYPTO_HASH_START_FNP hash_start;
359     ESYS_CRYPTO_HASH_UPDATE_FNP hash_update;
360     ESYS_CRYPTO_HASH_FINISH_FNP hash_finish;
361     ESYS_CRYPTO_HASH_ABORT_FNP hash_abort;
362     ESYS_CRYPTO_HMAC_START_FNP hmac_start;
363     ESYS_CRYPTO_HMAC_UPDATE_FNP hmac_update;
364     ESYS_CRYPTO_HMAC_FINISH_FNP hmac_finish;
365     ESYS_CRYPTO_HMAC_ABORT_FNP hmac_abort;
366     ESYS_CRYPTO_GET_RANDOM2B_FNP get_random2b;
367     ESYS_CRYPTO_GET_ECDH_POINT_FNP get_ecdh_point;
368     ESYS_CRYPTO_AES_ENCRYPT_FNP aes_encrypt;
369     ESYS_CRYPTO_AES_DECRYPT_FNP aes_decrypt;
370     ESYS_CRYPTO_INIT_FNP init;
371     void *userdata;
372 };
373 
374 /*
375  * TPM 2.0 ESAPI Functions
376  */
377 
378 TSS2_RC
379 Esys_Initialize(
380     ESYS_CONTEXT **esys_context,
381     TSS2_TCTI_CONTEXT *tcti,
382     TSS2_ABI_VERSION *abiVersion);
383 
384 void
385 Esys_Finalize(
386     ESYS_CONTEXT **context);
387 
388 TSS2_RC
389 Esys_GetTcti(
390     ESYS_CONTEXT *esys_context,
391     TSS2_TCTI_CONTEXT **tcti);
392 
393 TSS2_RC
394 Esys_GetPollHandles(
395     ESYS_CONTEXT *esys_context,
396     TSS2_TCTI_POLL_HANDLE **handles,
397     size_t *count);
398 
399 TSS2_RC
400 Esys_SetTimeout(
401     ESYS_CONTEXT *esys_context,
402     int32_t timeout);
403 
404 TSS2_RC
405 Esys_TR_Serialize(
406     ESYS_CONTEXT *esys_context,
407     ESYS_TR object,
408     uint8_t **buffer,
409     size_t *buffer_size);
410 
411 TSS2_RC
412 Esys_TR_Deserialize(
413     ESYS_CONTEXT *esys_context,
414     uint8_t const *buffer,
415     size_t buffer_size,
416     ESYS_TR *esys_handle);
417 
418 TSS2_RC
419 Esys_TR_FromTPMPublic_Async(
420     ESYS_CONTEXT *esysContext,
421     TPM2_HANDLE tpm_handle,
422     ESYS_TR optionalSession1,
423     ESYS_TR optionalSession2,
424     ESYS_TR optionalSession3);
425 
426 TSS2_RC
427 Esys_TR_FromTPMPublic_Finish(
428     ESYS_CONTEXT *esysContext,
429     ESYS_TR *object);
430 
431 TSS2_RC
432 Esys_TR_FromTPMPublic(
433     ESYS_CONTEXT *esysContext,
434     TPM2_HANDLE tpm_handle,
435     ESYS_TR optionalSession1,
436     ESYS_TR optionalSession2,
437     ESYS_TR optionalSession3,
438     ESYS_TR *object);
439 
440 TSS2_RC
441 Esys_TR_Close(
442     ESYS_CONTEXT *esys_context,
443     ESYS_TR *rsrc_handle);
444 
445 TSS2_RC
446 Esys_TR_SetAuth(
447     ESYS_CONTEXT *esysContext,
448     ESYS_TR handle,
449     TPM2B_AUTH const *authValue);
450 
451 TSS2_RC
452 Esys_TR_GetName(
453     ESYS_CONTEXT *esysContext,
454     ESYS_TR handle,
455     TPM2B_NAME **name);
456 
457 TSS2_RC
458 Esys_TRSess_GetAttributes(
459     ESYS_CONTEXT *esysContext,
460     ESYS_TR session,
461     TPMA_SESSION *flags);
462 
463 TSS2_RC
464 Esys_TRSess_SetAttributes(
465     ESYS_CONTEXT *esysContext,
466     ESYS_TR session,
467     TPMA_SESSION flags,
468     TPMA_SESSION mask);
469 
470 TSS2_RC
471 Esys_TRSess_GetNonceTPM(
472     ESYS_CONTEXT *esysContext,
473     ESYS_TR session,
474     TPM2B_NONCE **nonceTPM);
475 
476 TSS2_RC
477 Esys_TR_GetTpmHandle(
478     ESYS_CONTEXT *esys_context,
479     ESYS_TR esys_handle,
480     TPM2_HANDLE *tpm_handle);
481 
482 TSS2_RC
483 Esys_TRSess_GetAuthRequired(
484     ESYS_CONTEXT *esys_context,
485     ESYS_TR esys_handle,
486     TPMI_YES_NO *auth_needed);
487 
488 /* Table 5 - TPM2_Startup Command */
489 
490 TSS2_RC
491 Esys_Startup(
492     ESYS_CONTEXT *esysContext,
493     TPM2_SU startupType);
494 
495 TSS2_RC
496 Esys_Startup_Async(
497     ESYS_CONTEXT *esysContext,
498     TPM2_SU startupType);
499 
500 TSS2_RC
501 Esys_Startup_Finish(
502     ESYS_CONTEXT *esysContext);
503 
504 /* Table 7 - TPM2_Shutdown Command */
505 
506 TSS2_RC
507 Esys_Shutdown(
508     ESYS_CONTEXT *esysContext,
509     ESYS_TR shandle1,
510     ESYS_TR shandle2,
511     ESYS_TR shandle3,
512     TPM2_SU shutdownType);
513 
514 TSS2_RC
515 Esys_Shutdown_Async(
516     ESYS_CONTEXT *esysContext,
517     ESYS_TR shandle1,
518     ESYS_TR shandle2,
519     ESYS_TR shandle3,
520     TPM2_SU shutdownType);
521 
522 TSS2_RC
523 Esys_Shutdown_Finish(
524     ESYS_CONTEXT *esysContext);
525 
526 /* Table 9 - TPM2_SelfTest Command */
527 
528 TSS2_RC
529 Esys_SelfTest(
530     ESYS_CONTEXT *esysContext,
531     ESYS_TR shandle1,
532     ESYS_TR shandle2,
533     ESYS_TR shandle3,
534     TPMI_YES_NO fullTest);
535 
536 TSS2_RC
537 Esys_SelfTest_Async(
538     ESYS_CONTEXT *esysContext,
539     ESYS_TR shandle1,
540     ESYS_TR shandle2,
541     ESYS_TR shandle3,
542     TPMI_YES_NO fullTest);
543 
544 TSS2_RC
545 Esys_SelfTest_Finish(
546     ESYS_CONTEXT *esysContext);
547 
548 /* Table 11 - TPM2_IncrementalSelfTest Command */
549 
550 TSS2_RC
551 Esys_IncrementalSelfTest(
552     ESYS_CONTEXT *esysContext,
553     ESYS_TR shandle1,
554     ESYS_TR shandle2,
555     ESYS_TR shandle3,
556     const TPML_ALG *toTest,
557     TPML_ALG **toDoList);
558 
559 TSS2_RC
560 Esys_IncrementalSelfTest_Async(
561     ESYS_CONTEXT *esysContext,
562     ESYS_TR shandle1,
563     ESYS_TR shandle2,
564     ESYS_TR shandle3,
565     const TPML_ALG *toTest);
566 
567 TSS2_RC
568 Esys_IncrementalSelfTest_Finish(
569     ESYS_CONTEXT *esysContext,
570     TPML_ALG **toDoList);
571 
572 /* Table 13 - TPM2_GetTestResult Command */
573 
574 TSS2_RC
575 Esys_GetTestResult(
576     ESYS_CONTEXT *esysContext,
577     ESYS_TR shandle1,
578     ESYS_TR shandle2,
579     ESYS_TR shandle3,
580     TPM2B_MAX_BUFFER **outData,
581     TPM2_RC *testResult);
582 
583 TSS2_RC
584 Esys_GetTestResult_Async(
585     ESYS_CONTEXT *esysContext,
586     ESYS_TR shandle1,
587     ESYS_TR shandle2,
588     ESYS_TR shandle3);
589 
590 TSS2_RC
591 Esys_GetTestResult_Finish(
592     ESYS_CONTEXT *esysContext,
593     TPM2B_MAX_BUFFER **outData,
594     TPM2_RC *testResult);
595 
596 /* Table 15 - TPM2_StartAuthSession Command */
597 
598 TSS2_RC
599 Esys_StartAuthSession(
600     ESYS_CONTEXT *esysContext,
601     ESYS_TR tpmKey,
602     ESYS_TR bind,
603     ESYS_TR shandle1,
604     ESYS_TR shandle2,
605     ESYS_TR shandle3,
606     const TPM2B_NONCE *nonceCaller,
607     TPM2_SE sessionType,
608     const TPMT_SYM_DEF *symmetric,
609     TPMI_ALG_HASH authHash,
610     ESYS_TR *sessionHandle);
611 
612 TSS2_RC
613 Esys_StartAuthSession_Async(
614     ESYS_CONTEXT *esysContext,
615     ESYS_TR tpmKey,
616     ESYS_TR bind,
617     ESYS_TR shandle1,
618     ESYS_TR shandle2,
619     ESYS_TR shandle3,
620     const TPM2B_NONCE *nonceCaller,
621     TPM2_SE sessionType,
622     const TPMT_SYM_DEF *symmetric,
623     TPMI_ALG_HASH authHash);
624 
625 TSS2_RC
626 Esys_StartAuthSession_Finish(
627     ESYS_CONTEXT *esysContext,
628     ESYS_TR *sessionHandle);
629 
630 /* Table 17 - TPM2_PolicyRestart Command */
631 
632 TSS2_RC
633 Esys_PolicyRestart(
634     ESYS_CONTEXT *esysContext,
635     ESYS_TR sessionHandle,
636     ESYS_TR shandle1,
637     ESYS_TR shandle2,
638     ESYS_TR shandle3);
639 
640 TSS2_RC
641 Esys_PolicyRestart_Async(
642     ESYS_CONTEXT *esysContext,
643     ESYS_TR sessionHandle,
644     ESYS_TR shandle1,
645     ESYS_TR shandle2,
646     ESYS_TR shandle3);
647 
648 TSS2_RC
649 Esys_PolicyRestart_Finish(
650     ESYS_CONTEXT *esysContext);
651 
652 /* Table 19 - TPM2_Create Command */
653 
654 TSS2_RC
655 Esys_Create(
656     ESYS_CONTEXT *esysContext,
657     ESYS_TR parentHandle,
658     ESYS_TR shandle1,
659     ESYS_TR shandle2,
660     ESYS_TR shandle3,
661     const TPM2B_SENSITIVE_CREATE *inSensitive,
662     const TPM2B_PUBLIC *inPublic,
663     const TPM2B_DATA *outsideInfo,
664     const TPML_PCR_SELECTION *creationPCR,
665     TPM2B_PRIVATE **outPrivate,
666     TPM2B_PUBLIC **outPublic,
667     TPM2B_CREATION_DATA **creationData,
668     TPM2B_DIGEST **creationHash,
669     TPMT_TK_CREATION **creationTicket);
670 
671 TSS2_RC
672 Esys_Create_Async(
673     ESYS_CONTEXT *esysContext,
674     ESYS_TR parentHandle,
675     ESYS_TR shandle1,
676     ESYS_TR shandle2,
677     ESYS_TR shandle3,
678     const TPM2B_SENSITIVE_CREATE *inSensitive,
679     const TPM2B_PUBLIC *inPublic,
680     const TPM2B_DATA *outsideInfo,
681     const TPML_PCR_SELECTION *creationPCR);
682 
683 TSS2_RC
684 Esys_Create_Finish(
685     ESYS_CONTEXT *esysContext,
686     TPM2B_PRIVATE **outPrivate,
687     TPM2B_PUBLIC **outPublic,
688     TPM2B_CREATION_DATA **creationData,
689     TPM2B_DIGEST **creationHash,
690     TPMT_TK_CREATION **creationTicket);
691 
692 /* Table 21 - TPM2_Load Command */
693 
694 TSS2_RC
695 Esys_Load(
696     ESYS_CONTEXT *esysContext,
697     ESYS_TR parentHandle,
698     ESYS_TR shandle1,
699     ESYS_TR shandle2,
700     ESYS_TR shandle3,
701     const TPM2B_PRIVATE *inPrivate,
702     const TPM2B_PUBLIC *inPublic,
703     ESYS_TR *objectHandle);
704 
705 TSS2_RC
706 Esys_Load_Async(
707     ESYS_CONTEXT *esysContext,
708     ESYS_TR parentHandle,
709     ESYS_TR shandle1,
710     ESYS_TR shandle2,
711     ESYS_TR shandle3,
712     const TPM2B_PRIVATE *inPrivate,
713     const TPM2B_PUBLIC *inPublic);
714 
715 TSS2_RC
716 Esys_Load_Finish(
717     ESYS_CONTEXT *esysContext,
718     ESYS_TR *objectHandle);
719 
720 /* Table 23 - TPM2_LoadExternal Command */
721 
722 TSS2_RC
723 Esys_LoadExternal(
724     ESYS_CONTEXT *esysContext,
725     ESYS_TR shandle1,
726     ESYS_TR shandle2,
727     ESYS_TR shandle3,
728     const TPM2B_SENSITIVE *inPrivate,
729     const TPM2B_PUBLIC *inPublic,
730     ESYS_TR hierarchy,
731     ESYS_TR *objectHandle);
732 
733 TSS2_RC
734 Esys_LoadExternal_Async(
735     ESYS_CONTEXT *esysContext,
736     ESYS_TR shandle1,
737     ESYS_TR shandle2,
738     ESYS_TR shandle3,
739     const TPM2B_SENSITIVE *inPrivate,
740     const TPM2B_PUBLIC *inPublic,
741     ESYS_TR hierarchy);
742 
743 TSS2_RC
744 Esys_LoadExternal_Finish(
745     ESYS_CONTEXT *esysContext,
746     ESYS_TR *objectHandle);
747 
748 /* Table 25 - TPM2_ReadPublic Command */
749 
750 TSS2_RC
751 Esys_ReadPublic(
752     ESYS_CONTEXT *esysContext,
753     ESYS_TR objectHandle,
754     ESYS_TR shandle1,
755     ESYS_TR shandle2,
756     ESYS_TR shandle3,
757     TPM2B_PUBLIC **outPublic,
758     TPM2B_NAME **name,
759     TPM2B_NAME **qualifiedName);
760 
761 TSS2_RC
762 Esys_ReadPublic_Async(
763     ESYS_CONTEXT *esysContext,
764     ESYS_TR objectHandle,
765     ESYS_TR shandle1,
766     ESYS_TR shandle2,
767     ESYS_TR shandle3);
768 
769 TSS2_RC
770 Esys_ReadPublic_Finish(
771     ESYS_CONTEXT *esysContext,
772     TPM2B_PUBLIC **outPublic,
773     TPM2B_NAME **name,
774     TPM2B_NAME **qualifiedName);
775 
776 /* Table 27 - TPM2_ActivateCredential Command */
777 
778 TSS2_RC
779 Esys_ActivateCredential(
780     ESYS_CONTEXT *esysContext,
781     ESYS_TR activateHandle,
782     ESYS_TR keyHandle,
783     ESYS_TR shandle1,
784     ESYS_TR shandle2,
785     ESYS_TR shandle3,
786     const TPM2B_ID_OBJECT *credentialBlob,
787     const TPM2B_ENCRYPTED_SECRET *secret,
788     TPM2B_DIGEST **certInfo);
789 
790 TSS2_RC
791 Esys_ActivateCredential_Async(
792     ESYS_CONTEXT *esysContext,
793     ESYS_TR activateHandle,
794     ESYS_TR keyHandle,
795     ESYS_TR shandle1,
796     ESYS_TR shandle2,
797     ESYS_TR shandle3,
798     const TPM2B_ID_OBJECT *credentialBlob,
799     const TPM2B_ENCRYPTED_SECRET *secret);
800 
801 TSS2_RC
802 Esys_ActivateCredential_Finish(
803     ESYS_CONTEXT *esysContext,
804     TPM2B_DIGEST **certInfo);
805 
806 TSS2_RC
807 Esys_ACT_SetTimeout(
808     ESYS_CONTEXT *esysContext,
809     ESYS_TR actHandle,
810     ESYS_TR shandle1,
811     ESYS_TR shandle2,
812     ESYS_TR shandle3,
813     UINT32 startTimeout);
814 
815 TSS2_RC
816 Esys_ACT_SetTimeout_Async(
817     ESYS_CONTEXT *esysContext,
818     ESYS_TR actHandle,
819     ESYS_TR shandle1,
820     ESYS_TR shandle2,
821     ESYS_TR shandle3,
822     UINT32 startTimeout);
823 
824 TSS2_RC
825 Esys_ACT_SetTimeout_Finish(
826     ESYS_CONTEXT *esysContext);
827 
828 TSS2_RC
829 Esys_AC_GetCapability_Async(
830     ESYS_CONTEXT *esysContext,
831     ESYS_TR optionalSession1,
832     ESYS_TR optionalSession2,
833     ESYS_TR optionalSession3,
834     ESYS_TR ac,
835     TPM_AT capability,
836     UINT32 count);
837 
838 TSS2_RC
839 Esys_AC_GetCapability_Finish(
840     ESYS_CONTEXT *esysContext,
841     TPMI_YES_NO *moreData,
842     TPML_AC_CAPABILITIES **capabilityData);
843 
844 TSS2_RC
845 Esys_AC_GetCapability(
846     ESYS_CONTEXT *esysContext,
847     ESYS_TR optionalSession1,
848     ESYS_TR optionalSession2,
849     ESYS_TR optionalSession3,
850     ESYS_TR ac,
851     TPM_AT capability,
852     UINT32 count,
853     TPMI_YES_NO *moreData,
854     TPML_AC_CAPABILITIES **capabilityData);
855 
856 TSS2_RC
857 Esys_AC_Send_Async(
858     ESYS_CONTEXT *esysContext,
859     ESYS_TR sendObject,
860     ESYS_TR nvAuthHandle,
861     ESYS_TR optionalSession1,
862     ESYS_TR optionalSession2,
863     ESYS_TR optionalSession3,
864     ESYS_TR ac,
865     TPM2B_MAX_BUFFER *acDataIn);
866 
867 TSS2_RC
868 Esys_AC_Send_Finish(
869     ESYS_CONTEXT *esysContext,
870     TPMS_AC_OUTPUT **acDataOut);
871 
872 TSS2_RC
873 Esys_AC_Send(
874     ESYS_CONTEXT *esysContext,
875     ESYS_TR sendObject,
876     ESYS_TR nvAuthHandle,
877     ESYS_TR optionalSession1,
878     ESYS_TR optionalSession2,
879     ESYS_TR optionalSession3,
880     ESYS_TR ac,
881     TPM2B_MAX_BUFFER *acDataIn,
882     TPMS_AC_OUTPUT **acDataOut);
883 
884 TSS2_RC
885 Esys_Policy_AC_SendSelect_Async(
886     ESYS_CONTEXT *esysContext,
887     ESYS_TR policySession1,
888     ESYS_TR optionalSession2,
889     ESYS_TR optionalSession3,
890     TPM2B_NAME *objectName,
891     TPM2B_NAME *authHandleName,
892     TPM2B_NAME *acName,
893     const TPMI_YES_NO includeObject);
894 
895 TSS2_RC
896 Esys_Policy_AC_SendSelect_Finish(
897     ESYS_CONTEXT *esysContext);
898 
899 TSS2_RC
900 Esys_Policy_AC_SendSelect(
901     ESYS_CONTEXT *esysContext,
902     ESYS_TR policySession1,
903     ESYS_TR optionalSession2,
904     ESYS_TR optionalSession3,
905     TPM2B_NAME *objectName,
906     TPM2B_NAME *authHandleName,
907     TPM2B_NAME *acName,
908     TPMI_YES_NO includeObject);
909 
910 /* Table 29 - TPM2_MakeCredential Command */
911 
912 TSS2_RC
913 Esys_MakeCredential(
914     ESYS_CONTEXT *esysContext,
915     ESYS_TR handle,
916     ESYS_TR shandle1,
917     ESYS_TR shandle2,
918     ESYS_TR shandle3,
919     const TPM2B_DIGEST *credential,
920     const TPM2B_NAME *objectName,
921     TPM2B_ID_OBJECT **credentialBlob,
922     TPM2B_ENCRYPTED_SECRET **secret);
923 
924 TSS2_RC
925 Esys_MakeCredential_Async(
926     ESYS_CONTEXT *esysContext,
927     ESYS_TR handle,
928     ESYS_TR shandle1,
929     ESYS_TR shandle2,
930     ESYS_TR shandle3,
931     const TPM2B_DIGEST *credential,
932     const TPM2B_NAME *objectName);
933 
934 TSS2_RC
935 Esys_MakeCredential_Finish(
936     ESYS_CONTEXT *esysContext,
937     TPM2B_ID_OBJECT **credentialBlob,
938     TPM2B_ENCRYPTED_SECRET **secret);
939 
940 /* Table 31 - TPM2_Unseal Command */
941 
942 TSS2_RC
943 Esys_Unseal(
944     ESYS_CONTEXT *esysContext,
945     ESYS_TR itemHandle,
946     ESYS_TR shandle1,
947     ESYS_TR shandle2,
948     ESYS_TR shandle3,
949     TPM2B_SENSITIVE_DATA **outData);
950 
951 TSS2_RC
952 Esys_Unseal_Async(
953     ESYS_CONTEXT *esysContext,
954     ESYS_TR itemHandle,
955     ESYS_TR shandle1,
956     ESYS_TR shandle2,
957     ESYS_TR shandle3);
958 
959 TSS2_RC
960 Esys_Unseal_Finish(
961     ESYS_CONTEXT *esysContext,
962     TPM2B_SENSITIVE_DATA **outData);
963 
964 /* Table 33 - TPM2_ObjectChangeAuth Command */
965 
966 TSS2_RC
967 Esys_ObjectChangeAuth(
968     ESYS_CONTEXT *esysContext,
969     ESYS_TR objectHandle,
970     ESYS_TR parentHandle,
971     ESYS_TR shandle1,
972     ESYS_TR shandle2,
973     ESYS_TR shandle3,
974     const TPM2B_AUTH *newAuth,
975     TPM2B_PRIVATE **outPrivate);
976 
977 TSS2_RC
978 Esys_ObjectChangeAuth_Async(
979     ESYS_CONTEXT *esysContext,
980     ESYS_TR objectHandle,
981     ESYS_TR parentHandle,
982     ESYS_TR shandle1,
983     ESYS_TR shandle2,
984     ESYS_TR shandle3,
985     const TPM2B_AUTH *newAuth);
986 
987 TSS2_RC
988 Esys_ObjectChangeAuth_Finish(
989     ESYS_CONTEXT *esysContext,
990     TPM2B_PRIVATE **outPrivate);
991 
992 /* Table 35 - TPM2_CreateLoaded Command */
993 
994 TSS2_RC
995 Esys_CreateLoaded(
996     ESYS_CONTEXT *esysContext,
997     ESYS_TR parentHandle,
998     ESYS_TR shandle1,
999     ESYS_TR shandle2,
1000     ESYS_TR shandle3,
1001     const TPM2B_SENSITIVE_CREATE *inSensitive,
1002     const TPM2B_TEMPLATE *inPublic,
1003     ESYS_TR *objectHandle,
1004     TPM2B_PRIVATE **outPrivate,
1005     TPM2B_PUBLIC **outPublic);
1006 
1007 TSS2_RC
1008 Esys_CreateLoaded_Async(
1009     ESYS_CONTEXT *esysContext,
1010     ESYS_TR parentHandle,
1011     ESYS_TR shandle1,
1012     ESYS_TR shandle2,
1013     ESYS_TR shandle3,
1014     const TPM2B_SENSITIVE_CREATE *inSensitive,
1015     const TPM2B_TEMPLATE *inPublic);
1016 
1017 TSS2_RC
1018 Esys_CreateLoaded_Finish(
1019     ESYS_CONTEXT *esysContext,
1020     ESYS_TR *objectHandle,
1021     TPM2B_PRIVATE **outPrivate,
1022     TPM2B_PUBLIC **outPublic);
1023 
1024 /* Table 37 - TPM2_Duplicate Command */
1025 
1026 TSS2_RC
1027 Esys_Duplicate(
1028     ESYS_CONTEXT *esysContext,
1029     ESYS_TR objectHandle,
1030     ESYS_TR newParentHandle,
1031     ESYS_TR shandle1,
1032     ESYS_TR shandle2,
1033     ESYS_TR shandle3,
1034     const TPM2B_DATA *encryptionKeyIn,
1035     const TPMT_SYM_DEF_OBJECT *symmetricAlg,
1036     TPM2B_DATA **encryptionKeyOut,
1037     TPM2B_PRIVATE **duplicate,
1038     TPM2B_ENCRYPTED_SECRET **outSymSeed);
1039 
1040 TSS2_RC
1041 Esys_Duplicate_Async(
1042     ESYS_CONTEXT *esysContext,
1043     ESYS_TR objectHandle,
1044     ESYS_TR newParentHandle,
1045     ESYS_TR shandle1,
1046     ESYS_TR shandle2,
1047     ESYS_TR shandle3,
1048     const TPM2B_DATA *encryptionKeyIn,
1049     const TPMT_SYM_DEF_OBJECT *symmetricAlg);
1050 
1051 TSS2_RC
1052 Esys_Duplicate_Finish(
1053     ESYS_CONTEXT *esysContext,
1054     TPM2B_DATA **encryptionKeyOut,
1055     TPM2B_PRIVATE **duplicate,
1056     TPM2B_ENCRYPTED_SECRET **outSymSeed);
1057 
1058 /* Table 39 - TPM2_Rewrap Command */
1059 
1060 TSS2_RC
1061 Esys_Rewrap(
1062     ESYS_CONTEXT *esysContext,
1063     ESYS_TR oldParent,
1064     ESYS_TR newParent,
1065     ESYS_TR shandle1,
1066     ESYS_TR shandle2,
1067     ESYS_TR shandle3,
1068     const TPM2B_PRIVATE *inDuplicate,
1069     const TPM2B_NAME *name,
1070     const TPM2B_ENCRYPTED_SECRET *inSymSeed,
1071     TPM2B_PRIVATE **outDuplicate,
1072     TPM2B_ENCRYPTED_SECRET **outSymSeed);
1073 
1074 TSS2_RC
1075 Esys_Rewrap_Async(
1076     ESYS_CONTEXT *esysContext,
1077     ESYS_TR oldParent,
1078     ESYS_TR newParent,
1079     ESYS_TR shandle1,
1080     ESYS_TR shandle2,
1081     ESYS_TR shandle3,
1082     const TPM2B_PRIVATE *inDuplicate,
1083     const TPM2B_NAME *name,
1084     const TPM2B_ENCRYPTED_SECRET *inSymSeed);
1085 
1086 TSS2_RC
1087 Esys_Rewrap_Finish(
1088     ESYS_CONTEXT *esysContext,
1089     TPM2B_PRIVATE **outDuplicate,
1090     TPM2B_ENCRYPTED_SECRET **outSymSeed);
1091 
1092 /* Table 41 - TPM2_Import Command */
1093 
1094 TSS2_RC
1095 Esys_Import(
1096     ESYS_CONTEXT *esysContext,
1097     ESYS_TR parentHandle,
1098     ESYS_TR shandle1,
1099     ESYS_TR shandle2,
1100     ESYS_TR shandle3,
1101     const TPM2B_DATA *encryptionKey,
1102     const TPM2B_PUBLIC *objectPublic,
1103     const TPM2B_PRIVATE *duplicate,
1104     const TPM2B_ENCRYPTED_SECRET *inSymSeed,
1105     const TPMT_SYM_DEF_OBJECT *symmetricAlg,
1106     TPM2B_PRIVATE **outPrivate);
1107 
1108 TSS2_RC
1109 Esys_Import_Async(
1110     ESYS_CONTEXT *esysContext,
1111     ESYS_TR parentHandle,
1112     ESYS_TR shandle1,
1113     ESYS_TR shandle2,
1114     ESYS_TR shandle3,
1115     const TPM2B_DATA *encryptionKey,
1116     const TPM2B_PUBLIC *objectPublic,
1117     const TPM2B_PRIVATE *duplicate,
1118     const TPM2B_ENCRYPTED_SECRET *inSymSeed,
1119     const TPMT_SYM_DEF_OBJECT *symmetricAlg);
1120 
1121 TSS2_RC
1122 Esys_Import_Finish(
1123     ESYS_CONTEXT *esysContext,
1124     TPM2B_PRIVATE **outPrivate);
1125 
1126 /* Table 45 - TPM2_RSA_Encrypt Command */
1127 
1128 TSS2_RC
1129 Esys_RSA_Encrypt(
1130     ESYS_CONTEXT *esysContext,
1131     ESYS_TR keyHandle,
1132     ESYS_TR shandle1,
1133     ESYS_TR shandle2,
1134     ESYS_TR shandle3,
1135     const TPM2B_PUBLIC_KEY_RSA *message,
1136     const TPMT_RSA_DECRYPT *inScheme,
1137     const TPM2B_DATA *label,
1138     TPM2B_PUBLIC_KEY_RSA **outData);
1139 
1140 TSS2_RC
1141 Esys_RSA_Encrypt_Async(
1142     ESYS_CONTEXT *esysContext,
1143     ESYS_TR keyHandle,
1144     ESYS_TR shandle1,
1145     ESYS_TR shandle2,
1146     ESYS_TR shandle3,
1147     const TPM2B_PUBLIC_KEY_RSA *message,
1148     const TPMT_RSA_DECRYPT *inScheme,
1149     const TPM2B_DATA *label);
1150 
1151 TSS2_RC
1152 Esys_RSA_Encrypt_Finish(
1153     ESYS_CONTEXT *esysContext,
1154     TPM2B_PUBLIC_KEY_RSA **outData);
1155 
1156 /* Table 47 - TPM2_RSA_Decrypt Command */
1157 
1158 TSS2_RC
1159 Esys_RSA_Decrypt(
1160     ESYS_CONTEXT *esysContext,
1161     ESYS_TR keyHandle,
1162     ESYS_TR shandle1,
1163     ESYS_TR shandle2,
1164     ESYS_TR shandle3,
1165     const TPM2B_PUBLIC_KEY_RSA *cipherText,
1166     const TPMT_RSA_DECRYPT *inScheme,
1167     const TPM2B_DATA *label,
1168     TPM2B_PUBLIC_KEY_RSA **message);
1169 
1170 TSS2_RC
1171 Esys_RSA_Decrypt_Async(
1172     ESYS_CONTEXT *esysContext,
1173     ESYS_TR keyHandle,
1174     ESYS_TR shandle1,
1175     ESYS_TR shandle2,
1176     ESYS_TR shandle3,
1177     const TPM2B_PUBLIC_KEY_RSA *cipherText,
1178     const TPMT_RSA_DECRYPT *inScheme,
1179     const TPM2B_DATA *label);
1180 
1181 TSS2_RC
1182 Esys_RSA_Decrypt_Finish(
1183     ESYS_CONTEXT *esysContext,
1184     TPM2B_PUBLIC_KEY_RSA **message);
1185 
1186 /* Table 49 - TPM2_ECDH_KeyGen Command */
1187 
1188 TSS2_RC
1189 Esys_ECDH_KeyGen(
1190     ESYS_CONTEXT *esysContext,
1191     ESYS_TR keyHandle,
1192     ESYS_TR shandle1,
1193     ESYS_TR shandle2,
1194     ESYS_TR shandle3,
1195     TPM2B_ECC_POINT **zPoint,
1196     TPM2B_ECC_POINT **pubPoint);
1197 
1198 TSS2_RC
1199 Esys_ECDH_KeyGen_Async(
1200     ESYS_CONTEXT *esysContext,
1201     ESYS_TR keyHandle,
1202     ESYS_TR shandle1,
1203     ESYS_TR shandle2,
1204     ESYS_TR shandle3);
1205 
1206 TSS2_RC
1207 Esys_ECDH_KeyGen_Finish(
1208     ESYS_CONTEXT *esysContext,
1209     TPM2B_ECC_POINT **zPoint,
1210     TPM2B_ECC_POINT **pubPoint);
1211 
1212 /* Table 51 - TPM2_ECDH_ZGen Command */
1213 
1214 TSS2_RC
1215 Esys_ECDH_ZGen(
1216     ESYS_CONTEXT *esysContext,
1217     ESYS_TR keyHandle,
1218     ESYS_TR shandle1,
1219     ESYS_TR shandle2,
1220     ESYS_TR shandle3,
1221     const TPM2B_ECC_POINT *inPoint,
1222     TPM2B_ECC_POINT **outPoint);
1223 
1224 TSS2_RC
1225 Esys_ECDH_ZGen_Async(
1226     ESYS_CONTEXT *esysContext,
1227     ESYS_TR keyHandle,
1228     ESYS_TR shandle1,
1229     ESYS_TR shandle2,
1230     ESYS_TR shandle3,
1231     const TPM2B_ECC_POINT *inPoint);
1232 
1233 TSS2_RC
1234 Esys_ECDH_ZGen_Finish(
1235     ESYS_CONTEXT *esysContext,
1236     TPM2B_ECC_POINT **outPoint);
1237 
1238 /* Table 53 - TPM2_ECC_Parameters Command */
1239 
1240 TSS2_RC
1241 Esys_ECC_Parameters(
1242     ESYS_CONTEXT *esysContext,
1243     ESYS_TR shandle1,
1244     ESYS_TR shandle2,
1245     ESYS_TR shandle3,
1246     TPMI_ECC_CURVE curveID,
1247     TPMS_ALGORITHM_DETAIL_ECC **parameters);
1248 
1249 TSS2_RC
1250 Esys_ECC_Parameters_Async(
1251     ESYS_CONTEXT *esysContext,
1252     ESYS_TR shandle1,
1253     ESYS_TR shandle2,
1254     ESYS_TR shandle3,
1255     TPMI_ECC_CURVE curveID);
1256 
1257 TSS2_RC
1258 Esys_ECC_Parameters_Finish(
1259     ESYS_CONTEXT *esysContext,
1260     TPMS_ALGORITHM_DETAIL_ECC **parameters);
1261 
1262 /* Table 55 - TPM2_ZGen_2Phase Command */
1263 
1264 TSS2_RC
1265 Esys_ZGen_2Phase(
1266     ESYS_CONTEXT *esysContext,
1267     ESYS_TR keyA,
1268     ESYS_TR shandle1,
1269     ESYS_TR shandle2,
1270     ESYS_TR shandle3,
1271     const TPM2B_ECC_POINT *inQsB,
1272     const TPM2B_ECC_POINT *inQeB,
1273     TPMI_ECC_KEY_EXCHANGE inScheme,
1274     UINT16 counter,
1275     TPM2B_ECC_POINT **outZ1,
1276     TPM2B_ECC_POINT **outZ2);
1277 
1278 TSS2_RC
1279 Esys_ZGen_2Phase_Async(
1280     ESYS_CONTEXT *esysContext,
1281     ESYS_TR keyA,
1282     ESYS_TR shandle1,
1283     ESYS_TR shandle2,
1284     ESYS_TR shandle3,
1285     const TPM2B_ECC_POINT *inQsB,
1286     const TPM2B_ECC_POINT *inQeB,
1287     TPMI_ECC_KEY_EXCHANGE inScheme,
1288     UINT16 counter);
1289 
1290 TSS2_RC
1291 Esys_ZGen_2Phase_Finish(
1292     ESYS_CONTEXT *esysContext,
1293     TPM2B_ECC_POINT **outZ1,
1294     TPM2B_ECC_POINT **outZ2);
1295 
1296 /* Table 58 - TPM2_EncryptDecrypt Command */
1297 
1298 TSS2_RC
1299 Esys_EncryptDecrypt(
1300     ESYS_CONTEXT *esysContext,
1301     ESYS_TR keyHandle,
1302     ESYS_TR shandle1,
1303     ESYS_TR shandle2,
1304     ESYS_TR shandle3,
1305     TPMI_YES_NO decrypt,
1306     TPMI_ALG_CIPHER_MODE mode,
1307     const TPM2B_IV *ivIn,
1308     const TPM2B_MAX_BUFFER *inData,
1309     TPM2B_MAX_BUFFER **outData,
1310     TPM2B_IV **ivOut);
1311 
1312 TSS2_RC
1313 Esys_EncryptDecrypt_Async(
1314     ESYS_CONTEXT *esysContext,
1315     ESYS_TR keyHandle,
1316     ESYS_TR shandle1,
1317     ESYS_TR shandle2,
1318     ESYS_TR shandle3,
1319     TPMI_YES_NO decrypt,
1320     TPMI_ALG_CIPHER_MODE mode,
1321     const TPM2B_IV *ivIn,
1322     const TPM2B_MAX_BUFFER *inData);
1323 
1324 TSS2_RC
1325 Esys_EncryptDecrypt_Finish(
1326     ESYS_CONTEXT *esysContext,
1327     TPM2B_MAX_BUFFER **outData,
1328     TPM2B_IV **ivOut);
1329 
1330 /* Table 60 - TPM2_EncryptDecrypt2 Command */
1331 
1332 TSS2_RC
1333 Esys_EncryptDecrypt2(
1334     ESYS_CONTEXT *esysContext,
1335     ESYS_TR keyHandle,
1336     ESYS_TR shandle1,
1337     ESYS_TR shandle2,
1338     ESYS_TR shandle3,
1339     const TPM2B_MAX_BUFFER *inData,
1340     TPMI_YES_NO decrypt,
1341     TPMI_ALG_CIPHER_MODE mode,
1342     const TPM2B_IV *ivIn,
1343     TPM2B_MAX_BUFFER **outData,
1344     TPM2B_IV **ivOut);
1345 
1346 TSS2_RC
1347 Esys_EncryptDecrypt2_Async(
1348     ESYS_CONTEXT *esysContext,
1349     ESYS_TR keyHandle,
1350     ESYS_TR shandle1,
1351     ESYS_TR shandle2,
1352     ESYS_TR shandle3,
1353     const TPM2B_MAX_BUFFER *inData,
1354     TPMI_YES_NO decrypt,
1355     TPMI_ALG_CIPHER_MODE mode,
1356     const TPM2B_IV *ivIn);
1357 
1358 TSS2_RC
1359 Esys_EncryptDecrypt2_Finish(
1360     ESYS_CONTEXT *esysContext,
1361     TPM2B_MAX_BUFFER **outData,
1362     TPM2B_IV **ivOut);
1363 
1364 /* Table 62 - TPM2_Hash Command */
1365 
1366 TSS2_RC
1367 Esys_Hash(
1368     ESYS_CONTEXT *esysContext,
1369     ESYS_TR shandle1,
1370     ESYS_TR shandle2,
1371     ESYS_TR shandle3,
1372     const TPM2B_MAX_BUFFER *data,
1373     TPMI_ALG_HASH hashAlg,
1374     ESYS_TR hierarchy,
1375     TPM2B_DIGEST **outHash,
1376     TPMT_TK_HASHCHECK **validation);
1377 
1378 TSS2_RC
1379 Esys_Hash_Async(
1380     ESYS_CONTEXT *esysContext,
1381     ESYS_TR shandle1,
1382     ESYS_TR shandle2,
1383     ESYS_TR shandle3,
1384     const TPM2B_MAX_BUFFER *data,
1385     TPMI_ALG_HASH hashAlg,
1386     ESYS_TR hierarchy);
1387 
1388 TSS2_RC
1389 Esys_Hash_Finish(
1390     ESYS_CONTEXT *esysContext,
1391     TPM2B_DIGEST **outHash,
1392     TPMT_TK_HASHCHECK **validation);
1393 
1394 /* Table 64 - TPM2_HMAC Command */
1395 
1396 TSS2_RC
1397 Esys_HMAC(
1398     ESYS_CONTEXT *esysContext,
1399     ESYS_TR handle,
1400     ESYS_TR shandle1,
1401     ESYS_TR shandle2,
1402     ESYS_TR shandle3,
1403     const TPM2B_MAX_BUFFER *buffer,
1404     TPMI_ALG_HASH hashAlg,
1405     TPM2B_DIGEST **outHMAC);
1406 
1407 TSS2_RC
1408 Esys_HMAC_Async(
1409     ESYS_CONTEXT *esysContext,
1410     ESYS_TR handle,
1411     ESYS_TR shandle1,
1412     ESYS_TR shandle2,
1413     ESYS_TR shandle3,
1414     const TPM2B_MAX_BUFFER *buffer,
1415     TPMI_ALG_HASH hashAlg);
1416 
1417 TSS2_RC
1418 Esys_HMAC_Finish(
1419     ESYS_CONTEXT *esysContext,
1420     TPM2B_DIGEST **outHMAC);
1421 
1422 TSS2_RC
1423 Esys_MAC_Async(
1424     ESYS_CONTEXT *esysContext,
1425     ESYS_TR handle,
1426     ESYS_TR handleSession1,
1427     ESYS_TR optionalSession2,
1428     ESYS_TR optionalSession3,
1429     const TPM2B_MAX_BUFFER *buffer,
1430     TPMI_ALG_MAC_SCHEME inScheme);
1431 
1432 TSS2_RC
1433 Esys_MAC_Finish(
1434     ESYS_CONTEXT *esysContext,
1435     TPM2B_DIGEST **outMAC);
1436 
1437 TSS2_RC
1438 Esys_MAC(
1439     ESYS_CONTEXT *esysContext,
1440     ESYS_TR handle,
1441     ESYS_TR handleSession1,
1442     ESYS_TR optionalSession2,
1443     ESYS_TR optionalSession3,
1444     const TPM2B_MAX_BUFFER *buffer,
1445     TPMI_ALG_MAC_SCHEME inScheme,
1446     TPM2B_DIGEST **outMAC);
1447 
1448 /* Table 66 - TPM2_GetRandom Command */
1449 
1450 TSS2_RC
1451 Esys_GetRandom(
1452     ESYS_CONTEXT *esysContext,
1453     ESYS_TR shandle1,
1454     ESYS_TR shandle2,
1455     ESYS_TR shandle3,
1456     UINT16 bytesRequested,
1457     TPM2B_DIGEST **randomBytes);
1458 
1459 TSS2_RC
1460 Esys_GetRandom_Async(
1461     ESYS_CONTEXT *esysContext,
1462     ESYS_TR shandle1,
1463     ESYS_TR shandle2,
1464     ESYS_TR shandle3,
1465     UINT16 bytesRequested);
1466 
1467 TSS2_RC
1468 Esys_GetRandom_Finish(
1469     ESYS_CONTEXT *esysContext,
1470     TPM2B_DIGEST **randomBytes);
1471 
1472 /* Table 68 - TPM2_StirRandom Command */
1473 
1474 TSS2_RC
1475 Esys_StirRandom(
1476     ESYS_CONTEXT *esysContext,
1477     ESYS_TR shandle1,
1478     ESYS_TR shandle2,
1479     ESYS_TR shandle3,
1480     const TPM2B_SENSITIVE_DATA *inData);
1481 
1482 TSS2_RC
1483 Esys_StirRandom_Async(
1484     ESYS_CONTEXT *esysContext,
1485     ESYS_TR shandle1,
1486     ESYS_TR shandle2,
1487     ESYS_TR shandle3,
1488     const TPM2B_SENSITIVE_DATA *inData);
1489 
1490 TSS2_RC
1491 Esys_StirRandom_Finish(
1492     ESYS_CONTEXT *esysContext);
1493 
1494 /* Table 71 - TPM2_HMAC_Start Command */
1495 
1496 TSS2_RC
1497 Esys_HMAC_Start(
1498     ESYS_CONTEXT *esysContext,
1499     ESYS_TR handle,
1500     ESYS_TR shandle1,
1501     ESYS_TR shandle2,
1502     ESYS_TR shandle3,
1503     const TPM2B_AUTH *auth,
1504     TPMI_ALG_HASH hashAlg,
1505     ESYS_TR *sequenceHandle);
1506 
1507 TSS2_RC
1508 Esys_HMAC_Start_Async(
1509     ESYS_CONTEXT *esysContext,
1510     ESYS_TR handle,
1511     ESYS_TR shandle1,
1512     ESYS_TR shandle2,
1513     ESYS_TR shandle3,
1514     const TPM2B_AUTH *auth,
1515     TPMI_ALG_HASH hashAlg);
1516 
1517 TSS2_RC
1518 Esys_HMAC_Start_Finish(
1519     ESYS_CONTEXT *esysContext,
1520     ESYS_TR *sequenceHandle);
1521 
1522 TSS2_RC
1523 Esys_MAC_Start(
1524     ESYS_CONTEXT *esysContext,
1525     ESYS_TR handle,
1526     ESYS_TR handleSession1,
1527     ESYS_TR optionalSession2,
1528     ESYS_TR optionalSession3,
1529     const TPM2B_AUTH *auth,
1530     TPMI_ALG_MAC_SCHEME inScheme,
1531     ESYS_TR *sequenceHandle);
1532 
1533 TSS2_RC
1534 Esys_MAC_Start_Async(
1535     ESYS_CONTEXT *esysContext,
1536     ESYS_TR handle,
1537     ESYS_TR handleSession1,
1538     ESYS_TR optionalSession2,
1539     ESYS_TR optionalSession3,
1540     const TPM2B_AUTH *auth,
1541     TPMI_ALG_MAC_SCHEME inScheme);
1542 
1543 TSS2_RC
1544 Esys_MAC_Start_Finish(
1545     ESYS_CONTEXT *esysContext,
1546     ESYS_TR *sequenceHandle);
1547 
1548 /* Table 73 - TPM2_HashSequenceStart Command */
1549 
1550 TSS2_RC
1551 Esys_HashSequenceStart(
1552     ESYS_CONTEXT *esysContext,
1553     ESYS_TR shandle1,
1554     ESYS_TR shandle2,
1555     ESYS_TR shandle3,
1556     const TPM2B_AUTH *auth,
1557     TPMI_ALG_HASH hashAlg,
1558     ESYS_TR *sequenceHandle);
1559 
1560 TSS2_RC
1561 Esys_HashSequenceStart_Async(
1562     ESYS_CONTEXT *esysContext,
1563     ESYS_TR shandle1,
1564     ESYS_TR shandle2,
1565     ESYS_TR shandle3,
1566     const TPM2B_AUTH *auth,
1567     TPMI_ALG_HASH hashAlg);
1568 
1569 TSS2_RC
1570 Esys_HashSequenceStart_Finish(
1571     ESYS_CONTEXT *esysContext,
1572     ESYS_TR *sequenceHandle);
1573 
1574 /* Table 75 - TPM2_SequenceUpdate Command */
1575 
1576 TSS2_RC
1577 Esys_SequenceUpdate(
1578     ESYS_CONTEXT *esysContext,
1579     ESYS_TR sequenceHandle,
1580     ESYS_TR shandle1,
1581     ESYS_TR shandle2,
1582     ESYS_TR shandle3,
1583     const TPM2B_MAX_BUFFER *buffer);
1584 
1585 TSS2_RC
1586 Esys_SequenceUpdate_Async(
1587     ESYS_CONTEXT *esysContext,
1588     ESYS_TR sequenceHandle,
1589     ESYS_TR shandle1,
1590     ESYS_TR shandle2,
1591     ESYS_TR shandle3,
1592     const TPM2B_MAX_BUFFER *buffer);
1593 
1594 TSS2_RC
1595 Esys_SequenceUpdate_Finish(
1596     ESYS_CONTEXT *esysContext);
1597 
1598 /* Table 77 - TPM2_SequenceComplete Command */
1599 
1600 TSS2_RC
1601 Esys_SequenceComplete(
1602     ESYS_CONTEXT *esysContext,
1603     ESYS_TR sequenceHandle,
1604     ESYS_TR shandle1,
1605     ESYS_TR shandle2,
1606     ESYS_TR shandle3,
1607     const TPM2B_MAX_BUFFER *buffer,
1608     ESYS_TR hierarchy,
1609     TPM2B_DIGEST **result,
1610     TPMT_TK_HASHCHECK **validation);
1611 
1612 TSS2_RC
1613 Esys_SequenceComplete_Async(
1614     ESYS_CONTEXT *esysContext,
1615     ESYS_TR sequenceHandle,
1616     ESYS_TR shandle1,
1617     ESYS_TR shandle2,
1618     ESYS_TR shandle3,
1619     const TPM2B_MAX_BUFFER *buffer,
1620     ESYS_TR hierarchy);
1621 
1622 TSS2_RC
1623 Esys_SequenceComplete_Finish(
1624     ESYS_CONTEXT *esysContext,
1625     TPM2B_DIGEST **result,
1626     TPMT_TK_HASHCHECK **validation);
1627 
1628 /* Table 79 - TPM2_EventSequenceComplete Command */
1629 
1630 TSS2_RC
1631 Esys_EventSequenceComplete(
1632     ESYS_CONTEXT *esysContext,
1633     ESYS_TR pcrHandle,
1634     ESYS_TR sequenceHandle,
1635     ESYS_TR shandle1,
1636     ESYS_TR shandle2,
1637     ESYS_TR shandle3,
1638     const TPM2B_MAX_BUFFER *buffer,
1639     TPML_DIGEST_VALUES **results);
1640 
1641 TSS2_RC
1642 Esys_EventSequenceComplete_Async(
1643     ESYS_CONTEXT *esysContext,
1644     ESYS_TR pcrHandle,
1645     ESYS_TR sequenceHandle,
1646     ESYS_TR shandle1,
1647     ESYS_TR shandle2,
1648     ESYS_TR shandle3,
1649     const TPM2B_MAX_BUFFER *buffer);
1650 
1651 TSS2_RC
1652 Esys_EventSequenceComplete_Finish(
1653     ESYS_CONTEXT *esysContext,
1654     TPML_DIGEST_VALUES **results);
1655 
1656 /* Table 81 - TPM2_Certify Command */
1657 
1658 TSS2_RC
1659 Esys_Certify(
1660     ESYS_CONTEXT *esysContext,
1661     ESYS_TR objectHandle,
1662     ESYS_TR signHandle,
1663     ESYS_TR shandle1,
1664     ESYS_TR shandle2,
1665     ESYS_TR shandle3,
1666     const TPM2B_DATA *qualifyingData,
1667     const TPMT_SIG_SCHEME *inScheme,
1668     TPM2B_ATTEST **certifyInfo,
1669     TPMT_SIGNATURE **signature);
1670 
1671 TSS2_RC
1672 Esys_Certify_Async(
1673     ESYS_CONTEXT *esysContext,
1674     ESYS_TR objectHandle,
1675     ESYS_TR signHandle,
1676     ESYS_TR shandle1,
1677     ESYS_TR shandle2,
1678     ESYS_TR shandle3,
1679     const TPM2B_DATA *qualifyingData,
1680     const TPMT_SIG_SCHEME *inScheme);
1681 
1682 TSS2_RC
1683 Esys_Certify_Finish(
1684     ESYS_CONTEXT *esysContext,
1685     TPM2B_ATTEST **certifyInfo,
1686     TPMT_SIGNATURE **signature);
1687 
1688 /* Table 83 - TPM2_CertifyCreation Command */
1689 
1690 TSS2_RC
1691 Esys_CertifyCreation(
1692     ESYS_CONTEXT *esysContext,
1693     ESYS_TR signHandle,
1694     ESYS_TR objectHandle,
1695     ESYS_TR shandle1,
1696     ESYS_TR shandle2,
1697     ESYS_TR shandle3,
1698     const TPM2B_DATA *qualifyingData,
1699     const TPM2B_DIGEST *creationHash,
1700     const TPMT_SIG_SCHEME *inScheme,
1701     const TPMT_TK_CREATION *creationTicket,
1702     TPM2B_ATTEST **certifyInfo,
1703     TPMT_SIGNATURE **signature);
1704 
1705 TSS2_RC
1706 Esys_CertifyCreation_Async(
1707     ESYS_CONTEXT *esysContext,
1708     ESYS_TR signHandle,
1709     ESYS_TR objectHandle,
1710     ESYS_TR shandle1,
1711     ESYS_TR shandle2,
1712     ESYS_TR shandle3,
1713     const TPM2B_DATA *qualifyingData,
1714     const TPM2B_DIGEST *creationHash,
1715     const TPMT_SIG_SCHEME *inScheme,
1716     const TPMT_TK_CREATION *creationTicket);
1717 
1718 TSS2_RC
1719 Esys_CertifyCreation_Finish(
1720     ESYS_CONTEXT *esysContext,
1721     TPM2B_ATTEST **certifyInfo,
1722     TPMT_SIGNATURE **signature);
1723 
1724 TSS2_RC
1725 Esys_CertifyX509(
1726     ESYS_CONTEXT *esysContext,
1727     ESYS_TR objectHandle,
1728     ESYS_TR signHandle,
1729     ESYS_TR shandle1,
1730     ESYS_TR shandle2,
1731     ESYS_TR shandle3,
1732     const TPM2B_DATA *reserved,
1733     const TPMT_SIG_SCHEME *inScheme,
1734     const TPM2B_MAX_BUFFER *partialCertificate,
1735     TPM2B_MAX_BUFFER **addedToCertificate,
1736     TPM2B_DIGEST **tbsDigest,
1737     TPMT_SIGNATURE **signature);
1738 
1739 TSS2_RC
1740 Esys_CertifyX509_Async(
1741     ESYS_CONTEXT *esysContext,
1742     ESYS_TR objectHandle,
1743     ESYS_TR signHandle,
1744     ESYS_TR shandle1,
1745     ESYS_TR shandle2,
1746     ESYS_TR shandle3,
1747     const TPM2B_DATA *reserved,
1748     const TPMT_SIG_SCHEME *inScheme,
1749     const TPM2B_MAX_BUFFER *partialCertificate);
1750 
1751 TSS2_RC
1752 Esys_CertifyX509_Finish(
1753     ESYS_CONTEXT *esysContext,
1754     TPM2B_MAX_BUFFER **addedToCertificate,
1755     TPM2B_DIGEST **tbsDigest,
1756     TPMT_SIGNATURE **signature);
1757 
1758 /* Table 85 - TPM2_Quote Command */
1759 
1760 TSS2_RC
1761 Esys_Quote(
1762     ESYS_CONTEXT *esysContext,
1763     ESYS_TR signHandle,
1764     ESYS_TR shandle1,
1765     ESYS_TR shandle2,
1766     ESYS_TR shandle3,
1767     const TPM2B_DATA *qualifyingData,
1768     const TPMT_SIG_SCHEME *inScheme,
1769     const TPML_PCR_SELECTION *PCRselect,
1770     TPM2B_ATTEST **quoted,
1771     TPMT_SIGNATURE **signature);
1772 
1773 TSS2_RC
1774 Esys_Quote_Async(
1775     ESYS_CONTEXT *esysContext,
1776     ESYS_TR signHandle,
1777     ESYS_TR shandle1,
1778     ESYS_TR shandle2,
1779     ESYS_TR shandle3,
1780     const TPM2B_DATA *qualifyingData,
1781     const TPMT_SIG_SCHEME *inScheme,
1782     const TPML_PCR_SELECTION *PCRselect);
1783 
1784 TSS2_RC
1785 Esys_Quote_Finish(
1786     ESYS_CONTEXT *esysContext,
1787     TPM2B_ATTEST **quoted,
1788     TPMT_SIGNATURE **signature);
1789 
1790 /* Table 87 - TPM2_GetSessionAuditDigest Command */
1791 
1792 TSS2_RC
1793 Esys_GetSessionAuditDigest(
1794     ESYS_CONTEXT *esysContext,
1795     ESYS_TR privacyAdminHandle,
1796     ESYS_TR signHandle,
1797     ESYS_TR sessionHandle,
1798     ESYS_TR shandle1,
1799     ESYS_TR shandle2,
1800     ESYS_TR shandle3,
1801     const TPM2B_DATA *qualifyingData,
1802     const TPMT_SIG_SCHEME *inScheme,
1803     TPM2B_ATTEST **auditInfo,
1804     TPMT_SIGNATURE **signature);
1805 
1806 TSS2_RC
1807 Esys_GetSessionAuditDigest_Async(
1808     ESYS_CONTEXT *esysContext,
1809     ESYS_TR privacyAdminHandle,
1810     ESYS_TR signHandle,
1811     ESYS_TR sessionHandle,
1812     ESYS_TR shandle1,
1813     ESYS_TR shandle2,
1814     ESYS_TR shandle3,
1815     const TPM2B_DATA *qualifyingData,
1816     const TPMT_SIG_SCHEME *inScheme);
1817 
1818 TSS2_RC
1819 Esys_GetSessionAuditDigest_Finish(
1820     ESYS_CONTEXT *esysContext,
1821     TPM2B_ATTEST **auditInfo,
1822     TPMT_SIGNATURE **signature);
1823 
1824 /* Table 89 - TPM2_GetCommandAuditDigest Command */
1825 
1826 TSS2_RC
1827 Esys_GetCommandAuditDigest(
1828     ESYS_CONTEXT *esysContext,
1829     ESYS_TR privacyHandle,
1830     ESYS_TR signHandle,
1831     ESYS_TR shandle1,
1832     ESYS_TR shandle2,
1833     ESYS_TR shandle3,
1834     const TPM2B_DATA *qualifyingData,
1835     const TPMT_SIG_SCHEME *inScheme,
1836     TPM2B_ATTEST **auditInfo,
1837     TPMT_SIGNATURE **signature);
1838 
1839 TSS2_RC
1840 Esys_GetCommandAuditDigest_Async(
1841     ESYS_CONTEXT *esysContext,
1842     ESYS_TR privacyHandle,
1843     ESYS_TR signHandle,
1844     ESYS_TR shandle1,
1845     ESYS_TR shandle2,
1846     ESYS_TR shandle3,
1847     const TPM2B_DATA *qualifyingData,
1848     const TPMT_SIG_SCHEME *inScheme);
1849 
1850 TSS2_RC
1851 Esys_GetCommandAuditDigest_Finish(
1852     ESYS_CONTEXT *esysContext,
1853     TPM2B_ATTEST **auditInfo,
1854     TPMT_SIGNATURE **signature);
1855 
1856 /* Table 91 - TPM2_GetTime Command */
1857 
1858 TSS2_RC
1859 Esys_GetTime(
1860     ESYS_CONTEXT *esysContext,
1861     ESYS_TR privacyAdminHandle,
1862     ESYS_TR signHandle,
1863     ESYS_TR shandle1,
1864     ESYS_TR shandle2,
1865     ESYS_TR shandle3,
1866     const TPM2B_DATA *qualifyingData,
1867     const TPMT_SIG_SCHEME *inScheme,
1868     TPM2B_ATTEST **timeInfo,
1869     TPMT_SIGNATURE **signature);
1870 
1871 TSS2_RC
1872 Esys_GetTime_Async(
1873     ESYS_CONTEXT *esysContext,
1874     ESYS_TR privacyAdminHandle,
1875     ESYS_TR signHandle,
1876     ESYS_TR shandle1,
1877     ESYS_TR shandle2,
1878     ESYS_TR shandle3,
1879     const TPM2B_DATA *qualifyingData,
1880     const TPMT_SIG_SCHEME *inScheme);
1881 
1882 TSS2_RC
1883 Esys_GetTime_Finish(
1884     ESYS_CONTEXT *esysContext,
1885     TPM2B_ATTEST **timeInfo,
1886     TPMT_SIGNATURE **signature);
1887 
1888 /* Table 93 - TPM2_Commit Command */
1889 
1890 TSS2_RC
1891 Esys_Commit(
1892     ESYS_CONTEXT *esysContext,
1893     ESYS_TR signHandle,
1894     ESYS_TR shandle1,
1895     ESYS_TR shandle2,
1896     ESYS_TR shandle3,
1897     const TPM2B_ECC_POINT *P1,
1898     const TPM2B_SENSITIVE_DATA *s2,
1899     const TPM2B_ECC_PARAMETER *y2,
1900     TPM2B_ECC_POINT **K,
1901     TPM2B_ECC_POINT **L,
1902     TPM2B_ECC_POINT **E,
1903     UINT16 *counter);
1904 
1905 TSS2_RC
1906 Esys_Commit_Async(
1907     ESYS_CONTEXT *esysContext,
1908     ESYS_TR signHandle,
1909     ESYS_TR shandle1,
1910     ESYS_TR shandle2,
1911     ESYS_TR shandle3,
1912     const TPM2B_ECC_POINT *P1,
1913     const TPM2B_SENSITIVE_DATA *s2,
1914     const TPM2B_ECC_PARAMETER *y2);
1915 
1916 TSS2_RC
1917 Esys_Commit_Finish(
1918     ESYS_CONTEXT *esysContext,
1919     TPM2B_ECC_POINT **K,
1920     TPM2B_ECC_POINT **L,
1921     TPM2B_ECC_POINT **E,
1922     UINT16 *counter);
1923 
1924 /* Table 95 - TPM2_EC_Ephemeral Command */
1925 
1926 TSS2_RC
1927 Esys_EC_Ephemeral(
1928     ESYS_CONTEXT *esysContext,
1929     ESYS_TR shandle1,
1930     ESYS_TR shandle2,
1931     ESYS_TR shandle3,
1932     TPMI_ECC_CURVE curveID,
1933     TPM2B_ECC_POINT **Q,
1934     UINT16 *counter);
1935 
1936 TSS2_RC
1937 Esys_EC_Ephemeral_Async(
1938     ESYS_CONTEXT *esysContext,
1939     ESYS_TR shandle1,
1940     ESYS_TR shandle2,
1941     ESYS_TR shandle3,
1942     TPMI_ECC_CURVE curveID);
1943 
1944 TSS2_RC
1945 Esys_EC_Ephemeral_Finish(
1946     ESYS_CONTEXT *esysContext,
1947     TPM2B_ECC_POINT **Q,
1948     UINT16 *counter);
1949 
1950 /* Table 97 - TPM2_VerifySignature Command */
1951 
1952 TSS2_RC
1953 Esys_VerifySignature(
1954     ESYS_CONTEXT *esysContext,
1955     ESYS_TR keyHandle,
1956     ESYS_TR shandle1,
1957     ESYS_TR shandle2,
1958     ESYS_TR shandle3,
1959     const TPM2B_DIGEST *digest,
1960     const TPMT_SIGNATURE *signature,
1961     TPMT_TK_VERIFIED **validation);
1962 
1963 TSS2_RC
1964 Esys_VerifySignature_Async(
1965     ESYS_CONTEXT *esysContext,
1966     ESYS_TR keyHandle,
1967     ESYS_TR shandle1,
1968     ESYS_TR shandle2,
1969     ESYS_TR shandle3,
1970     const TPM2B_DIGEST *digest,
1971     const TPMT_SIGNATURE *signature);
1972 
1973 TSS2_RC
1974 Esys_VerifySignature_Finish(
1975     ESYS_CONTEXT *esysContext,
1976     TPMT_TK_VERIFIED **validation);
1977 
1978 /* Table 99 - TPM2_Sign Command */
1979 
1980 TSS2_RC
1981 Esys_Sign(
1982     ESYS_CONTEXT *esysContext,
1983     ESYS_TR keyHandle,
1984     ESYS_TR shandle1,
1985     ESYS_TR shandle2,
1986     ESYS_TR shandle3,
1987     const TPM2B_DIGEST *digest,
1988     const TPMT_SIG_SCHEME *inScheme,
1989     const TPMT_TK_HASHCHECK *validation,
1990     TPMT_SIGNATURE **signature);
1991 
1992 TSS2_RC
1993 Esys_Sign_Async(
1994     ESYS_CONTEXT *esysContext,
1995     ESYS_TR keyHandle,
1996     ESYS_TR shandle1,
1997     ESYS_TR shandle2,
1998     ESYS_TR shandle3,
1999     const TPM2B_DIGEST *digest,
2000     const TPMT_SIG_SCHEME *inScheme,
2001     const TPMT_TK_HASHCHECK *validation);
2002 
2003 TSS2_RC
2004 Esys_Sign_Finish(
2005     ESYS_CONTEXT *esysContext,
2006     TPMT_SIGNATURE **signature);
2007 
2008 /* Table 101 - TPM2_SetCommandCodeAuditStatus Command */
2009 
2010 TSS2_RC
2011 Esys_SetCommandCodeAuditStatus(
2012     ESYS_CONTEXT *esysContext,
2013     ESYS_TR auth,
2014     ESYS_TR shandle1,
2015     ESYS_TR shandle2,
2016     ESYS_TR shandle3,
2017     TPMI_ALG_HASH auditAlg,
2018     const TPML_CC *setList,
2019     const TPML_CC *clearList);
2020 
2021 TSS2_RC
2022 Esys_SetCommandCodeAuditStatus_Async(
2023     ESYS_CONTEXT *esysContext,
2024     ESYS_TR auth,
2025     ESYS_TR shandle1,
2026     ESYS_TR shandle2,
2027     ESYS_TR shandle3,
2028     TPMI_ALG_HASH auditAlg,
2029     const TPML_CC *setList,
2030     const TPML_CC *clearList);
2031 
2032 TSS2_RC
2033 Esys_SetCommandCodeAuditStatus_Finish(
2034     ESYS_CONTEXT *esysContext);
2035 
2036 /* Table 103 - TPM2_PCR_Extend Command */
2037 
2038 TSS2_RC
2039 Esys_PCR_Extend(
2040     ESYS_CONTEXT *esysContext,
2041     ESYS_TR pcrHandle,
2042     ESYS_TR shandle1,
2043     ESYS_TR shandle2,
2044     ESYS_TR shandle3,
2045     const TPML_DIGEST_VALUES *digests);
2046 
2047 TSS2_RC
2048 Esys_PCR_Extend_Async(
2049     ESYS_CONTEXT *esysContext,
2050     ESYS_TR pcrHandle,
2051     ESYS_TR shandle1,
2052     ESYS_TR shandle2,
2053     ESYS_TR shandle3,
2054     const TPML_DIGEST_VALUES *digests);
2055 
2056 TSS2_RC
2057 Esys_PCR_Extend_Finish(
2058     ESYS_CONTEXT *esysContext);
2059 
2060 /* Table 105 - TPM2_PCR_Event Command */
2061 
2062 TSS2_RC
2063 Esys_PCR_Event(
2064     ESYS_CONTEXT *esysContext,
2065     ESYS_TR pcrHandle,
2066     ESYS_TR shandle1,
2067     ESYS_TR shandle2,
2068     ESYS_TR shandle3,
2069     const TPM2B_EVENT *eventData,
2070     TPML_DIGEST_VALUES **digests);
2071 
2072 TSS2_RC
2073 Esys_PCR_Event_Async(
2074     ESYS_CONTEXT *esysContext,
2075     ESYS_TR pcrHandle,
2076     ESYS_TR shandle1,
2077     ESYS_TR shandle2,
2078     ESYS_TR shandle3,
2079     const TPM2B_EVENT *eventData);
2080 
2081 TSS2_RC
2082 Esys_PCR_Event_Finish(
2083     ESYS_CONTEXT *esysContext,
2084     TPML_DIGEST_VALUES **digests);
2085 
2086 /* Table 107 - TPM2_PCR_Read Command */
2087 
2088 TSS2_RC
2089 Esys_PCR_Read(
2090     ESYS_CONTEXT *esysContext,
2091     ESYS_TR shandle1,
2092     ESYS_TR shandle2,
2093     ESYS_TR shandle3,
2094     const TPML_PCR_SELECTION *pcrSelectionIn,
2095     UINT32 *pcrUpdateCounter,
2096     TPML_PCR_SELECTION **pcrSelectionOut,
2097     TPML_DIGEST **pcrValues);
2098 
2099 TSS2_RC
2100 Esys_PCR_Read_Async(
2101     ESYS_CONTEXT *esysContext,
2102     ESYS_TR shandle1,
2103     ESYS_TR shandle2,
2104     ESYS_TR shandle3,
2105     const TPML_PCR_SELECTION *pcrSelectionIn);
2106 
2107 TSS2_RC
2108 Esys_PCR_Read_Finish(
2109     ESYS_CONTEXT *esysContext,
2110     UINT32 *pcrUpdateCounter,
2111     TPML_PCR_SELECTION **pcrSelectionOut,
2112     TPML_DIGEST **pcrValues);
2113 
2114 /* Table 109 - TPM2_PCR_Allocate Command */
2115 
2116 TSS2_RC
2117 Esys_PCR_Allocate(
2118     ESYS_CONTEXT *esysContext,
2119     ESYS_TR authHandle,
2120     ESYS_TR shandle1,
2121     ESYS_TR shandle2,
2122     ESYS_TR shandle3,
2123     const TPML_PCR_SELECTION *pcrAllocation,
2124     TPMI_YES_NO *allocationSuccess,
2125     UINT32 *maxPCR,
2126     UINT32 *sizeNeeded,
2127     UINT32 *sizeAvailable);
2128 
2129 TSS2_RC
2130 Esys_PCR_Allocate_Async(
2131     ESYS_CONTEXT *esysContext,
2132     ESYS_TR authHandle,
2133     ESYS_TR shandle1,
2134     ESYS_TR shandle2,
2135     ESYS_TR shandle3,
2136     const TPML_PCR_SELECTION *pcrAllocation);
2137 
2138 TSS2_RC
2139 Esys_PCR_Allocate_Finish(
2140     ESYS_CONTEXT *esysContext,
2141     TPMI_YES_NO *allocationSuccess,
2142     UINT32 *maxPCR,
2143     UINT32 *sizeNeeded,
2144     UINT32 *sizeAvailable);
2145 
2146 /* Table 111 - TPM2_PCR_SetAuthPolicy Command */
2147 
2148 TSS2_RC
2149 Esys_PCR_SetAuthPolicy(
2150     ESYS_CONTEXT *esysContext,
2151     ESYS_TR authHandle,
2152     ESYS_TR shandle1,
2153     ESYS_TR shandle2,
2154     ESYS_TR shandle3,
2155     const TPM2B_DIGEST *authPolicy,
2156     TPMI_ALG_HASH hashAlg,
2157     TPMI_DH_PCR pcrNum);
2158 
2159 TSS2_RC
2160 Esys_PCR_SetAuthPolicy_Async(
2161     ESYS_CONTEXT *esysContext,
2162     ESYS_TR authHandle,
2163     ESYS_TR shandle1,
2164     ESYS_TR shandle2,
2165     ESYS_TR shandle3,
2166     const TPM2B_DIGEST *authPolicy,
2167     TPMI_ALG_HASH hashAlg,
2168     TPMI_DH_PCR pcrNum);
2169 
2170 TSS2_RC
2171 Esys_PCR_SetAuthPolicy_Finish(
2172     ESYS_CONTEXT *esysContext);
2173 
2174 /* Table 113 - TPM2_PCR_SetAuthValue Command */
2175 
2176 TSS2_RC
2177 Esys_PCR_SetAuthValue(
2178     ESYS_CONTEXT *esysContext,
2179     ESYS_TR pcrHandle,
2180     ESYS_TR shandle1,
2181     ESYS_TR shandle2,
2182     ESYS_TR shandle3,
2183     const TPM2B_DIGEST *auth);
2184 
2185 TSS2_RC
2186 Esys_PCR_SetAuthValue_Async(
2187     ESYS_CONTEXT *esysContext,
2188     ESYS_TR pcrHandle,
2189     ESYS_TR shandle1,
2190     ESYS_TR shandle2,
2191     ESYS_TR shandle3,
2192     const TPM2B_DIGEST *auth);
2193 
2194 TSS2_RC
2195 Esys_PCR_SetAuthValue_Finish(
2196     ESYS_CONTEXT *esysContext);
2197 
2198 /* Table 115 - TPM2_PCR_Reset Command */
2199 
2200 TSS2_RC
2201 Esys_PCR_Reset(
2202     ESYS_CONTEXT *esysContext,
2203     ESYS_TR pcrHandle,
2204     ESYS_TR shandle1,
2205     ESYS_TR shandle2,
2206     ESYS_TR shandle3);
2207 
2208 TSS2_RC
2209 Esys_PCR_Reset_Async(
2210     ESYS_CONTEXT *esysContext,
2211     ESYS_TR pcrHandle,
2212     ESYS_TR shandle1,
2213     ESYS_TR shandle2,
2214     ESYS_TR shandle3);
2215 
2216 TSS2_RC
2217 Esys_PCR_Reset_Finish(
2218     ESYS_CONTEXT *esysContext);
2219 
2220 /* Table 117 - TPM2_PolicySigned Command */
2221 
2222 TSS2_RC
2223 Esys_PolicySigned(
2224     ESYS_CONTEXT *esysContext,
2225     ESYS_TR authObject,
2226     ESYS_TR policySession,
2227     ESYS_TR shandle1,
2228     ESYS_TR shandle2,
2229     ESYS_TR shandle3,
2230     const TPM2B_NONCE *nonceTPM,
2231     const TPM2B_DIGEST *cpHashA,
2232     const TPM2B_NONCE *policyRef,
2233     INT32 expiration,
2234     const TPMT_SIGNATURE *auth,
2235     TPM2B_TIMEOUT **timeout,
2236     TPMT_TK_AUTH **policyTicket);
2237 
2238 TSS2_RC
2239 Esys_PolicySigned_Async(
2240     ESYS_CONTEXT *esysContext,
2241     ESYS_TR authObject,
2242     ESYS_TR policySession,
2243     ESYS_TR shandle1,
2244     ESYS_TR shandle2,
2245     ESYS_TR shandle3,
2246     const TPM2B_NONCE *nonceTPM,
2247     const TPM2B_DIGEST *cpHashA,
2248     const TPM2B_NONCE *policyRef,
2249     INT32 expiration,
2250     const TPMT_SIGNATURE *auth);
2251 
2252 TSS2_RC
2253 Esys_PolicySigned_Finish(
2254     ESYS_CONTEXT *esysContext,
2255     TPM2B_TIMEOUT **timeout,
2256     TPMT_TK_AUTH **policyTicket);
2257 
2258 /* Table 119 - TPM2_PolicySecret Command */
2259 
2260 TSS2_RC
2261 Esys_PolicySecret(
2262     ESYS_CONTEXT *esysContext,
2263     ESYS_TR authHandle,
2264     ESYS_TR policySession,
2265     ESYS_TR shandle1,
2266     ESYS_TR shandle2,
2267     ESYS_TR shandle3,
2268     const TPM2B_NONCE *nonceTPM,
2269     const TPM2B_DIGEST *cpHashA,
2270     const TPM2B_NONCE *policyRef,
2271     INT32 expiration,
2272     TPM2B_TIMEOUT **timeout,
2273     TPMT_TK_AUTH **policyTicket);
2274 
2275 TSS2_RC
2276 Esys_PolicySecret_Async(
2277     ESYS_CONTEXT *esysContext,
2278     ESYS_TR authHandle,
2279     ESYS_TR policySession,
2280     ESYS_TR shandle1,
2281     ESYS_TR shandle2,
2282     ESYS_TR shandle3,
2283     const TPM2B_NONCE *nonceTPM,
2284     const TPM2B_DIGEST *cpHashA,
2285     const TPM2B_NONCE *policyRef,
2286     INT32 expiration);
2287 
2288 TSS2_RC
2289 Esys_PolicySecret_Finish(
2290     ESYS_CONTEXT *esysContext,
2291     TPM2B_TIMEOUT **timeout,
2292     TPMT_TK_AUTH **policyTicket);
2293 
2294 /* Table 121 - TPM2_PolicyTicket Command */
2295 
2296 TSS2_RC
2297 Esys_PolicyTicket(
2298     ESYS_CONTEXT *esysContext,
2299     ESYS_TR policySession,
2300     ESYS_TR shandle1,
2301     ESYS_TR shandle2,
2302     ESYS_TR shandle3,
2303     const TPM2B_TIMEOUT *timeout,
2304     const TPM2B_DIGEST *cpHashA,
2305     const TPM2B_NONCE *policyRef,
2306     const TPM2B_NAME *authName,
2307     const TPMT_TK_AUTH *ticket);
2308 
2309 TSS2_RC
2310 Esys_PolicyTicket_Async(
2311     ESYS_CONTEXT *esysContext,
2312     ESYS_TR policySession,
2313     ESYS_TR shandle1,
2314     ESYS_TR shandle2,
2315     ESYS_TR shandle3,
2316     const TPM2B_TIMEOUT *timeout,
2317     const TPM2B_DIGEST *cpHashA,
2318     const TPM2B_NONCE *policyRef,
2319     const TPM2B_NAME *authName,
2320     const TPMT_TK_AUTH *ticket);
2321 
2322 TSS2_RC
2323 Esys_PolicyTicket_Finish(
2324     ESYS_CONTEXT *esysContext);
2325 
2326 /* Table 123 - TPM2_PolicyOR Command */
2327 
2328 TSS2_RC
2329 Esys_PolicyOR(
2330     ESYS_CONTEXT *esysContext,
2331     ESYS_TR policySession,
2332     ESYS_TR shandle1,
2333     ESYS_TR shandle2,
2334     ESYS_TR shandle3,
2335     const TPML_DIGEST *pHashList);
2336 
2337 TSS2_RC
2338 Esys_PolicyOR_Async(
2339     ESYS_CONTEXT *esysContext,
2340     ESYS_TR policySession,
2341     ESYS_TR shandle1,
2342     ESYS_TR shandle2,
2343     ESYS_TR shandle3,
2344     const TPML_DIGEST *pHashList);
2345 
2346 TSS2_RC
2347 Esys_PolicyOR_Finish(
2348     ESYS_CONTEXT *esysContext);
2349 
2350 /* Table 125 - TPM2_PolicyPCR Command */
2351 
2352 TSS2_RC
2353 Esys_PolicyPCR(
2354     ESYS_CONTEXT *esysContext,
2355     ESYS_TR policySession,
2356     ESYS_TR shandle1,
2357     ESYS_TR shandle2,
2358     ESYS_TR shandle3,
2359     const TPM2B_DIGEST *pcrDigest,
2360     const TPML_PCR_SELECTION *pcrs);
2361 
2362 TSS2_RC
2363 Esys_PolicyPCR_Async(
2364     ESYS_CONTEXT *esysContext,
2365     ESYS_TR policySession,
2366     ESYS_TR shandle1,
2367     ESYS_TR shandle2,
2368     ESYS_TR shandle3,
2369     const TPM2B_DIGEST *pcrDigest,
2370     const TPML_PCR_SELECTION *pcrs);
2371 
2372 TSS2_RC
2373 Esys_PolicyPCR_Finish(
2374     ESYS_CONTEXT *esysContext);
2375 
2376 /* Table 127 - TPM2_PolicyLocality Command */
2377 
2378 TSS2_RC
2379 Esys_PolicyLocality(
2380     ESYS_CONTEXT *esysContext,
2381     ESYS_TR policySession,
2382     ESYS_TR shandle1,
2383     ESYS_TR shandle2,
2384     ESYS_TR shandle3,
2385     TPMA_LOCALITY locality);
2386 
2387 TSS2_RC
2388 Esys_PolicyLocality_Async(
2389     ESYS_CONTEXT *esysContext,
2390     ESYS_TR policySession,
2391     ESYS_TR shandle1,
2392     ESYS_TR shandle2,
2393     ESYS_TR shandle3,
2394     TPMA_LOCALITY locality);
2395 
2396 TSS2_RC
2397 Esys_PolicyLocality_Finish(
2398     ESYS_CONTEXT *esysContext);
2399 
2400 /* Table 129 - TPM2_PolicyNV Command */
2401 
2402 TSS2_RC
2403 Esys_PolicyNV(
2404     ESYS_CONTEXT *esysContext,
2405     ESYS_TR authHandle,
2406     ESYS_TR nvIndex,
2407     ESYS_TR policySession,
2408     ESYS_TR shandle1,
2409     ESYS_TR shandle2,
2410     ESYS_TR shandle3,
2411     const TPM2B_OPERAND *operandB,
2412     UINT16 offset,
2413     TPM2_EO operation);
2414 
2415 TSS2_RC
2416 Esys_PolicyNV_Async(
2417     ESYS_CONTEXT *esysContext,
2418     ESYS_TR authHandle,
2419     ESYS_TR nvIndex,
2420     ESYS_TR policySession,
2421     ESYS_TR shandle1,
2422     ESYS_TR shandle2,
2423     ESYS_TR shandle3,
2424     const TPM2B_OPERAND *operandB,
2425     UINT16 offset,
2426     TPM2_EO operation);
2427 
2428 TSS2_RC
2429 Esys_PolicyNV_Finish(
2430     ESYS_CONTEXT *esysContext);
2431 
2432 /* Table 131 - TPM2_PolicyCounterTimer Command */
2433 
2434 TSS2_RC
2435 Esys_PolicyCounterTimer(
2436     ESYS_CONTEXT *esysContext,
2437     ESYS_TR policySession,
2438     ESYS_TR shandle1,
2439     ESYS_TR shandle2,
2440     ESYS_TR shandle3,
2441     const TPM2B_OPERAND *operandB,
2442     UINT16 offset,
2443     TPM2_EO operation);
2444 
2445 TSS2_RC
2446 Esys_PolicyCounterTimer_Async(
2447     ESYS_CONTEXT *esysContext,
2448     ESYS_TR policySession,
2449     ESYS_TR shandle1,
2450     ESYS_TR shandle2,
2451     ESYS_TR shandle3,
2452     const TPM2B_OPERAND *operandB,
2453     UINT16 offset,
2454     TPM2_EO operation);
2455 
2456 TSS2_RC
2457 Esys_PolicyCounterTimer_Finish(
2458     ESYS_CONTEXT *esysContext);
2459 
2460 /* Table 133 - TPM2_PolicyCommandCode Command */
2461 
2462 TSS2_RC
2463 Esys_PolicyCommandCode(
2464     ESYS_CONTEXT *esysContext,
2465     ESYS_TR policySession,
2466     ESYS_TR shandle1,
2467     ESYS_TR shandle2,
2468     ESYS_TR shandle3,
2469     TPM2_CC code);
2470 
2471 TSS2_RC
2472 Esys_PolicyCommandCode_Async(
2473     ESYS_CONTEXT *esysContext,
2474     ESYS_TR policySession,
2475     ESYS_TR shandle1,
2476     ESYS_TR shandle2,
2477     ESYS_TR shandle3,
2478     TPM2_CC code);
2479 
2480 TSS2_RC
2481 Esys_PolicyCommandCode_Finish(
2482     ESYS_CONTEXT *esysContext);
2483 
2484 /* Table 135 - TPM2_PolicyPhysicalPresence Command */
2485 
2486 TSS2_RC
2487 Esys_PolicyPhysicalPresence(
2488     ESYS_CONTEXT *esysContext,
2489     ESYS_TR policySession,
2490     ESYS_TR shandle1,
2491     ESYS_TR shandle2,
2492     ESYS_TR shandle3);
2493 
2494 TSS2_RC
2495 Esys_PolicyPhysicalPresence_Async(
2496     ESYS_CONTEXT *esysContext,
2497     ESYS_TR policySession,
2498     ESYS_TR shandle1,
2499     ESYS_TR shandle2,
2500     ESYS_TR shandle3);
2501 
2502 TSS2_RC
2503 Esys_PolicyPhysicalPresence_Finish(
2504     ESYS_CONTEXT *esysContext);
2505 
2506 /* Table 137 - TPM2_PolicyCpHash Command */
2507 
2508 TSS2_RC
2509 Esys_PolicyCpHash(
2510     ESYS_CONTEXT *esysContext,
2511     ESYS_TR policySession,
2512     ESYS_TR shandle1,
2513     ESYS_TR shandle2,
2514     ESYS_TR shandle3,
2515     const TPM2B_DIGEST *cpHashA);
2516 
2517 TSS2_RC
2518 Esys_PolicyCpHash_Async(
2519     ESYS_CONTEXT *esysContext,
2520     ESYS_TR policySession,
2521     ESYS_TR shandle1,
2522     ESYS_TR shandle2,
2523     ESYS_TR shandle3,
2524     const TPM2B_DIGEST *cpHashA);
2525 
2526 TSS2_RC
2527 Esys_PolicyCpHash_Finish(
2528     ESYS_CONTEXT *esysContext);
2529 
2530 /* Table 139 - TPM2_PolicyNameHash Command */
2531 
2532 TSS2_RC
2533 Esys_PolicyNameHash(
2534     ESYS_CONTEXT *esysContext,
2535     ESYS_TR policySession,
2536     ESYS_TR shandle1,
2537     ESYS_TR shandle2,
2538     ESYS_TR shandle3,
2539     const TPM2B_DIGEST *nameHash);
2540 
2541 TSS2_RC
2542 Esys_PolicyNameHash_Async(
2543     ESYS_CONTEXT *esysContext,
2544     ESYS_TR policySession,
2545     ESYS_TR shandle1,
2546     ESYS_TR shandle2,
2547     ESYS_TR shandle3,
2548     const TPM2B_DIGEST *nameHash);
2549 
2550 TSS2_RC
2551 Esys_PolicyNameHash_Finish(
2552     ESYS_CONTEXT *esysContext);
2553 
2554 /* Table 141 - TPM2_PolicyDuplicationSelect Command */
2555 
2556 TSS2_RC
2557 Esys_PolicyDuplicationSelect(
2558     ESYS_CONTEXT *esysContext,
2559     ESYS_TR policySession,
2560     ESYS_TR shandle1,
2561     ESYS_TR shandle2,
2562     ESYS_TR shandle3,
2563     const TPM2B_NAME *objectName,
2564     const TPM2B_NAME *newParentName,
2565     TPMI_YES_NO includeObject);
2566 
2567 TSS2_RC
2568 Esys_PolicyDuplicationSelect_Async(
2569     ESYS_CONTEXT *esysContext,
2570     ESYS_TR policySession,
2571     ESYS_TR shandle1,
2572     ESYS_TR shandle2,
2573     ESYS_TR shandle3,
2574     const TPM2B_NAME *objectName,
2575     const TPM2B_NAME *newParentName,
2576     TPMI_YES_NO includeObject);
2577 
2578 TSS2_RC
2579 Esys_PolicyDuplicationSelect_Finish(
2580     ESYS_CONTEXT *esysContext);
2581 
2582 /* Table 143 - TPM2_PolicyAuthorize Command */
2583 
2584 TSS2_RC
2585 Esys_PolicyAuthorize(
2586     ESYS_CONTEXT *esysContext,
2587     ESYS_TR policySession,
2588     ESYS_TR shandle1,
2589     ESYS_TR shandle2,
2590     ESYS_TR shandle3,
2591     const TPM2B_DIGEST *approvedPolicy,
2592     const TPM2B_NONCE *policyRef,
2593     const TPM2B_NAME *keySign,
2594     const TPMT_TK_VERIFIED *checkTicket);
2595 
2596 TSS2_RC
2597 Esys_PolicyAuthorize_Async(
2598     ESYS_CONTEXT *esysContext,
2599     ESYS_TR policySession,
2600     ESYS_TR shandle1,
2601     ESYS_TR shandle2,
2602     ESYS_TR shandle3,
2603     const TPM2B_DIGEST *approvedPolicy,
2604     const TPM2B_NONCE *policyRef,
2605     const TPM2B_NAME *keySign,
2606     const TPMT_TK_VERIFIED *checkTicket);
2607 
2608 TSS2_RC
2609 Esys_PolicyAuthorize_Finish(
2610     ESYS_CONTEXT *esysContext);
2611 
2612 /* Table 145 - TPM2_PolicyAuthValue Command */
2613 
2614 TSS2_RC
2615 Esys_PolicyAuthValue(
2616     ESYS_CONTEXT *esysContext,
2617     ESYS_TR policySession,
2618     ESYS_TR shandle1,
2619     ESYS_TR shandle2,
2620     ESYS_TR shandle3);
2621 
2622 TSS2_RC
2623 Esys_PolicyAuthValue_Async(
2624     ESYS_CONTEXT *esysContext,
2625     ESYS_TR policySession,
2626     ESYS_TR shandle1,
2627     ESYS_TR shandle2,
2628     ESYS_TR shandle3);
2629 
2630 TSS2_RC
2631 Esys_PolicyAuthValue_Finish(
2632     ESYS_CONTEXT *esysContext);
2633 
2634 /* Table 147 - TPM2_PolicyPassword Command */
2635 
2636 TSS2_RC
2637 Esys_PolicyPassword(
2638     ESYS_CONTEXT *esysContext,
2639     ESYS_TR policySession,
2640     ESYS_TR shandle1,
2641     ESYS_TR shandle2,
2642     ESYS_TR shandle3);
2643 
2644 TSS2_RC
2645 Esys_PolicyPassword_Async(
2646     ESYS_CONTEXT *esysContext,
2647     ESYS_TR policySession,
2648     ESYS_TR shandle1,
2649     ESYS_TR shandle2,
2650     ESYS_TR shandle3);
2651 
2652 TSS2_RC
2653 Esys_PolicyPassword_Finish(
2654     ESYS_CONTEXT *esysContext);
2655 
2656 /* Table 149 - TPM2_PolicyGetDigest Command */
2657 
2658 TSS2_RC
2659 Esys_PolicyGetDigest(
2660     ESYS_CONTEXT *esysContext,
2661     ESYS_TR policySession,
2662     ESYS_TR shandle1,
2663     ESYS_TR shandle2,
2664     ESYS_TR shandle3,
2665     TPM2B_DIGEST **policyDigest);
2666 
2667 TSS2_RC
2668 Esys_PolicyGetDigest_Async(
2669     ESYS_CONTEXT *esysContext,
2670     ESYS_TR policySession,
2671     ESYS_TR shandle1,
2672     ESYS_TR shandle2,
2673     ESYS_TR shandle3);
2674 
2675 TSS2_RC
2676 Esys_PolicyGetDigest_Finish(
2677     ESYS_CONTEXT *esysContext,
2678     TPM2B_DIGEST **policyDigest);
2679 
2680 /* Table 151 - TPM2_PolicyNvWritten Command */
2681 
2682 TSS2_RC
2683 Esys_PolicyNvWritten(
2684     ESYS_CONTEXT *esysContext,
2685     ESYS_TR policySession,
2686     ESYS_TR shandle1,
2687     ESYS_TR shandle2,
2688     ESYS_TR shandle3,
2689     TPMI_YES_NO writtenSet);
2690 
2691 TSS2_RC
2692 Esys_PolicyNvWritten_Async(
2693     ESYS_CONTEXT *esysContext,
2694     ESYS_TR policySession,
2695     ESYS_TR shandle1,
2696     ESYS_TR shandle2,
2697     ESYS_TR shandle3,
2698     TPMI_YES_NO writtenSet);
2699 
2700 TSS2_RC
2701 Esys_PolicyNvWritten_Finish(
2702     ESYS_CONTEXT *esysContext);
2703 
2704 /* Table 153 - TPM2_PolicyTemplate Command */
2705 
2706 TSS2_RC
2707 Esys_PolicyTemplate(
2708     ESYS_CONTEXT *esysContext,
2709     ESYS_TR policySession,
2710     ESYS_TR shandle1,
2711     ESYS_TR shandle2,
2712     ESYS_TR shandle3,
2713     const TPM2B_DIGEST *templateHash);
2714 
2715 TSS2_RC
2716 Esys_PolicyTemplate_Async(
2717     ESYS_CONTEXT *esysContext,
2718     ESYS_TR policySession,
2719     ESYS_TR shandle1,
2720     ESYS_TR shandle2,
2721     ESYS_TR shandle3,
2722     const TPM2B_DIGEST *templateHash);
2723 
2724 TSS2_RC
2725 Esys_PolicyTemplate_Finish(
2726     ESYS_CONTEXT *esysContext);
2727 
2728 /* Table 155 - TPM2_PolicyAuthorizeNV Command */
2729 
2730 TSS2_RC
2731 Esys_PolicyAuthorizeNV(
2732     ESYS_CONTEXT *esysContext,
2733     ESYS_TR authHandle,
2734     ESYS_TR nvIndex,
2735     ESYS_TR policySession,
2736     ESYS_TR shandle1,
2737     ESYS_TR shandle2,
2738     ESYS_TR shandle3);
2739 
2740 TSS2_RC
2741 Esys_PolicyAuthorizeNV_Async(
2742     ESYS_CONTEXT *esysContext,
2743     ESYS_TR authHandle,
2744     ESYS_TR nvIndex,
2745     ESYS_TR policySession,
2746     ESYS_TR shandle1,
2747     ESYS_TR shandle2,
2748     ESYS_TR shandle3);
2749 
2750 TSS2_RC
2751 Esys_PolicyAuthorizeNV_Finish(
2752     ESYS_CONTEXT *esysContext);
2753 
2754 /* Table 157 - TPM2_CreatePrimary Command */
2755 
2756 TSS2_RC
2757 Esys_CreatePrimary(
2758     ESYS_CONTEXT *esysContext,
2759     ESYS_TR primaryHandle,
2760     ESYS_TR shandle1,
2761     ESYS_TR shandle2,
2762     ESYS_TR shandle3,
2763     const TPM2B_SENSITIVE_CREATE *inSensitive,
2764     const TPM2B_PUBLIC *inPublic,
2765     const TPM2B_DATA *outsideInfo,
2766     const TPML_PCR_SELECTION *creationPCR,
2767     ESYS_TR *objectHandle,
2768     TPM2B_PUBLIC **outPublic,
2769     TPM2B_CREATION_DATA **creationData,
2770     TPM2B_DIGEST **creationHash,
2771     TPMT_TK_CREATION **creationTicket);
2772 
2773 TSS2_RC
2774 Esys_CreatePrimary_Async(
2775     ESYS_CONTEXT *esysContext,
2776     ESYS_TR primaryHandle,
2777     ESYS_TR shandle1,
2778     ESYS_TR shandle2,
2779     ESYS_TR shandle3,
2780     const TPM2B_SENSITIVE_CREATE *inSensitive,
2781     const TPM2B_PUBLIC *inPublic,
2782     const TPM2B_DATA *outsideInfo,
2783     const TPML_PCR_SELECTION *creationPCR);
2784 
2785 TSS2_RC
2786 Esys_CreatePrimary_Finish(
2787     ESYS_CONTEXT *esysContext,
2788     ESYS_TR *objectHandle,
2789     TPM2B_PUBLIC **outPublic,
2790     TPM2B_CREATION_DATA **creationData,
2791     TPM2B_DIGEST **creationHash,
2792     TPMT_TK_CREATION **creationTicket);
2793 
2794 /* Table 159 - TPM2_HierarchyControl Command */
2795 
2796 TSS2_RC
2797 Esys_HierarchyControl(
2798     ESYS_CONTEXT *esysContext,
2799     ESYS_TR authHandle,
2800     ESYS_TR shandle1,
2801     ESYS_TR shandle2,
2802     ESYS_TR shandle3,
2803     ESYS_TR enable,
2804     TPMI_YES_NO state);
2805 
2806 TSS2_RC
2807 Esys_HierarchyControl_Async(
2808     ESYS_CONTEXT *esysContext,
2809     ESYS_TR authHandle,
2810     ESYS_TR shandle1,
2811     ESYS_TR shandle2,
2812     ESYS_TR shandle3,
2813     ESYS_TR enable,
2814     TPMI_YES_NO state);
2815 
2816 TSS2_RC
2817 Esys_HierarchyControl_Finish(
2818     ESYS_CONTEXT *esysContext);
2819 
2820 /* Table 161 - TPM2_SetPrimaryPolicy Command */
2821 
2822 TSS2_RC
2823 Esys_SetPrimaryPolicy(
2824     ESYS_CONTEXT *esysContext,
2825     ESYS_TR authHandle,
2826     ESYS_TR shandle1,
2827     ESYS_TR shandle2,
2828     ESYS_TR shandle3,
2829     const TPM2B_DIGEST *authPolicy,
2830     TPMI_ALG_HASH hashAlg);
2831 
2832 TSS2_RC
2833 Esys_SetPrimaryPolicy_Async(
2834     ESYS_CONTEXT *esysContext,
2835     ESYS_TR authHandle,
2836     ESYS_TR shandle1,
2837     ESYS_TR shandle2,
2838     ESYS_TR shandle3,
2839     const TPM2B_DIGEST *authPolicy,
2840     TPMI_ALG_HASH hashAlg);
2841 
2842 TSS2_RC
2843 Esys_SetPrimaryPolicy_Finish(
2844     ESYS_CONTEXT *esysContext);
2845 
2846 /* Table 163 - TPM2_ChangePPS Command */
2847 
2848 TSS2_RC
2849 Esys_ChangePPS(
2850     ESYS_CONTEXT *esysContext,
2851     ESYS_TR authHandle,
2852     ESYS_TR shandle1,
2853     ESYS_TR shandle2,
2854     ESYS_TR shandle3);
2855 
2856 TSS2_RC
2857 Esys_ChangePPS_Async(
2858     ESYS_CONTEXT *esysContext,
2859     ESYS_TR authHandle,
2860     ESYS_TR shandle1,
2861     ESYS_TR shandle2,
2862     ESYS_TR shandle3);
2863 
2864 TSS2_RC
2865 Esys_ChangePPS_Finish(
2866     ESYS_CONTEXT *esysContext);
2867 
2868 /* Table 165 - TPM2_ChangeEPS Command */
2869 
2870 TSS2_RC
2871 Esys_ChangeEPS(
2872     ESYS_CONTEXT *esysContext,
2873     ESYS_TR authHandle,
2874     ESYS_TR shandle1,
2875     ESYS_TR shandle2,
2876     ESYS_TR shandle3);
2877 
2878 TSS2_RC
2879 Esys_ChangeEPS_Async(
2880     ESYS_CONTEXT *esysContext,
2881     ESYS_TR authHandle,
2882     ESYS_TR shandle1,
2883     ESYS_TR shandle2,
2884     ESYS_TR shandle3);
2885 
2886 TSS2_RC
2887 Esys_ChangeEPS_Finish(
2888     ESYS_CONTEXT *esysContext);
2889 
2890 /* Table 167 - TPM2_Clear Command */
2891 
2892 TSS2_RC
2893 Esys_Clear(
2894     ESYS_CONTEXT *esysContext,
2895     ESYS_TR authHandle,
2896     ESYS_TR shandle1,
2897     ESYS_TR shandle2,
2898     ESYS_TR shandle3);
2899 
2900 TSS2_RC
2901 Esys_Clear_Async(
2902     ESYS_CONTEXT *esysContext,
2903     ESYS_TR authHandle,
2904     ESYS_TR shandle1,
2905     ESYS_TR shandle2,
2906     ESYS_TR shandle3);
2907 
2908 TSS2_RC
2909 Esys_Clear_Finish(
2910     ESYS_CONTEXT *esysContext);
2911 
2912 /* Table 169 - TPM2_ClearControl Command */
2913 
2914 TSS2_RC
2915 Esys_ClearControl(
2916     ESYS_CONTEXT *esysContext,
2917     ESYS_TR auth,
2918     ESYS_TR shandle1,
2919     ESYS_TR shandle2,
2920     ESYS_TR shandle3,
2921     TPMI_YES_NO disable);
2922 
2923 TSS2_RC
2924 Esys_ClearControl_Async(
2925     ESYS_CONTEXT *esysContext,
2926     ESYS_TR auth,
2927     ESYS_TR shandle1,
2928     ESYS_TR shandle2,
2929     ESYS_TR shandle3,
2930     TPMI_YES_NO disable);
2931 
2932 TSS2_RC
2933 Esys_ClearControl_Finish(
2934     ESYS_CONTEXT *esysContext);
2935 
2936 /* Table 171 - TPM2_HierarchyChangeAuth Command */
2937 
2938 TSS2_RC
2939 Esys_HierarchyChangeAuth(
2940     ESYS_CONTEXT *esysContext,
2941     ESYS_TR authHandle,
2942     ESYS_TR shandle1,
2943     ESYS_TR shandle2,
2944     ESYS_TR shandle3,
2945     const TPM2B_AUTH *newAuth);
2946 
2947 TSS2_RC
2948 Esys_HierarchyChangeAuth_Async(
2949     ESYS_CONTEXT *esysContext,
2950     ESYS_TR authHandle,
2951     ESYS_TR shandle1,
2952     ESYS_TR shandle2,
2953     ESYS_TR shandle3,
2954     const TPM2B_AUTH *newAuth);
2955 
2956 TSS2_RC
2957 Esys_HierarchyChangeAuth_Finish(
2958     ESYS_CONTEXT *esysContext);
2959 
2960 /* Table 173 - TPM2_DictionaryAttackLockReset Command */
2961 
2962 TSS2_RC
2963 Esys_DictionaryAttackLockReset(
2964     ESYS_CONTEXT *esysContext,
2965     ESYS_TR lockHandle,
2966     ESYS_TR shandle1,
2967     ESYS_TR shandle2,
2968     ESYS_TR shandle3);
2969 
2970 TSS2_RC
2971 Esys_DictionaryAttackLockReset_Async(
2972     ESYS_CONTEXT *esysContext,
2973     ESYS_TR lockHandle,
2974     ESYS_TR shandle1,
2975     ESYS_TR shandle2,
2976     ESYS_TR shandle3);
2977 
2978 TSS2_RC
2979 Esys_DictionaryAttackLockReset_Finish(
2980     ESYS_CONTEXT *esysContext);
2981 
2982 /* Table 175 - TPM2_DictionaryAttackParameters Command */
2983 
2984 TSS2_RC
2985 Esys_DictionaryAttackParameters(
2986     ESYS_CONTEXT *esysContext,
2987     ESYS_TR lockHandle,
2988     ESYS_TR shandle1,
2989     ESYS_TR shandle2,
2990     ESYS_TR shandle3,
2991     UINT32 newMaxTries,
2992     UINT32 newRecoveryTime,
2993     UINT32 lockoutRecovery);
2994 
2995 TSS2_RC
2996 Esys_DictionaryAttackParameters_Async(
2997     ESYS_CONTEXT *esysContext,
2998     ESYS_TR lockHandle,
2999     ESYS_TR shandle1,
3000     ESYS_TR shandle2,
3001     ESYS_TR shandle3,
3002     UINT32 newMaxTries,
3003     UINT32 newRecoveryTime,
3004     UINT32 lockoutRecovery);
3005 
3006 TSS2_RC
3007 Esys_DictionaryAttackParameters_Finish(
3008     ESYS_CONTEXT *esysContext);
3009 
3010 /* Table 177 - TPM2_PP_Commands Command */
3011 
3012 TSS2_RC
3013 Esys_PP_Commands(
3014     ESYS_CONTEXT *esysContext,
3015     ESYS_TR auth,
3016     ESYS_TR shandle1,
3017     ESYS_TR shandle2,
3018     ESYS_TR shandle3,
3019     const TPML_CC *setList,
3020     const TPML_CC *clearList);
3021 
3022 TSS2_RC
3023 Esys_PP_Commands_Async(
3024     ESYS_CONTEXT *esysContext,
3025     ESYS_TR auth,
3026     ESYS_TR shandle1,
3027     ESYS_TR shandle2,
3028     ESYS_TR shandle3,
3029     const TPML_CC *setList,
3030     const TPML_CC *clearList);
3031 
3032 TSS2_RC
3033 Esys_PP_Commands_Finish(
3034     ESYS_CONTEXT *esysContext);
3035 
3036 /* Table 179 - TPM2_SetAlgorithmSet Command */
3037 
3038 TSS2_RC
3039 Esys_SetAlgorithmSet(
3040     ESYS_CONTEXT *esysContext,
3041     ESYS_TR authHandle,
3042     ESYS_TR shandle1,
3043     ESYS_TR shandle2,
3044     ESYS_TR shandle3,
3045     UINT32 algorithmSet);
3046 
3047 TSS2_RC
3048 Esys_SetAlgorithmSet_Async(
3049     ESYS_CONTEXT *esysContext,
3050     ESYS_TR authHandle,
3051     ESYS_TR shandle1,
3052     ESYS_TR shandle2,
3053     ESYS_TR shandle3,
3054     UINT32 algorithmSet);
3055 
3056 TSS2_RC
3057 Esys_SetAlgorithmSet_Finish(
3058     ESYS_CONTEXT *esysContext);
3059 
3060 /* Table 181 - TPM2_FieldUpgradeStart Command */
3061 
3062 TSS2_RC
3063 Esys_FieldUpgradeStart(
3064     ESYS_CONTEXT *esysContext,
3065     ESYS_TR authorization,
3066     ESYS_TR keyHandle,
3067     ESYS_TR shandle1,
3068     ESYS_TR shandle2,
3069     ESYS_TR shandle3,
3070     const TPM2B_DIGEST *fuDigest,
3071     const TPMT_SIGNATURE *manifestSignature);
3072 
3073 TSS2_RC
3074 Esys_FieldUpgradeStart_Async(
3075     ESYS_CONTEXT *esysContext,
3076     ESYS_TR authorization,
3077     ESYS_TR keyHandle,
3078     ESYS_TR shandle1,
3079     ESYS_TR shandle2,
3080     ESYS_TR shandle3,
3081     const TPM2B_DIGEST *fuDigest,
3082     const TPMT_SIGNATURE *manifestSignature);
3083 
3084 TSS2_RC
3085 Esys_FieldUpgradeStart_Finish(
3086     ESYS_CONTEXT *esysContext);
3087 
3088 /* Table 183 - TPM2_FieldUpgradeData Command */
3089 
3090 TSS2_RC
3091 Esys_FieldUpgradeData(
3092     ESYS_CONTEXT *esysContext,
3093     ESYS_TR shandle1,
3094     ESYS_TR shandle2,
3095     ESYS_TR shandle3,
3096     const TPM2B_MAX_BUFFER *fuData,
3097     TPMT_HA **nextDigest,
3098     TPMT_HA **firstDigest);
3099 
3100 TSS2_RC
3101 Esys_FieldUpgradeData_Async(
3102     ESYS_CONTEXT *esysContext,
3103     ESYS_TR shandle1,
3104     ESYS_TR shandle2,
3105     ESYS_TR shandle3,
3106     const TPM2B_MAX_BUFFER *fuData);
3107 
3108 TSS2_RC
3109 Esys_FieldUpgradeData_Finish(
3110     ESYS_CONTEXT *esysContext,
3111     TPMT_HA **nextDigest,
3112     TPMT_HA **firstDigest);
3113 
3114 /* Table 185 - TPM2_FirmwareRead Command */
3115 
3116 TSS2_RC
3117 Esys_FirmwareRead(
3118     ESYS_CONTEXT *esysContext,
3119     ESYS_TR shandle1,
3120     ESYS_TR shandle2,
3121     ESYS_TR shandle3,
3122     UINT32 sequenceNumber,
3123     TPM2B_MAX_BUFFER **fuData);
3124 
3125 TSS2_RC
3126 Esys_FirmwareRead_Async(
3127     ESYS_CONTEXT *esysContext,
3128     ESYS_TR shandle1,
3129     ESYS_TR shandle2,
3130     ESYS_TR shandle3,
3131     UINT32 sequenceNumber);
3132 
3133 TSS2_RC
3134 Esys_FirmwareRead_Finish(
3135     ESYS_CONTEXT *esysContext,
3136     TPM2B_MAX_BUFFER **fuData);
3137 
3138 /* Table 187 - TPM2_ContextSave Command */
3139 
3140 TSS2_RC
3141 Esys_ContextSave(
3142     ESYS_CONTEXT *esysContext,
3143     ESYS_TR saveHandle,
3144     TPMS_CONTEXT **context);
3145 
3146 TSS2_RC
3147 Esys_ContextSave_Async(
3148     ESYS_CONTEXT *esysContext,
3149     ESYS_TR saveHandle);
3150 
3151 TSS2_RC
3152 Esys_ContextSave_Finish(
3153     ESYS_CONTEXT *esysContext,
3154     TPMS_CONTEXT **context);
3155 
3156 /* Table 189 - TPM2_ContextLoad Command */
3157 
3158 TSS2_RC
3159 Esys_ContextLoad(
3160     ESYS_CONTEXT *esysContext,
3161     const TPMS_CONTEXT *context,
3162     ESYS_TR *loadedHandle);
3163 
3164 TSS2_RC
3165 Esys_ContextLoad_Async(
3166     ESYS_CONTEXT *esysContext,
3167     const TPMS_CONTEXT *context);
3168 
3169 TSS2_RC
3170 Esys_ContextLoad_Finish(
3171     ESYS_CONTEXT *esysContext,
3172     ESYS_TR *loadedHandle);
3173 
3174 /* Table 191 - TPM2_FlushContext Command */
3175 
3176 TSS2_RC
3177 Esys_FlushContext(
3178     ESYS_CONTEXT *esysContext,
3179     ESYS_TR flushHandle);
3180 
3181 TSS2_RC
3182 Esys_FlushContext_Async(
3183     ESYS_CONTEXT *esysContext,
3184     ESYS_TR flushHandle);
3185 
3186 TSS2_RC
3187 Esys_FlushContext_Finish(
3188     ESYS_CONTEXT *esysContext);
3189 
3190 /* Table 193 - TPM2_EvictControl Command */
3191 
3192 TSS2_RC
3193 Esys_EvictControl(
3194     ESYS_CONTEXT *esysContext,
3195     ESYS_TR auth,
3196     ESYS_TR objectHandle,
3197     ESYS_TR shandle1,
3198     ESYS_TR shandle2,
3199     ESYS_TR shandle3,
3200     TPMI_DH_PERSISTENT persistentHandle,
3201     ESYS_TR *newObjectHandle);
3202 
3203 TSS2_RC
3204 Esys_EvictControl_Async(
3205     ESYS_CONTEXT *esysContext,
3206     ESYS_TR auth,
3207     ESYS_TR objectHandle,
3208     ESYS_TR shandle1,
3209     ESYS_TR shandle2,
3210     ESYS_TR shandle3,
3211     TPMI_DH_PERSISTENT persistentHandle);
3212 
3213 TSS2_RC
3214 Esys_EvictControl_Finish(
3215     ESYS_CONTEXT *esysContext,
3216     ESYS_TR *newObjectHandle);
3217 
3218 /* Table 195 - TPM2_ReadClock Command */
3219 
3220 TSS2_RC
3221 Esys_ReadClock(
3222     ESYS_CONTEXT *esysContext,
3223     ESYS_TR shandle1,
3224     ESYS_TR shandle2,
3225     ESYS_TR shandle3,
3226     TPMS_TIME_INFO **currentTime);
3227 
3228 TSS2_RC
3229 Esys_ReadClock_Async(
3230     ESYS_CONTEXT *esysContext,
3231     ESYS_TR shandle1,
3232     ESYS_TR shandle2,
3233     ESYS_TR shandle3);
3234 
3235 TSS2_RC
3236 Esys_ReadClock_Finish(
3237     ESYS_CONTEXT *esysContext,
3238     TPMS_TIME_INFO **currentTime);
3239 
3240 /* Table 197 - TPM2_ClockSet Command */
3241 
3242 TSS2_RC
3243 Esys_ClockSet(
3244     ESYS_CONTEXT *esysContext,
3245     ESYS_TR auth,
3246     ESYS_TR shandle1,
3247     ESYS_TR shandle2,
3248     ESYS_TR shandle3,
3249     UINT64 newTime);
3250 
3251 TSS2_RC
3252 Esys_ClockSet_Async(
3253     ESYS_CONTEXT *esysContext,
3254     ESYS_TR auth,
3255     ESYS_TR shandle1,
3256     ESYS_TR shandle2,
3257     ESYS_TR shandle3,
3258     UINT64 newTime);
3259 
3260 TSS2_RC
3261 Esys_ClockSet_Finish(
3262     ESYS_CONTEXT *esysContext);
3263 
3264 /* Table 199 - TPM2_ClockRateAdjust Command */
3265 
3266 TSS2_RC
3267 Esys_ClockRateAdjust(
3268     ESYS_CONTEXT *esysContext,
3269     ESYS_TR auth,
3270     ESYS_TR shandle1,
3271     ESYS_TR shandle2,
3272     ESYS_TR shandle3,
3273     TPM2_CLOCK_ADJUST rateAdjust);
3274 
3275 TSS2_RC
3276 Esys_ClockRateAdjust_Async(
3277     ESYS_CONTEXT *esysContext,
3278     ESYS_TR auth,
3279     ESYS_TR shandle1,
3280     ESYS_TR shandle2,
3281     ESYS_TR shandle3,
3282     TPM2_CLOCK_ADJUST rateAdjust);
3283 
3284 TSS2_RC
3285 Esys_ClockRateAdjust_Finish(
3286     ESYS_CONTEXT *esysContext);
3287 
3288 /* Table 201 - TPM2_GetCapability Command */
3289 
3290 TSS2_RC
3291 Esys_GetCapability(
3292     ESYS_CONTEXT *esysContext,
3293     ESYS_TR shandle1,
3294     ESYS_TR shandle2,
3295     ESYS_TR shandle3,
3296     TPM2_CAP capability,
3297     UINT32 property,
3298     UINT32 propertyCount,
3299     TPMI_YES_NO *moreData,
3300     TPMS_CAPABILITY_DATA **capabilityData);
3301 
3302 TSS2_RC
3303 Esys_GetCapability_Async(
3304     ESYS_CONTEXT *esysContext,
3305     ESYS_TR shandle1,
3306     ESYS_TR shandle2,
3307     ESYS_TR shandle3,
3308     TPM2_CAP capability,
3309     UINT32 property,
3310     UINT32 propertyCount);
3311 
3312 TSS2_RC
3313 Esys_GetCapability_Finish(
3314     ESYS_CONTEXT *esysContext,
3315     TPMI_YES_NO *moreData,
3316     TPMS_CAPABILITY_DATA **capabilityData);
3317 
3318 /* Table 203 - TPM2_TestParms Command */
3319 
3320 TSS2_RC
3321 Esys_TestParms(
3322     ESYS_CONTEXT *esysContext,
3323     ESYS_TR shandle1,
3324     ESYS_TR shandle2,
3325     ESYS_TR shandle3,
3326     const TPMT_PUBLIC_PARMS *parameters);
3327 
3328 TSS2_RC
3329 Esys_TestParms_Async(
3330     ESYS_CONTEXT *esysContext,
3331     ESYS_TR shandle1,
3332     ESYS_TR shandle2,
3333     ESYS_TR shandle3,
3334     const TPMT_PUBLIC_PARMS *parameters);
3335 
3336 TSS2_RC
3337 Esys_TestParms_Finish(
3338     ESYS_CONTEXT *esysContext);
3339 
3340 /* Table 205 - TPM2_NV_DefineSpace Command */
3341 
3342 TSS2_RC
3343 Esys_NV_DefineSpace(
3344     ESYS_CONTEXT *esysContext,
3345     ESYS_TR authHandle,
3346     ESYS_TR shandle1,
3347     ESYS_TR shandle2,
3348     ESYS_TR shandle3,
3349     const TPM2B_AUTH *auth,
3350     const TPM2B_NV_PUBLIC *publicInfo,
3351     ESYS_TR *nvHandle);
3352 
3353 TSS2_RC
3354 Esys_NV_DefineSpace_Async(
3355     ESYS_CONTEXT *esysContext,
3356     ESYS_TR authHandle,
3357     ESYS_TR shandle1,
3358     ESYS_TR shandle2,
3359     ESYS_TR shandle3,
3360     const TPM2B_AUTH *auth,
3361     const TPM2B_NV_PUBLIC *publicInfo);
3362 
3363 TSS2_RC
3364 Esys_NV_DefineSpace_Finish(
3365     ESYS_CONTEXT *esysContext,
3366     ESYS_TR *nvHandle);
3367 
3368 /* Table 207 - TPM2_NV_UndefineSpace Command */
3369 
3370 TSS2_RC
3371 Esys_NV_UndefineSpace(
3372     ESYS_CONTEXT *esysContext,
3373     ESYS_TR authHandle,
3374     ESYS_TR nvIndex,
3375     ESYS_TR shandle1,
3376     ESYS_TR shandle2,
3377     ESYS_TR shandle3);
3378 
3379 TSS2_RC
3380 Esys_NV_UndefineSpace_Async(
3381     ESYS_CONTEXT *esysContext,
3382     ESYS_TR authHandle,
3383     ESYS_TR nvIndex,
3384     ESYS_TR shandle1,
3385     ESYS_TR shandle2,
3386     ESYS_TR shandle3);
3387 
3388 TSS2_RC
3389 Esys_NV_UndefineSpace_Finish(
3390     ESYS_CONTEXT *esysContext);
3391 
3392 /* Table 209 - TPM2_NV_UndefineSpaceSpecial Command */
3393 
3394 TSS2_RC
3395 Esys_NV_UndefineSpaceSpecial(
3396     ESYS_CONTEXT *esysContext,
3397     ESYS_TR nvIndex,
3398     ESYS_TR platform,
3399     ESYS_TR shandle1,
3400     ESYS_TR shandle2,
3401     ESYS_TR shandle3);
3402 
3403 TSS2_RC
3404 Esys_NV_UndefineSpaceSpecial_Async(
3405     ESYS_CONTEXT *esysContext,
3406     ESYS_TR nvIndex,
3407     ESYS_TR platform,
3408     ESYS_TR shandle1,
3409     ESYS_TR shandle2,
3410     ESYS_TR shandle3);
3411 
3412 TSS2_RC
3413 Esys_NV_UndefineSpaceSpecial_Finish(
3414     ESYS_CONTEXT *esysContext);
3415 
3416 /* Table 211 - TPM2_NV_ReadPublic Command */
3417 
3418 TSS2_RC
3419 Esys_NV_ReadPublic(
3420     ESYS_CONTEXT *esysContext,
3421     ESYS_TR nvIndex,
3422     ESYS_TR shandle1,
3423     ESYS_TR shandle2,
3424     ESYS_TR shandle3,
3425     TPM2B_NV_PUBLIC **nvPublic,
3426     TPM2B_NAME **nvName);
3427 
3428 TSS2_RC
3429 Esys_NV_ReadPublic_Async(
3430     ESYS_CONTEXT *esysContext,
3431     ESYS_TR nvIndex,
3432     ESYS_TR shandle1,
3433     ESYS_TR shandle2,
3434     ESYS_TR shandle3);
3435 
3436 TSS2_RC
3437 Esys_NV_ReadPublic_Finish(
3438     ESYS_CONTEXT *esysContext,
3439     TPM2B_NV_PUBLIC **nvPublic,
3440     TPM2B_NAME **nvName);
3441 
3442 /* Table 213 - TPM2_NV_Write Command */
3443 
3444 TSS2_RC
3445 Esys_NV_Write(
3446     ESYS_CONTEXT *esysContext,
3447     ESYS_TR authHandle,
3448     ESYS_TR nvIndex,
3449     ESYS_TR shandle1,
3450     ESYS_TR shandle2,
3451     ESYS_TR shandle3,
3452     const TPM2B_MAX_NV_BUFFER *data,
3453     UINT16 offset);
3454 
3455 TSS2_RC
3456 Esys_NV_Write_Async(
3457     ESYS_CONTEXT *esysContext,
3458     ESYS_TR authHandle,
3459     ESYS_TR nvIndex,
3460     ESYS_TR shandle1,
3461     ESYS_TR shandle2,
3462     ESYS_TR shandle3,
3463     const TPM2B_MAX_NV_BUFFER *data,
3464     UINT16 offset);
3465 
3466 TSS2_RC
3467 Esys_NV_Write_Finish(
3468     ESYS_CONTEXT *esysContext);
3469 
3470 /* Table 215 - TPM2_NV_Increment Command */
3471 
3472 TSS2_RC
3473 Esys_NV_Increment(
3474     ESYS_CONTEXT *esysContext,
3475     ESYS_TR authHandle,
3476     ESYS_TR nvIndex,
3477     ESYS_TR shandle1,
3478     ESYS_TR shandle2,
3479     ESYS_TR shandle3);
3480 
3481 TSS2_RC
3482 Esys_NV_Increment_Async(
3483     ESYS_CONTEXT *esysContext,
3484     ESYS_TR authHandle,
3485     ESYS_TR nvIndex,
3486     ESYS_TR shandle1,
3487     ESYS_TR shandle2,
3488     ESYS_TR shandle3);
3489 
3490 TSS2_RC
3491 Esys_NV_Increment_Finish(
3492     ESYS_CONTEXT *esysContext);
3493 
3494 /* Table 217 - TPM2_NV_Extend Command */
3495 
3496 TSS2_RC
3497 Esys_NV_Extend(
3498     ESYS_CONTEXT *esysContext,
3499     ESYS_TR authHandle,
3500     ESYS_TR nvIndex,
3501     ESYS_TR shandle1,
3502     ESYS_TR shandle2,
3503     ESYS_TR shandle3,
3504     const TPM2B_MAX_NV_BUFFER *data);
3505 
3506 TSS2_RC
3507 Esys_NV_Extend_Async(
3508     ESYS_CONTEXT *esysContext,
3509     ESYS_TR authHandle,
3510     ESYS_TR nvIndex,
3511     ESYS_TR shandle1,
3512     ESYS_TR shandle2,
3513     ESYS_TR shandle3,
3514     const TPM2B_MAX_NV_BUFFER *data);
3515 
3516 TSS2_RC
3517 Esys_NV_Extend_Finish(
3518     ESYS_CONTEXT *esysContext);
3519 
3520 /* Table 219 - TPM2_NV_SetBits Command */
3521 
3522 TSS2_RC
3523 Esys_NV_SetBits(
3524     ESYS_CONTEXT *esysContext,
3525     ESYS_TR authHandle,
3526     ESYS_TR nvIndex,
3527     ESYS_TR shandle1,
3528     ESYS_TR shandle2,
3529     ESYS_TR shandle3,
3530     UINT64 bits);
3531 
3532 TSS2_RC
3533 Esys_NV_SetBits_Async(
3534     ESYS_CONTEXT *esysContext,
3535     ESYS_TR authHandle,
3536     ESYS_TR nvIndex,
3537     ESYS_TR shandle1,
3538     ESYS_TR shandle2,
3539     ESYS_TR shandle3,
3540     UINT64 bits);
3541 
3542 TSS2_RC
3543 Esys_NV_SetBits_Finish(
3544     ESYS_CONTEXT *esysContext);
3545 
3546 /* Table 221 - TPM2_NV_WriteLock Command */
3547 
3548 TSS2_RC
3549 Esys_NV_WriteLock(
3550     ESYS_CONTEXT *esysContext,
3551     ESYS_TR authHandle,
3552     ESYS_TR nvIndex,
3553     ESYS_TR shandle1,
3554     ESYS_TR shandle2,
3555     ESYS_TR shandle3);
3556 
3557 TSS2_RC
3558 Esys_NV_WriteLock_Async(
3559     ESYS_CONTEXT *esysContext,
3560     ESYS_TR authHandle,
3561     ESYS_TR nvIndex,
3562     ESYS_TR shandle1,
3563     ESYS_TR shandle2,
3564     ESYS_TR shandle3);
3565 
3566 TSS2_RC
3567 Esys_NV_WriteLock_Finish(
3568     ESYS_CONTEXT *esysContext);
3569 
3570 /* Table 223 - TPM2_NV_GlobalWriteLock Command */
3571 
3572 TSS2_RC
3573 Esys_NV_GlobalWriteLock(
3574     ESYS_CONTEXT *esysContext,
3575     ESYS_TR authHandle,
3576     ESYS_TR shandle1,
3577     ESYS_TR shandle2,
3578     ESYS_TR shandle3);
3579 
3580 TSS2_RC
3581 Esys_NV_GlobalWriteLock_Async(
3582     ESYS_CONTEXT *esysContext,
3583     ESYS_TR authHandle,
3584     ESYS_TR shandle1,
3585     ESYS_TR shandle2,
3586     ESYS_TR shandle3);
3587 
3588 TSS2_RC
3589 Esys_NV_GlobalWriteLock_Finish(
3590     ESYS_CONTEXT *esysContext);
3591 
3592 /* Table 225 - TPM2_NV_Read Command */
3593 
3594 TSS2_RC
3595 Esys_NV_Read(
3596     ESYS_CONTEXT *esysContext,
3597     ESYS_TR authHandle,
3598     ESYS_TR nvIndex,
3599     ESYS_TR shandle1,
3600     ESYS_TR shandle2,
3601     ESYS_TR shandle3,
3602     UINT16 size,
3603     UINT16 offset,
3604     TPM2B_MAX_NV_BUFFER **data);
3605 
3606 TSS2_RC
3607 Esys_NV_Read_Async(
3608     ESYS_CONTEXT *esysContext,
3609     ESYS_TR authHandle,
3610     ESYS_TR nvIndex,
3611     ESYS_TR shandle1,
3612     ESYS_TR shandle2,
3613     ESYS_TR shandle3,
3614     UINT16 size,
3615     UINT16 offset);
3616 
3617 TSS2_RC
3618 Esys_NV_Read_Finish(
3619     ESYS_CONTEXT *esysContext,
3620     TPM2B_MAX_NV_BUFFER **data);
3621 
3622 /* Table 227 - TPM2_NV_ReadLock Command */
3623 
3624 TSS2_RC
3625 Esys_NV_ReadLock(
3626     ESYS_CONTEXT *esysContext,
3627     ESYS_TR authHandle,
3628     ESYS_TR nvIndex,
3629     ESYS_TR shandle1,
3630     ESYS_TR shandle2,
3631     ESYS_TR shandle3);
3632 
3633 TSS2_RC
3634 Esys_NV_ReadLock_Async(
3635     ESYS_CONTEXT *esysContext,
3636     ESYS_TR authHandle,
3637     ESYS_TR nvIndex,
3638     ESYS_TR shandle1,
3639     ESYS_TR shandle2,
3640     ESYS_TR shandle3);
3641 
3642 TSS2_RC
3643 Esys_NV_ReadLock_Finish(
3644     ESYS_CONTEXT *esysContext);
3645 
3646 /* Table 229 - TPM2_NV_ChangeAuth Command */
3647 
3648 TSS2_RC
3649 Esys_NV_ChangeAuth(
3650     ESYS_CONTEXT *esysContext,
3651     ESYS_TR nvIndex,
3652     ESYS_TR shandle1,
3653     ESYS_TR shandle2,
3654     ESYS_TR shandle3,
3655     const TPM2B_AUTH *newAuth);
3656 
3657 TSS2_RC
3658 Esys_NV_ChangeAuth_Async(
3659     ESYS_CONTEXT *esysContext,
3660     ESYS_TR nvIndex,
3661     ESYS_TR shandle1,
3662     ESYS_TR shandle2,
3663     ESYS_TR shandle3,
3664     const TPM2B_AUTH *newAuth);
3665 
3666 TSS2_RC
3667 Esys_NV_ChangeAuth_Finish(
3668     ESYS_CONTEXT *esysContext);
3669 
3670 /* Table 231 - TPM2_NV_Certify Command */
3671 
3672 TSS2_RC
3673 Esys_NV_Certify(
3674     ESYS_CONTEXT *esysContext,
3675     ESYS_TR signHandle,
3676     ESYS_TR authHandle,
3677     ESYS_TR nvIndex,
3678     ESYS_TR shandle1,
3679     ESYS_TR shandle2,
3680     ESYS_TR shandle3,
3681     const TPM2B_DATA *qualifyingData,
3682     const TPMT_SIG_SCHEME *inScheme,
3683     UINT16 size,
3684     UINT16 offset,
3685     TPM2B_ATTEST **certifyInfo,
3686     TPMT_SIGNATURE **signature);
3687 
3688 TSS2_RC
3689 Esys_NV_Certify_Async(
3690     ESYS_CONTEXT *esysContext,
3691     ESYS_TR signHandle,
3692     ESYS_TR authHandle,
3693     ESYS_TR nvIndex,
3694     ESYS_TR shandle1,
3695     ESYS_TR shandle2,
3696     ESYS_TR shandle3,
3697     const TPM2B_DATA *qualifyingData,
3698     const TPMT_SIG_SCHEME *inScheme,
3699     UINT16 size,
3700     UINT16 offset);
3701 
3702 TSS2_RC
3703 Esys_NV_Certify_Finish(
3704     ESYS_CONTEXT *esysContext,
3705     TPM2B_ATTEST **certifyInfo,
3706     TPMT_SIGNATURE **signature);
3707 
3708 /* Table 233 - TPM2_Vendor_TCG_Test Command */
3709 
3710 TSS2_RC
3711 Esys_Vendor_TCG_Test(
3712     ESYS_CONTEXT *esysContext,
3713     ESYS_TR shandle1,
3714     ESYS_TR shandle2,
3715     ESYS_TR shandle3,
3716     const TPM2B_DATA *inputData,
3717     TPM2B_DATA **outputData);
3718 
3719 TSS2_RC
3720 Esys_Vendor_TCG_Test_Async(
3721     ESYS_CONTEXT *esysContext,
3722     ESYS_TR shandle1,
3723     ESYS_TR shandle2,
3724     ESYS_TR shandle3,
3725     const TPM2B_DATA *inputData);
3726 
3727 TSS2_RC
3728 Esys_Vendor_TCG_Test_Finish(
3729     ESYS_CONTEXT *esysContext,
3730     TPM2B_DATA **outputData);
3731 
3732 /*
3733  * TPM 2.0 ESAPI Helper Functions
3734  */
3735 void
3736 Esys_Free(
3737     void *__ptr);
3738 
3739 TSS2_RC
3740 Esys_GetSysContext(
3741     ESYS_CONTEXT *esys_context,
3742     TSS2_SYS_CONTEXT **sys_context);
3743 
3744 TSS2_RC
3745 Esys_SetCryptoCallbacks(
3746     ESYS_CONTEXT *esysContext,
3747     ESYS_CRYPTO_CALLBACKS *callbacks);
3748 
3749 #ifdef __cplusplus
3750 }
3751 #endif
3752 
3753 #endif /* TSS2_ESYS_H */

tss2_fapi.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef TSS2_FAPI_H
7 #define TSS2_FAPI_H
8 
9 #include <stddef.h>
10 #include <stdint.h>
11 
12 #include "tss2_tcti.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /* Type definitions */
19 
20 typedef struct FAPI_CONTEXT FAPI_CONTEXT;
21 
22 
23 /* Defines for blob type of Fapi_GetEsysBlob */
24 
25 #define FAPI_ESYSBLOB_CONTEXTLOAD 1
26 #define FAPI_ESYSBLOB_DESERIALIZE 2
27 
28 /* Context functions */
29 
30 TSS2_RC Fapi_Initialize(
31     FAPI_CONTEXT  **context,
32     char     const *uri);
33 
34 TSS2_RC Fapi_Initialize_Async(
35     FAPI_CONTEXT  **context,
36     char     const *uri);
37 
38 TSS2_RC Fapi_Initialize_Finish(
39     FAPI_CONTEXT  **context);
40 
41 void Fapi_Finalize(
42     FAPI_CONTEXT  **context);
43 
44 TSS2_RC Fapi_GetTcti(
45     FAPI_CONTEXT       *context,
46     TSS2_TCTI_CONTEXT **tcti);
47 
48 void Fapi_Free(
49     void           *ptr);
50 
51 #if defined(__linux__) || defined(__unix__) || defined(__APPLE__) || defined (__QNXNTO__) || defined (__VXWORKS__)
52 #if defined (__VXWORKS__)
53 #include <sys/poll.h>
54 #else
55 #include <poll.h>
56 #endif
57 typedef struct pollfd FAPI_POLL_HANDLE;
58 #elif defined(_WIN32)
59 #include <windows.h>
60 typedef HANDLE FAPI_POLL_HANDLE;
61 #else
62 typedef void FAPI_POLL_HANDLE;
63 #ifndef FAPI_SUPPRESS_POLL_WARNINGS
64 #pragma message "Info: Platform not supported for FAPI_POLL_HANDLES"
65 #endif
66 #endif
67 
68 TSS2_RC Fapi_GetPollHandles(
69     FAPI_CONTEXT      *context,
70     FAPI_POLL_HANDLE **handles,
71     size_t            *num_handles);
72 
73 TSS2_RC Fapi_GetInfo(
74     FAPI_CONTEXT   *context,
75     char          **info);
76 
77 TSS2_RC Fapi_GetInfo_Async(
78     FAPI_CONTEXT   *context);
79 
80 TSS2_RC Fapi_GetInfo_Finish(
81     FAPI_CONTEXT   *context,
82     char          **info);
83 
84 /* General functions */
85 
86 TSS2_RC Fapi_Provision(
87     FAPI_CONTEXT   *context,
88     char     const *authValueEh,
89     char     const *authValueSh,
90     char     const *authValueLockout);
91 
92 TSS2_RC Fapi_Provision_Async(
93     FAPI_CONTEXT   *context,
94     char     const *authValueEh,
95     char     const *authValueSh,
96     char     const *authValueLockout);
97 
98 TSS2_RC Fapi_Provision_Finish(
99     FAPI_CONTEXT   *context);
100 
101 TSS2_RC Fapi_GetPlatformCertificates(
102     FAPI_CONTEXT   *context,
103     uint8_t       **certificates,
104     size_t         *certificatesSize);
105 
106 TSS2_RC Fapi_GetPlatformCertificates_Async(
107     FAPI_CONTEXT   *context);
108 
109 TSS2_RC Fapi_GetPlatformCertificates_Finish(
110     FAPI_CONTEXT   *context,
111     uint8_t       **certificates,
112     size_t         *certificatesSize);
113 
114 TSS2_RC Fapi_GetRandom(
115     FAPI_CONTEXT   *context,
116     size_t          numBytes,
117     uint8_t       **data);
118 
119 TSS2_RC Fapi_GetRandom_Async(
120     FAPI_CONTEXT   *context,
121     size_t          numBytes);
122 
123 TSS2_RC Fapi_GetRandom_Finish(
124     FAPI_CONTEXT   *context,
125     uint8_t       **data);
126 
127 TSS2_RC Fapi_Import(
128     FAPI_CONTEXT   *context,
129     char     const *path,
130     char     const *importData);
131 
132 TSS2_RC Fapi_Import_Async(
133     FAPI_CONTEXT   *context,
134     char     const *path,
135     char     const *importData);
136 
137 TSS2_RC Fapi_Import_Finish(
138     FAPI_CONTEXT   *context);
139 
140 TSS2_RC Fapi_List(
141     FAPI_CONTEXT   *context,
142     char     const *searchPath,
143     char          **pathList);
144 
145 TSS2_RC Fapi_List_Async(
146     FAPI_CONTEXT   *context,
147     char     const *searchPath);
148 
149 TSS2_RC Fapi_List_Finish(
150     FAPI_CONTEXT   *context,
151     char          **pathList);
152 
153 TSS2_RC Fapi_Delete(
154     FAPI_CONTEXT   *context,
155     char     const *path);
156 
157 TSS2_RC Fapi_Delete_Async(
158     FAPI_CONTEXT   *context,
159     char     const *path);
160 
161 TSS2_RC Fapi_Delete_Finish(
162     FAPI_CONTEXT   *context);
163 
164 TSS2_RC Fapi_GetEsysBlob(
165     FAPI_CONTEXT   *context,
166     char     const *path,
167     uint8_t        *type,
168     uint8_t       **data,
169     size_t         *length);
170 
171 TSS2_RC Fapi_GetEsysBlob_Async(
172     FAPI_CONTEXT   *context,
173     char     const *path);
174 
175 TSS2_RC Fapi_GetEsysBlob_Finish(
176     FAPI_CONTEXT   *context,
177     uint8_t        *type,
178     uint8_t       **data,
179     size_t         *length);
180 
181 TSS2_RC Fapi_ChangeAuth(
182     FAPI_CONTEXT   *context,
183     char     const *entityPath,
184     char     const *authValue);
185 
186 TSS2_RC Fapi_ChangeAuth_Async(
187     FAPI_CONTEXT   *context,
188     char     const *entityPath,
189     char     const *authValue);
190 
191 TSS2_RC Fapi_ChangeAuth_Finish(
192     FAPI_CONTEXT   *context);
193 
194 TSS2_RC Fapi_SetDescription(
195     FAPI_CONTEXT   *context,
196     char     const *path,
197     char     const *description);
198 
199 TSS2_RC Fapi_SetDescription_Async(
200     FAPI_CONTEXT   *context,
201     char     const *path,
202     char     const *description);
203 
204 TSS2_RC Fapi_SetDescription_Finish(
205     FAPI_CONTEXT   *context);
206 
207 TSS2_RC Fapi_GetDescription(
208     FAPI_CONTEXT   *context,
209     char     const *path,
210     char          **description);
211 
212 TSS2_RC Fapi_GetDescription_Async(
213     FAPI_CONTEXT   *context,
214     char     const *path);
215 
216 TSS2_RC Fapi_GetDescription_Finish(
217     FAPI_CONTEXT   *context,
218     char          **description);
219 
220 TSS2_RC Fapi_SetAppData(
221     FAPI_CONTEXT   *context,
222     char     const *path,
223     uint8_t  const *appData,
224     size_t          appDataSize);
225 
226 TSS2_RC Fapi_SetAppData_Async(
227     FAPI_CONTEXT   *context,
228     char     const *path,
229     uint8_t  const *appData,
230     size_t          appDataSize);
231 
232 TSS2_RC Fapi_SetAppData_Finish(
233     FAPI_CONTEXT   *context);
234 
235 TSS2_RC Fapi_GetAppData(
236     FAPI_CONTEXT   *context,
237     char     const *path,
238     uint8_t       **appData,
239     size_t         *appDataSize);
240 
241 TSS2_RC Fapi_GetAppData_Async(
242     FAPI_CONTEXT   *context,
243     char     const *path);
244 
245 TSS2_RC Fapi_GetAppData_Finish(
246     FAPI_CONTEXT   *context,
247     uint8_t       **appData,
248     size_t         *appDataSize);
249 
250 TSS2_RC Fapi_GetTpmBlobs(
251     FAPI_CONTEXT   *context,
252     char     const *path,
253     uint8_t       **tpm2bPublic,
254     size_t         *tpm2bPublicSize,
255     uint8_t       **tpm2bPrivate,
256     size_t         *tpm2bPrivateSize,
257     char          **policy);
258 
259 TSS2_RC Fapi_GetTpmBlobs_Async(
260     FAPI_CONTEXT   *context,
261     char     const *path);
262 
263 TSS2_RC Fapi_GetTpmBlobs_Finish(
264     FAPI_CONTEXT   *context,
265     uint8_t       **tpm2bPublic,
266     size_t         *tpm2bPublicSize,
267     uint8_t       **tpm2bPrivate,
268     size_t         *tpm2bPrivateSize,
269     char          **policy);
270 
271 /* Key functions */
272 
273 TSS2_RC Fapi_CreateKey(
274     FAPI_CONTEXT   *context,
275     char     const *path,
276     char     const *type,
277     char     const *policyPath,
278     char     const *authValue);
279 
280 TSS2_RC Fapi_CreateKey_Async(
281     FAPI_CONTEXT   *context,
282     char     const *path,
283     char     const *type,
284     char     const *policyPath,
285     char     const *authValue);
286 
287 TSS2_RC Fapi_CreateKey_Finish(
288     FAPI_CONTEXT   *context);
289 
290 TSS2_RC Fapi_Sign(
291     FAPI_CONTEXT   *context,
292     char     const *keyPath,
293     char     const *padding,
294     uint8_t  const *digest,
295     size_t          digestSize,
296     uint8_t       **signature,
297     size_t         *signatureSize,
298     char          **publicKey,
299     char          **certificate);
300 
301 TSS2_RC Fapi_Sign_Async(
302     FAPI_CONTEXT   *context,
303     char     const *keyPath,
304     char     const *padding,
305     uint8_t  const *digest,
306     size_t         digestSize);
307 
308 TSS2_RC Fapi_Sign_Finish(
309     FAPI_CONTEXT   *context,
310     uint8_t       **signature,
311     size_t         *signatureSize,
312     char          **publicKey,
313     char          **certificate);
314 
315 TSS2_RC Fapi_VerifySignature(
316     FAPI_CONTEXT   *context,
317     char     const *keyPath,
318     uint8_t  const *digest,
319     size_t          digestSize,
320     uint8_t  const *signature,
321     size_t          signatureSize);
322 
323 TSS2_RC Fapi_VerifySignature_Async(
324     FAPI_CONTEXT   *context,
325     char     const *keyPath,
326     uint8_t  const *digest,
327     size_t          digestSize,
328     uint8_t  const *signature,
329     size_t          signatureSize);
330 
331 TSS2_RC Fapi_VerifySignature_Finish(
332     FAPI_CONTEXT   *context);
333 
334 TSS2_RC Fapi_Encrypt(
335     FAPI_CONTEXT   *context,
336     char     const *keyPath,
337     uint8_t  const *plainText,
338     size_t          plainTextSize,
339     uint8_t       **cipherText,
340     size_t         *cipherTextSize);
341 
342 TSS2_RC Fapi_Encrypt_Async(
343     FAPI_CONTEXT   *context,
344     char     const *keyPath,
345     uint8_t  const *plainText,
346     size_t          plainTextSize);
347 
348 TSS2_RC Fapi_Encrypt_Finish(
349     FAPI_CONTEXT   *context,
350     uint8_t       **cipherText,
351     size_t         *cipherTextSize );
352 
353 TSS2_RC Fapi_Decrypt(
354     FAPI_CONTEXT   *context,
355     char     const *keyPath,
356     uint8_t  const *cipherText,
357     size_t          cipherTextSize,
358     uint8_t       **plainText,
359     size_t         *plainTextSize);
360 
361 TSS2_RC Fapi_Decrypt_Async(
362     FAPI_CONTEXT   *context,
363     char     const *keyPath,
364     uint8_t  const *cipherText,
365     size_t          cipherTextSize);
366 
367 TSS2_RC Fapi_Decrypt_Finish(
368     FAPI_CONTEXT   *context,
369     uint8_t       **plainText,
370     size_t         *plainTextSize);
371 
372 TSS2_RC Fapi_SetCertificate(
373     FAPI_CONTEXT   *context,
374     char     const *path,
375     char     const *x509certData);
376 
377 TSS2_RC Fapi_SetCertificate_Async(
378     FAPI_CONTEXT   *context,
379     char     const *path,
380     char     const *x509certData);
381 
382 TSS2_RC Fapi_SetCertificate_Finish(
383     FAPI_CONTEXT   *context);
384 
385 TSS2_RC Fapi_GetCertificate(
386     FAPI_CONTEXT   *context,
387     char     const *path,
388     char          **x509certData);
389 
390 TSS2_RC Fapi_GetCertificate_Async(
391     FAPI_CONTEXT   *context,
392     char     const *path);
393 
394 TSS2_RC Fapi_GetCertificate_Finish(
395     FAPI_CONTEXT   *context,
396     char          **x509certData);
397 
398 TSS2_RC Fapi_ExportKey(
399     FAPI_CONTEXT   *context,
400     char     const *pathOfKeyToDuplicate,
401     char     const *pathToPublicKeyOfNewParent,
402     char          **exportedData);
403 
404 TSS2_RC Fapi_ExportKey_Async(
405     FAPI_CONTEXT   *context,
406     char     const *pathOfKeyToDuplicate,
407     char     const *pathToPublicKeyOfNewParent);
408 
409 TSS2_RC Fapi_ExportKey_Finish(
410     FAPI_CONTEXT   *context,
411     char          **exportedData);
412 
413 /* Seal functions */
414 
415 TSS2_RC Fapi_CreateSeal(
416     FAPI_CONTEXT   *context,
417     char     const *path,
418     char     const *type,
419     size_t          size,
420     char     const *policyPath,
421     char     const *authValue,
422     uint8_t  const *data);
423 
424 TSS2_RC Fapi_CreateSeal_Async(
425     FAPI_CONTEXT   *context,
426     char     const *path,
427     char     const *type,
428     size_t          size,
429     char     const *policyPath,
430     char     const *authValue,
431     uint8_t  const *data);
432 
433 TSS2_RC Fapi_CreateSeal_Finish(
434     FAPI_CONTEXT   *context);
435 
436 TSS2_RC Fapi_Unseal(
437     FAPI_CONTEXT   *context,
438     char     const *path,
439     uint8_t       **data,
440     size_t         *size);
441 
442 TSS2_RC Fapi_Unseal_Async(
443     FAPI_CONTEXT   *context,
444     char     const *path);
445 
446 TSS2_RC Fapi_Unseal_Finish(
447     FAPI_CONTEXT   *context,
448     uint8_t       **data,
449     size_t         *size);
450 
451 /* Policy functions */
452 
453 TSS2_RC Fapi_ExportPolicy(
454     FAPI_CONTEXT   *context,
455     char     const *path,
456     char          **jsonPolicy);
457 
458 TSS2_RC Fapi_ExportPolicy_Async(
459     FAPI_CONTEXT   *context,
460     char     const *path);
461 
462 TSS2_RC Fapi_ExportPolicy_Finish(
463     FAPI_CONTEXT   *context,
464     char          **jsonPolicy);
465 
466 TSS2_RC Fapi_AuthorizePolicy(
467     FAPI_CONTEXT   *context,
468     char     const *policyPath,
469     char     const *keyPath,
470     uint8_t  const *policyRef,
471     size_t          policyRefSize);
472 
473 TSS2_RC Fapi_AuthorizePolicy_Async(
474     FAPI_CONTEXT   *context,
475     char     const *policyPath,
476     char     const *keyPath,
477     uint8_t  const *policyRef,
478     size_t          policyRefSize);
479 
480 TSS2_RC Fapi_AuthorizePolicy_Finish(
481     FAPI_CONTEXT   *context);
482 
483 TSS2_RC Fapi_WriteAuthorizeNv(
484     FAPI_CONTEXT   *context,
485     char     const *nvPath,
486     char     const *policyPath);
487 
488 TSS2_RC Fapi_WriteAuthorizeNv_Async(
489     FAPI_CONTEXT   *context,
490     char     const *nvPath,
491     char     const *policyPath);
492 
493 TSS2_RC Fapi_WriteAuthorizeNv_Finish(
494     FAPI_CONTEXT   *context);
495 
496 /* Attestation functions */
497 
498 TSS2_RC Fapi_PcrRead(
499     FAPI_CONTEXT   *context,
500     uint32_t        pcrIndex,
501     uint8_t       **pcrValue,
502     size_t         *pcrValueSize,
503     char          **pcrLog);
504 
505 TSS2_RC Fapi_PcrRead_Async(
506     FAPI_CONTEXT   *context,
507     uint32_t        pcrIndex);
508 
509 TSS2_RC Fapi_PcrRead_Finish(
510     FAPI_CONTEXT   *context,
511     uint8_t       **pcrValue,
512     size_t         *pcrValueSize,
513     char          **pcrLog);
514 
515 TSS2_RC Fapi_PcrExtend(
516     FAPI_CONTEXT   *context,
517     uint32_t        pcr,
518     uint8_t  const *data,
519     size_t          dataSize,
520     char     const *logData);
521 
522 TSS2_RC Fapi_PcrExtend_Async(
523     FAPI_CONTEXT   *context,
524     uint32_t        pcr,
525     uint8_t  const *data,
526     size_t          dataSize,
527     char     const *logData);
528 
529 TSS2_RC Fapi_PcrExtend_Finish(
530     FAPI_CONTEXT   *context);
531 
532 
533 TSS2_RC Fapi_Quote(
534     FAPI_CONTEXT   *context,
535     uint32_t       *pcrList,
536     size_t          pcrListSize,
537     char     const *keyPath,
538     char     const *quoteType,
539     uint8_t  const *qualifyingData,
540     size_t          qualifyingDataSize,
541     char          **quoteInfo,
542     uint8_t       **signature,
543     size_t         *signatureSize,
544     char          **pcrLog,
545     char          **certificate);
546 
547 TSS2_RC Fapi_Quote_Async(
548     FAPI_CONTEXT   *context,
549     uint32_t       *pcrList,
550     size_t          pcrListSize,
551     char     const *keyPath,
552     char     const *quoteType,
553     uint8_t  const *qualifyingData,
554     size_t          qualifyingDataSize);
555 
556 TSS2_RC Fapi_Quote_Finish(
557     FAPI_CONTEXT  *context,
558     char         **quoteInfo,
559     uint8_t      **signature,
560     size_t        *signatureSize,
561     char          **pcrLog,
562     char          **certificate);
563 
564 TSS2_RC Fapi_VerifyQuote(
565     FAPI_CONTEXT   *context,
566     char     const *publicKeyPath,
567     uint8_t  const *qualifyingData,
568     size_t          qualifyingDataSize,
569     char     const *quoteInfo,
570     uint8_t  const *signature,
571     size_t          signatureSize,
572     char     const *pcrLog);
573 
574 TSS2_RC Fapi_VerifyQuote_Async(
575     FAPI_CONTEXT   *context,
576     char     const *publicKeyPath,
577     uint8_t  const *qualifyingData,
578     size_t          qualifyingDataSize,
579     char     const *quoteInfo,
580     uint8_t  const *signature,
581     size_t          signatureSize,
582     char     const *pcrLog);
583 
584 TSS2_RC Fapi_VerifyQuote_Finish(
585     FAPI_CONTEXT   *context);
586 
587 /* NV functions */
588 
589 TSS2_RC Fapi_CreateNv(
590     FAPI_CONTEXT *context,
591     char   const *path,
592     char   const *type,
593     size_t        size,
594     char   const *policyPath,
595     char   const *authValue);
596 
597 TSS2_RC Fapi_CreateNv_Async(
598     FAPI_CONTEXT *context,
599     char   const *path,
600     char   const *type,
601     size_t        size,
602     char   const *policyPath,
603     char   const *authValue);
604 
605 TSS2_RC Fapi_CreateNv_Finish(
606     FAPI_CONTEXT *context);
607 
608 TSS2_RC Fapi_NvRead(
609     FAPI_CONTEXT   *context,
610     char     const *path,
611     uint8_t      **data,
612     size_t        *size,
613     char         **logData);
614 
615 TSS2_RC Fapi_NvRead_Async(
616     FAPI_CONTEXT   *context,
617     char     const *path);
618 
619 TSS2_RC Fapi_NvRead_Finish(
620     FAPI_CONTEXT   *context,
621     uint8_t       **data,
622     size_t         *size,
623     char          **logData);
624 
625 TSS2_RC Fapi_NvWrite(
626     FAPI_CONTEXT  *context,
627     char    const *path,
628     uint8_t const *data,
629     size_t         size);
630 
631 TSS2_RC Fapi_NvWrite_Async(
632     FAPI_CONTEXT  *context,
633     char    const *path,
634     uint8_t const *data,
635     size_t         size);
636 
637 TSS2_RC Fapi_NvWrite_Finish(
638     FAPI_CONTEXT   *context);
639 
640 TSS2_RC Fapi_NvExtend(
641     FAPI_CONTEXT  *context,
642     char    const *path,
643     uint8_t const *data,
644     size_t         size,
645     char    const *logData);
646 
647 TSS2_RC Fapi_NvExtend_Async(
648     FAPI_CONTEXT  *context,
649     char    const *path,
650     uint8_t const *data,
651     size_t         size,
652     char    const *logData);
653 
654 TSS2_RC Fapi_NvExtend_Finish(
655     FAPI_CONTEXT  *context);
656 
657 TSS2_RC Fapi_NvIncrement(
658     FAPI_CONTEXT   *context,
659     char     const *path);
660 
661 TSS2_RC Fapi_NvIncrement_Async(
662     FAPI_CONTEXT   *context,
663     char     const *path);
664 
665 TSS2_RC Fapi_NvIncrement_Finish(
666     FAPI_CONTEXT   *context);
667 
668 TSS2_RC Fapi_NvSetBits(
669     FAPI_CONTEXT   *context,
670     char     const *path,
671     uint64_t        bitmap);
672 
673 TSS2_RC Fapi_NvSetBits_Async(
674     FAPI_CONTEXT   *context,
675     char     const *path,
676     uint64_t        bitmap);
677 
678 TSS2_RC Fapi_NvSetBits_Finish(
679     FAPI_CONTEXT   *context);
680 
681 typedef TSS2_RC (*Fapi_CB_Auth)(
682     char     const *objectPath,
683     char     const *description,
684     char    const **auth,
685     void           *userData);
686 
687 TSS2_RC Fapi_SetAuthCB(
688     FAPI_CONTEXT   *context,
689     Fapi_CB_Auth    callback,
690     void           *userData);
691 
692 typedef TSS2_RC (*Fapi_CB_Branch)(
693     char     const *objectPath,
694     char     const *description,
695     char    const **branchNames,
696     size_t          numBranches,
697     size_t         *selectedBranch,
698     void           *userData);
699 
700 TSS2_RC Fapi_SetBranchCB(
701     FAPI_CONTEXT   *context,
702     Fapi_CB_Branch  callback,
703     void           *userData);
704 
705 typedef TSS2_RC (*Fapi_CB_Sign)(
706     char     const *objectPath,
707     char     const *description,
708     char     const *publicKey,
709     char     const *publicKeyHint,
710     uint32_t        hashAlg,
711     uint8_t  const *dataToSign,
712     size_t          dataToSignSize,
713     uint8_t const **signature,
714     size_t         *signatureSize,
715     void           *userData);
716 
717 TSS2_RC Fapi_SetSignCB(
718     FAPI_CONTEXT   *context,
719     Fapi_CB_Sign    callback,
720     void           *userData);
721 
722 typedef TSS2_RC (*Fapi_CB_PolicyAction)(
723     char     const *objectPath,
724     char     const *action,
725     void           *userData);
726 
727 TSS2_RC Fapi_SetPolicyActionCB(
728     FAPI_CONTEXT        *context,
729     Fapi_CB_PolicyAction callback,
730     void                *userData);
731 
732 #ifdef __cplusplus
733 }
734 #endif
735 
736 #endif /* TSS2_FAPI_H */

esys_crypto.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef ESYS_CRYPTO_H
7 #define ESYS_CRYPTO_H
8 
9 #include <stddef.h>
10 #include "tss2_tpm2_types.h"
11 #include "tss2-sys/sysapi_util.h"
12 #if defined(OSSL)
13 #include "esys_crypto_ossl.h"
14 #elif defined(MBED)
15 #include "esys_crypto_mbed.h"
16 #else
17 #define _iesys_crypto_aes_decrypt NULL;
18 #define _iesys_crypto_aes_encrypt NULL;
19 #define _iesys_crypto_get_ecdh_point NULL;
20 #define _iesys_crypto_hash_abort NULL;
21 #define _iesys_crypto_hash_finish NULL;
22 #define _iesys_crypto_hash_start NULL;
23 #define _iesys_crypto_hash_update NULL;
24 #define _iesys_crypto_hmac_abort NULL;
25 #define _iesys_crypto_hmac_finish NULL;
26 #define _iesys_crypto_hmac_start NULL;
27 #define _iesys_crypto_hmac_update NULL;
28 #define _iesys_crypto_init NULL;
29 #define _iesys_crypto_get_random2b NULL;
30 #define _iesys_crypto_rsa_pk_encrypt NULL;
31 #endif
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define AES_BLOCK_SIZE_IN_BYTES 16
38 
39 TSS2_RC iesys_crypto_hash_get_digest_size(TPM2_ALG_ID hashAlg, size_t *size);
40 
41 TSS2_RC iesys_crypto_pHash(
42     ESYS_CRYPTO_CALLBACKS *crypto_cb,
43     TPM2_ALG_ID alg,
44     const uint8_t rcBuffer[4],
45     const uint8_t ccBuffer[4],
46     const TPM2B_NAME *name1,
47     const TPM2B_NAME *name2,
48     const TPM2B_NAME *name3,
49     const uint8_t *pBuffer,
50     size_t pBuffer_size,
51     uint8_t *pHash,
52     size_t *pHash_size);
53 
54 #define iesys_crypto_cpHash(ectx, alg, ccBuffer, name1, name2, name3, \
55                             cpBuffer, cpBuffer_size, cpHash, cpHash_size) \
56         iesys_crypto_pHash(ectx, alg, NULL, ccBuffer, name1, name2, name3, cpBuffer, \
57                            cpBuffer_size, cpHash, cpHash_size)
58 #define iesys_crypto_rpHash(ectx, alg, rcBuffer, ccBuffer, rpBuffer, rpBuffer_size, \
59                             rpHash, rpHash_size)                        \
60         iesys_crypto_pHash(ectx, alg, rcBuffer, ccBuffer, NULL, NULL, NULL, rpBuffer, \
61                            rpBuffer_size, rpHash, rpHash_size)
62 
63 TSS2_RC iesys_crypto_hmac_finish2b(
64     ESYS_CRYPTO_CALLBACKS *crypto_cb,
65     ESYS_CRYPTO_CONTEXT_BLOB ** context,
66     TPM2B *tpm2b);
67 
68 TSS2_RC iesys_crypto_hmac_update2b(
69     ESYS_CRYPTO_CALLBACKS *crypto_cb,
70     ESYS_CRYPTO_CONTEXT_BLOB * context,
71     TPM2B *tpm2b);
72 
73 TSS2_RC iesys_crypto_hash_update2b(
74     ESYS_CRYPTO_CALLBACKS *crypto_cb,
75     ESYS_CRYPTO_CONTEXT_BLOB * context,
76     TPM2B *tpm2b);
77 
78 TSS2_RC iesys_crypto_rsa_pk_encrypt(
79     ESYS_CRYPTO_CALLBACKS *crypto_cb,
80     TPM2B_PUBLIC * pub_tpm_key,
81     size_t in_size,
82     BYTE * in_buffer,
83     size_t max_out_size,
84     BYTE * out_buffer,
85     size_t * out_size,
86     const char *label);
87 
88 TSS2_RC iesys_crypto_hash_start(
89     ESYS_CRYPTO_CALLBACKS *crypto_cb,
90     ESYS_CRYPTO_CONTEXT_BLOB **context,
91     TPM2_ALG_ID hashAlg);
92 
93 TSS2_RC  iesys_crypto_hash_update(
94     ESYS_CRYPTO_CALLBACKS *crypto_cb,
95     ESYS_CRYPTO_CONTEXT_BLOB *context,
96     const uint8_t *buffer,
97     size_t size);
98 
99 TSS2_RC iesys_crypto_hash_finish(
100     ESYS_CRYPTO_CALLBACKS *crypto_cb,
101     ESYS_CRYPTO_CONTEXT_BLOB ** context,
102     uint8_t *buffer,
103     size_t *size);
104 
105 TSS2_RC iesys_crypto_hash_abort(
106     ESYS_CRYPTO_CALLBACKS *crypto_cb,
107     ESYS_CRYPTO_CONTEXT_BLOB **context);
108 
109 TSS2_RC iesys_crypto_hmac_start(
110     ESYS_CRYPTO_CALLBACKS *crypto_cb,
111     ESYS_CRYPTO_CONTEXT_BLOB **context,
112    TPM2_ALG_ID hashAlg,
113    const uint8_t *key,
114    size_t size);
115 
116 TSS2_RC iesys_crypto_hmac_update(
117     ESYS_CRYPTO_CALLBACKS *crypto_cb,
118     ESYS_CRYPTO_CONTEXT_BLOB * context,
119     const uint8_t *buffer,
120     size_t size);
121 
122 TSS2_RC iesys_crypto_hmac_finish(
123     ESYS_CRYPTO_CALLBACKS *crypto_cb,
124     ESYS_CRYPTO_CONTEXT_BLOB **context,
125     uint8_t *buffer,
126     size_t * size);
127 
128 TSS2_RC iesys_crypto_hmac_abort(
129     ESYS_CRYPTO_CALLBACKS *crypto_cb,
130     ESYS_CRYPTO_CONTEXT_BLOB **context);
131 
132 TSS2_RC iesys_crypto_get_random2b(
133     ESYS_CRYPTO_CALLBACKS *crypto_cb,
134     TPM2B_NONCE *nonce,
135     size_t num_bytes);
136 
137 TSS2_RC iesys_crypto_get_ecdh_point(
138     ESYS_CRYPTO_CALLBACKS *crypto_cb,
139     TPM2B_PUBLIC *key,
140     size_t max_out_size,
141     TPM2B_ECC_PARAMETER *Z,
142     TPMS_ECC_POINT *Q,
143     BYTE * out_buffer,
144     size_t * out_size);
145 
146  TSS2_RC iesys_crypto_aes_encrypt(
147     ESYS_CRYPTO_CALLBACKS *crypto_cb,
148     uint8_t *key,
149     TPM2_ALG_ID tpm_sym_alg,
150     TPMI_AES_KEY_BITS key_bits,
151     TPM2_ALG_ID tpm_mode,
152     uint8_t *buffer,
153     size_t buffer_size,
154     uint8_t *iv);
155 
156 TSS2_RC iesys_crypto_aes_decrypt(
157     ESYS_CRYPTO_CALLBACKS *crypto_cb,
158     uint8_t *key,
159     TPM2_ALG_ID tpm_sym_alg,
160     TPMI_AES_KEY_BITS key_bits,
161     TPM2_ALG_ID tpm_mode,
162     uint8_t *buffer,
163     size_t buffer_size,
164     uint8_t *iv);
165 
166 TSS2_RC iesys_crypto_authHmac(
167     ESYS_CRYPTO_CALLBACKS *crypto_cb,
168     TPM2_ALG_ID alg,
169     uint8_t *hmacKey,
170     size_t hmacKeySize,
171     const uint8_t *pHash,
172     size_t pHash_size,
173     const TPM2B_NONCE *nonceNewer,
174     const TPM2B_NONCE *nonceOlder,
175     const TPM2B_NONCE *nonceDecrypt,
176     const TPM2B_NONCE *nonceEncrypt,
177     TPMA_SESSION sessionAttributes,
178     TPM2B_AUTH *hmac);
179 
180 TSS2_RC iesys_crypto_KDFaHmac(
181     ESYS_CRYPTO_CALLBACKS *crypto_cb,
182     TPM2_ALG_ID alg,
183     uint8_t *hmacKey,
184     size_t hmacKeySize,
185     uint32_t counter,
186     const char *label,
187     TPM2B_NONCE *contextU,
188     TPM2B_NONCE *contextV,
189     uint32_t bitlength,
190     uint8_t *hmac,
191     size_t *hmacSize);
192 
193 TSS2_RC iesys_crypto_KDFa(
194     ESYS_CRYPTO_CALLBACKS *crypto_cb,
195     TPM2_ALG_ID hashAlg,
196     uint8_t *hmacKey,
197     size_t hmacKeySize,
198     const char *label,
199     TPM2B_NONCE *contextU,
200     TPM2B_NONCE *contextV,
201     uint32_t bitLength,
202     uint32_t *counterInOut,
203     BYTE *outKey,
204     BOOL use_digest_size);
205 
206 TSS2_RC iesys_xor_parameter_obfuscation(
207     ESYS_CRYPTO_CALLBACKS *cryto_cb,
208     TPM2_ALG_ID hash_alg,
209     uint8_t *key,
210     size_t key_size,
211     TPM2B_NONCE * contextU,
212     TPM2B_NONCE * contextV,
213     BYTE *data,
214     size_t data_size);
215 
216 TSS2_RC iesys_crypto_KDFe(
217     ESYS_CRYPTO_CALLBACKS *crypto_cb,
218     TPM2_ALG_ID hashAlg,
219     TPM2B_ECC_PARAMETER *Z,
220     const char *label,
221     TPM2B_ECC_PARAMETER *partyUInfo,
222     TPM2B_ECC_PARAMETER *partyVInfo,
223     UINT32 bit_size,
224     BYTE *key);
225 
226 TSS2_RC iesys_initialize_crypto_backend(
227     ESYS_CRYPTO_CALLBACKS *crypto_cb,
228     ESYS_CRYPTO_CALLBACKS *user_cb);
229 
230 #ifdef __cplusplus
231 } /* extern "C" */
232 #endif
233 
234 #endif /* ESYS_CRYPTO_H */

esys_crypto_mbed.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright: 2020, Andreas Droescher
4  * All rights reserved.
5  ******************************************************************************/
6 
7 #ifndef ESYS_CRYPTO_MBED_H
8 #define ESYS_CRYPTO_MBED_H
9 
10 #include <stddef.h>
11 #include "tss2_tpm2_types.h"
12 #include "tss2-sys/sysapi_util.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 TSS2_RC iesys_cryptmbed_hash_start(
19     ESYS_CRYPTO_CONTEXT_BLOB **context,
20     TPM2_ALG_ID hashAlg,
21     void *userdata);
22 
23 TSS2_RC iesys_cryptmbed_hash_update(
24     ESYS_CRYPTO_CONTEXT_BLOB *context,
25     const uint8_t *buffer, size_t size,
26     void *userdata);
27 
28 TSS2_RC iesys_cryptmbed_hash_finish(
29     ESYS_CRYPTO_CONTEXT_BLOB **context,
30     uint8_t *buffer,
31     size_t *size,
32     void *userdata);
33 
34 void iesys_cryptmbed_hash_abort(
35     ESYS_CRYPTO_CONTEXT_BLOB **context,
36     void *userdata);
37 
38 #define _iesys_crypto_rsa_pk_encrypt iesys_cryptmbed_pk_encrypt
39 #define _iesys_crypto_hash_start iesys_cryptmbed_hash_start
40 #define _iesys_crypto_hash_update iesys_cryptmbed_hash_update
41 #define _iesys_crypto_hash_finish iesys_cryptmbed_hash_finish
42 #define _iesys_crypto_hash_abort iesys_cryptmbed_hash_abort
43 
44 TSS2_RC iesys_cryptmbed_hmac_start(
45     ESYS_CRYPTO_CONTEXT_BLOB **context,
46     TPM2_ALG_ID hmacAlg,
47     const uint8_t *key,
48     size_t size,
49     void *userdata);
50 
51 TSS2_RC iesys_cryptmbed_hmac_update(
52     ESYS_CRYPTO_CONTEXT_BLOB *context,
53     const uint8_t *buffer,
54     size_t size,
55     void *userdata);
56 
57 TSS2_RC iesys_cryptmbed_hmac_finish(
58     ESYS_CRYPTO_CONTEXT_BLOB **context,
59     uint8_t *buffer,
60     size_t *size,
61     void *userdata);
62 
63 void iesys_cryptmbed_hmac_abort(
64     ESYS_CRYPTO_CONTEXT_BLOB **context,
65     void *userdata);
66 
67 #define _iesys_crypto_hmac_start iesys_cryptmbed_hmac_start
68 #define _iesys_crypto_hmac_update iesys_cryptmbed_hmac_update
69 #define _iesys_crypto_hmac_finish iesys_cryptmbed_hmac_finish
70 #define _iesys_crypto_hmac_abort iesys_cryptmbed_hmac_abort
71 
72 TSS2_RC iesys_cryptmbed_random2b(
73     TPM2B_NONCE *nonce,
74     size_t num_bytes,
75     void *userdata);
76 
77 TSS2_RC iesys_cryptmbed_pk_encrypt(
78     TPM2B_PUBLIC *key,
79     size_t in_size,
80     BYTE *in_buffer,
81     size_t max_out_size,
82     BYTE *out_buffer,
83     size_t *out_size,
84     const char *label,
85     void *userdata);
86 
87 
88 TSS2_RC iesys_cryptmbed_sym_aes_encrypt(
89     uint8_t *key,
90     TPM2_ALG_ID tpm_sym_alg,
91     TPMI_AES_KEY_BITS key_bits,
92     TPM2_ALG_ID tpm_mode,
93     uint8_t *dst,
94     size_t dst_size,
95     uint8_t *iv,
96     void *userdata);
97 
98 TSS2_RC iesys_cryptmbed_sym_aes_decrypt(
99     uint8_t *key,
100     TPM2_ALG_ID tpm_sym_alg,
101     TPMI_AES_KEY_BITS key_bits,
102     TPM2_ALG_ID tpm_mode,
103     uint8_t *dst,
104     size_t dst_size,
105     uint8_t *iv,
106     void *userdata);
107 
108 TSS2_RC iesys_cryptmbed_get_ecdh_point(
109     TPM2B_PUBLIC *key,
110     size_t max_out_size,
111     TPM2B_ECC_PARAMETER *Z,
112     TPMS_ECC_POINT *Q,
113     BYTE * out_buffer,
114     size_t * out_size,
115     void *userdata);
116 
117 TSS2_RC iesys_cryptmbed_init(void *userdata);
118 
119 #define _iesys_crypto_get_random2b iesys_cryptmbed_random2b
120 #define _iesys_crypto_get_ecdh_point iesys_cryptmbed_get_ecdh_point
121 #define _iesys_crypto_aes_encrypt iesys_cryptmbed_sym_aes_encrypt
122 #define _iesys_crypto_aes_decrypt iesys_cryptmbed_sym_aes_decrypt
123 
124 #define _iesys_crypto_init iesys_cryptmbed_init
125 
126 #ifdef __cplusplus
127 } /* extern "C" */
128 #endif
129 
130 #endif /* ESYS_CRYPTO_MBED_H */

esys_crypto_ossl.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef ESYS_CRYPTO_OSSL_H
7 #define ESYS_CRYPTO_OSSL_H
8 
9 #include <stddef.h>
10 #include "tss2_tpm2_types.h"
11 #include "tss2-sys/sysapi_util.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #define OSSL_FREE(S,TYPE) if((S) != NULL) {TYPE##_free((void*) (S)); (S)=NULL;}
18 
19 TSS2_RC iesys_cryptossl_hash_start(
20     ESYS_CRYPTO_CONTEXT_BLOB **context,
21     TPM2_ALG_ID hashAlg,
22     void *userdata);
23 
24 TSS2_RC iesys_cryptossl_hash_update(
25     ESYS_CRYPTO_CONTEXT_BLOB *context,
26     const uint8_t *buffer, size_t size,
27     void *userdata);
28 
29 TSS2_RC iesys_cryptossl_hash_finish(
30     ESYS_CRYPTO_CONTEXT_BLOB **context,
31     uint8_t *buffer,
32     size_t *size,
33     void *userdata);
34 
35 void iesys_cryptossl_hash_abort(
36     ESYS_CRYPTO_CONTEXT_BLOB **context,
37     void *userdata);
38 
39 #define _iesys_crypto_rsa_pk_encrypt iesys_cryptossl_pk_encrypt
40 #define _iesys_crypto_hash_start iesys_cryptossl_hash_start
41 #define _iesys_crypto_hash_update iesys_cryptossl_hash_update
42 #define _iesys_crypto_hash_finish iesys_cryptossl_hash_finish
43 #define _iesys_crypto_hash_abort iesys_cryptossl_hash_abort
44 
45 TSS2_RC iesys_cryptossl_hmac_start(
46     ESYS_CRYPTO_CONTEXT_BLOB **context,
47     TPM2_ALG_ID hmacAlg,
48     const uint8_t *key,
49     size_t size,
50     void *userdata);
51 
52 TSS2_RC iesys_cryptossl_hmac_update(
53     ESYS_CRYPTO_CONTEXT_BLOB *context,
54     const uint8_t *buffer,
55     size_t size,
56     void *userdata);
57 
58 TSS2_RC iesys_cryptossl_hmac_finish(
59     ESYS_CRYPTO_CONTEXT_BLOB **context,
60     uint8_t *buffer,
61     size_t *size,
62     void *userdata);
63 
64 void iesys_cryptossl_hmac_abort(
65     ESYS_CRYPTO_CONTEXT_BLOB **context,
66     void *userdata);
67 
68 #define _iesys_crypto_hmac_start iesys_cryptossl_hmac_start
69 #define _iesys_crypto_hmac_start2b iesys_cryptossl_hmac_start2b
70 #define _iesys_crypto_hmac_update iesys_cryptossl_hmac_update
71 #define _iesys_crypto_hmac_update2b iesys_cryptossl_hmac_update2b
72 #define _iesys_crypto_hmac_finish iesys_cryptossl_hmac_finish
73 #define _iesys_crypto_hmac_finish2b iesys_cryptossl_hmac_finish2b
74 #define _iesys_crypto_hmac_abort iesys_cryptossl_hmac_abort
75 
76 TSS2_RC iesys_cryptossl_random2b(
77     TPM2B_NONCE *nonce,
78     size_t num_bytes,
79     void *userdata);
80 
81 TSS2_RC iesys_cryptossl_pk_encrypt(
82     TPM2B_PUBLIC *key,
83     size_t in_size,
84     BYTE *in_buffer,
85     size_t max_out_size,
86     BYTE *out_buffer,
87     size_t *out_size,
88     const char *label,
89     void *userdata);
90 
91 
92 TSS2_RC iesys_cryptossl_sym_aes_encrypt(
93     uint8_t *key,
94     TPM2_ALG_ID tpm_sym_alg,
95     TPMI_AES_KEY_BITS key_bits,
96     TPM2_ALG_ID tpm_mode,
97     uint8_t *dst,
98     size_t dst_size,
99     uint8_t *iv,
100     void *userdata);
101 
102 TSS2_RC iesys_cryptossl_sym_aes_decrypt(
103     uint8_t *key,
104     TPM2_ALG_ID tpm_sym_alg,
105     TPMI_AES_KEY_BITS key_bits,
106     TPM2_ALG_ID tpm_mode,
107     uint8_t *dst,
108     size_t dst_size,
109     uint8_t *iv,
110     void *userdata);
111 
112 TSS2_RC iesys_cryptossl_get_ecdh_point(
113     TPM2B_PUBLIC *key,
114     size_t max_out_size,
115     TPM2B_ECC_PARAMETER *Z,
116     TPMS_ECC_POINT *Q,
117     BYTE * out_buffer,
118     size_t * out_size,
119     void *userdata);
120 
121 #define _iesys_crypto_get_random2b iesys_cryptossl_random2b
122 #define _iesys_crypto_get_ecdh_point iesys_cryptossl_get_ecdh_point
123 #define _iesys_crypto_aes_encrypt iesys_cryptossl_sym_aes_encrypt
124 #define _iesys_crypto_aes_decrypt iesys_cryptossl_sym_aes_decrypt
125 
126 TSS2_RC iesys_cryptossl_init(void *userdata);
127 
128 #define _iesys_crypto_init iesys_cryptossl_init
129 
130 #ifdef __cplusplus
131 } /* extern "C" */
132 #endif
133 
134 #endif /* ESYS_CRYPTO_OSSL_H */

esys_int.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef ESYS_INT_H
7 #define ESYS_INT_H
8 
9 #include <stdint.h>
10 #include "esys_crypto.h"
11 #include "esys_types.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
22 typedef struct RSRC_NODE_T {
23     ESYS_TR esys_handle;        
25     TPM2B_AUTH auth;            
26     IESYS_RESOURCE rsrc;        
27     struct RSRC_NODE_T * next;  
28 } RSRC_NODE_T;
29 
30 typedef struct {
31     ESYS_TR tpmKey;
32     ESYS_TR bind;
33     TPM2_SE sessionType;
34     TPMI_ALG_HASH authHash;
35     TPM2B_NONCE *nonceCaller;
36     TPM2B_NONCE nonceCallerData;
37     TPMT_SYM_DEF *symmetric;
38     TPMT_SYM_DEF symmetricData;
39 } StartAuthSession_IN;
40 
41 typedef struct {
42     TPM2B_SENSITIVE_CREATE *inSensitive;
43     TPM2B_SENSITIVE_CREATE inSensitiveData;
44 } CreatePrimary_IN;
45 
46 typedef struct {
47     TPM2B_SENSITIVE_CREATE *inSensitive;
48     TPM2B_SENSITIVE_CREATE inSensitiveData;
49 } Create_IN;
50 
51 typedef struct {
52     ESYS_TR saveHandle;
53 } ContextSave_IN;
54 
55 typedef struct {
56     TPMS_CONTEXT *context;
57     TPMS_CONTEXT contextData;
58 } ContextLoad_IN;
59 
60 typedef struct {
61     TPM2B_PUBLIC *inPublic;
62     TPM2B_PUBLIC inPublicData;
63 } Load_IN;
64 
65 typedef struct {
66     TPM2B_PUBLIC *inPublic;
67     TPM2B_PUBLIC inPublicData;
68 } LoadExternal_IN;
69 
70 typedef struct {
71     TPM2B_SENSITIVE_CREATE *inSensitive;
72     TPM2B_SENSITIVE_CREATE inSensitiveData;
73     TPM2B_TEMPLATE *inPublic;
74     TPM2B_TEMPLATE inPublicData;
75 } CreateLoaded_IN;
76 
77 typedef struct {
78     ESYS_TR objectHandle;
79     TPMI_DH_PERSISTENT persistentHandle;
80 } EvictControl_IN;
81 
82 typedef struct {
83     TPM2B_AUTH authData;
84 } HMAC_Start_IN;
85 
86 typedef HMAC_Start_IN MAC_Start_IN;
87 
88 typedef struct {
89     ESYS_TR authHandle;
90     TPM2B_AUTH newAuth;
91 } HierarchyChangeAuth_IN;
92 
93 typedef struct {
94     ESYS_TR sequenceHandle;
95 } SequenceComplete_IN;
96 
97 typedef struct {
98     ESYS_TR policySession;
99 } Policy_IN;
100 
101 typedef struct {
102     ESYS_TR nvIndex;
103     TPM2B_AUTH authData;
104     TPM2B_NV_PUBLIC *publicInfo;
105     TPM2B_NV_PUBLIC publicInfoData;
106 } NV_IN;
107 
108 typedef struct {
109     ESYS_TR flushHandle;
110 } FlushContext_IN;
111 
112 typedef struct {
113     ESYS_TR pcrHandle;
114     TPM2B_AUTH authData;
115 } PCR_IN;
116 
122 typedef union {
123     StartAuthSession_IN StartAuthSession;
124     CreatePrimary_IN CreatePrimary;
125     Create_IN Create;
126     ContextSave_IN ContextSave;
127     ContextLoad_IN ContextLoad;
128     Load_IN Load;
129     LoadExternal_IN LoadExternal;
130     CreateLoaded_IN CreateLoaded;
131     EvictControl_IN EvictControl;
132     HMAC_Start_IN HMAC_Start;
133     MAC_Start_IN MAC_Start;
134     HierarchyChangeAuth_IN HierarchyChangeAuth;
135     SequenceComplete_IN SequenceComplete;
136     Policy_IN Policy;
137     NV_IN NV;
138     FlushContext_IN FlushContext;
139     PCR_IN PCR;
140 } IESYS_CMD_IN_PARAM;
141 
143 enum _ESYS_STATE {
144     _ESYS_STATE_INIT = 0,     
147     _ESYS_STATE_SENT,         
149     _ESYS_STATE_RESUBMISSION, 
151     _ESYS_STATE_INTERNALERROR 
153 };
154 
161 struct ESYS_CONTEXT {
162     enum _ESYS_STATE state;      
163     TSS2_SYS_CONTEXT *sys;       
165     ESYS_TR esys_handle_cnt;     
166     RSRC_NODE_T *rsrc_list;      
167     int32_t timeout;             
169     ESYS_TR session_type[3];     
171     RSRC_NODE_T *session_tab[3]; 
173     int encryptNonceIdx;         
174     TPM2B_NONCE *encryptNonce;   
176     int authsCount;              
178     int submissionCount;         
180     TPM2B_DATA salt;             
181     IESYS_CMD_IN_PARAM in;       
183     ESYS_TR esys_handle;         
185     TSS2_TCTI_CONTEXT *tcti_app_param;
188     void *dlhandle;              
190     IESYS_SESSION *enc_session;  
192     ESYS_TR sav_session1;        
195     ESYS_TR sav_session2;
196     ESYS_TR sav_session3;
197 
198     ESYS_CRYPTO_CALLBACKS crypto_backend; 
200 };
201 
207 #define _ESYS_MAX_SUBMISSIONS 5
208 
211 #define _ESYS_ASSERT_NON_NULL(x) \
212     if (x == NULL) { \
213         LOG_ERROR(str(x) " == NULL."); \
214         return TSS2_ESYS_RC_BAD_REFERENCE; \
215     }
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 #endif /* ESYS_INT_H */

esys_iutil.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef ESYS_IUTIL_H
7 #define ESYS_IUTIL_H
8 
9 #include <stdbool.h>
10 #include <inttypes.h>
11 #include <string.h>
12 #include "tss2_esys.h"
13 
14 #include "esys_int.h"
15 #include "esys_crypto.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /*
22  * Start issuing ESYS_TR objects past the TPM2_RH_LAST namespace
23  * and give ourselves 0x1000 handle space in case of differing
24  * header files between the library build and the client build.
25  *
26  * Due to an API mistake, TPM2_RH constants are valid for a few
27  * select ESYS API calls.
28  *
29  * More details can be found here:
30  *   - https://github.com/tpm2-software/tpm2-tss/issues/1750
31  */
32 #define ESYS_TR_MIN_OBJECT (TPM2_RH_LAST + 1 + 0x1000)
33 
35 typedef struct {
36     TPM2_ALG_ID alg;                 
37     size_t size;                     
38     uint8_t digest[sizeof(TPMU_HA)]; 
39 } HASH_TAB_ITEM;
40 
41 TSS2_RC init_session_tab(
42     ESYS_CONTEXT *esysContext,
43     ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3);
44 
45 void iesys_DeleteAllResourceObjects(
46     ESYS_CONTEXT *esys_context);
47 
48 TSS2_RC iesys_compute_encrypt_nonce(
49     ESYS_CONTEXT *esysContext,
50     int *encryptNonceIdx,
51     TPM2B_NONCE **encryptNonce);
52 
53 TSS2_RC iesys_compute_cp_hashtab(
54     ESYS_CONTEXT *esysContext,
55     const TPM2B_NAME *name1,
56     const TPM2B_NAME *name2,
57     const TPM2B_NAME *name3,
58     HASH_TAB_ITEM cp_hash_tab[3],
59     uint8_t *cpHashNum);
60 
61 TSS2_RC iesys_compute_rp_hashtab(
62     ESYS_CONTEXT *esysContext,
63     const uint8_t *rpBuffer,
64     size_t rpBuffer_size,
65     HASH_TAB_ITEM rp_hash_tab[3],
66     uint8_t *rpHashNum);
67 
68 TSS2_RC esys_CreateResourceObject(
69     ESYS_CONTEXT *esys_context,
70     ESYS_TR esys_handle,
71     RSRC_NODE_T **node);
72 
73 TSS2_RC iesys_handle_to_tpm_handle(
74     ESYS_TR esys_handle,
75     TPM2_HANDLE *tpm_handle);
76 
77 bool
78 iesys_is_platform_handle(
79         ESYS_TR handle);
80 
81 TSS2_RC esys_GetResourceObject(
82     ESYS_CONTEXT *esys_context,
83     ESYS_TR rsrc_handle,
84     RSRC_NODE_T **node);
85 
86 TPM2_HT iesys_get_handle_type(
87     TPM2_HANDLE handle);
88 
89 TSS2_RC iesys_finalize(ESYS_CONTEXT *context);
90 
91 bool iesys_compare_name(
92     ESYS_CRYPTO_CALLBACKS *crypto_cb,
93     TPM2B_PUBLIC *publicInfo,
94     TPM2B_NAME *name);
95 
96 TSS2_RC iesys_compute_encrypted_salt(
97     ESYS_CONTEXT *esysContext,
98     RSRC_NODE_T *tpmKeyNode,
99     TPM2B_ENCRYPTED_SECRET *encryptedSalt);
100 
101 TSS2_RC iesys_gen_caller_nonces(
102     ESYS_CONTEXT *esysContext);
103 
104 TSS2_RC iesys_encrypt_param(
105     ESYS_CONTEXT *esysContext,
106     TPM2B_NONCE **decryptNonce,
107     int *decryptNonceIdx);
108 
109 TSS2_RC iesys_decrypt_param(
110     ESYS_CONTEXT *esysContext);
111 
112 TSS2_RC iesys_check_rp_hmacs(
113     ESYS_CONTEXT *esysContext,
114     TSS2L_SYS_AUTH_RESPONSE *rspAuths,
115     HASH_TAB_ITEM rp_hash_tab[3],
116     uint8_t rpHashNum);
117 
118 void iesys_compute_bound_entity(
119     const TPM2B_NAME *name,
120     const TPM2B_AUTH *auth,
121     TPM2B_NAME *bound_entity);
122 
123 bool iesys_is_object_bound(
124     const TPM2B_NAME * name,
125     const TPM2B_AUTH * auth,
126     RSRC_NODE_T * session);
127 
128 TSS2_RC iesys_check_sequence_async(
129     ESYS_CONTEXT *esysContext);
130 
131 TSS2_RC check_session_feasibility(
132     ESYS_TR shandle1,
133     ESYS_TR shandle2,
134     ESYS_TR shandle3,
135     int mandatory);
136 
137 void iesys_compute_session_value(
138     RSRC_NODE_T *session,
139     const TPM2B_NAME *name,
140     const TPM2B_AUTH *auth_value);
141 
142 TSS2_RC iesys_compute_hmac(
143     ESYS_CONTEXT *esys_context,
144     RSRC_NODE_T *session,
145     HASH_TAB_ITEM cp_hash_tab[3],
146     uint8_t cpHashNum,
147     TPM2B_NONCE *decryptNonce,
148     TPM2B_NONCE *encryptNonce,
149     TPMS_AUTH_COMMAND *auth);
150 
151 TSS2_RC iesys_gen_auths(
152     ESYS_CONTEXT *esysContext,
153     RSRC_NODE_T *h1,
154     RSRC_NODE_T *h2,
155     RSRC_NODE_T *h3,
156     TSS2L_SYS_AUTH_COMMAND *auths);
157 
158 TSS2_RC iesys_check_response(
159     ESYS_CONTEXT * esys_context);
160 
161 TSS2_RC iesys_nv_get_name(
162     ESYS_CRYPTO_CALLBACKS *crypto_cb,
163     TPM2B_NV_PUBLIC *publicInfo,
164     TPM2B_NAME *name);
165 
166 TSS2_RC iesys_get_name(
167     ESYS_CRYPTO_CALLBACKS *crypto_cb,
168     TPM2B_PUBLIC *publicInfo,
169     TPM2B_NAME *name);
170 
171 bool iesys_tpm_error(
172     TSS2_RC r);
173 
174 TSS2_RC iesys_hash_long_auth_values(
175     ESYS_CRYPTO_CALLBACKS *crypto_cb,
176     TPM2B_AUTH *auth_value,
177     TPMI_ALG_HASH hash_alg);
178 
179 #ifdef __cplusplus
180 } /* extern "C" */
181 #endif
182 
183 #endif /* ESYS_IUTIL_H */

esys_mu.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef ESYS_MU_H
7 #define ESYS_MU_H
8 
9 #include "tss2_mu.h"
10 
11 #include "esys_types.h"
12 
13 #ifndef FALSE
14 #define FALSE 0
15 #endif
16 #ifndef TRUE
17 #define TRUE 1
18 #endif
19 #define ESYS_MAX_SIZE_METADATA 3072
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 TSS2_RC
26 iesys_MU_IESYSC_PARAM_ENCRYPT_Marshal(
27     const IESYSC_PARAM_ENCRYPT in,
28     uint8_t *buffer,
29     size_t size,
30     size_t *offset);
31 
32 TSS2_RC
33 iesys_MU_IESYSC_PARAM_ENCRYPT_Unmarshal(
34     const uint8_t *buffer,
35     size_t size,
36     size_t *offset,
37     IESYSC_PARAM_ENCRYPT *out);
38 
39 TSS2_RC
40 iesys_MU_IESYSC_PARAM_ENCRYPT_check(
41     const IESYSC_PARAM_ENCRYPT *in);
42 
43 TSS2_RC
44 iesys_MU_IESYSC_PARAM_DECRYPT_Marshal(
45     const IESYSC_PARAM_DECRYPT in,
46     uint8_t *buffer,
47     size_t size,
48     size_t *offset);
49 
50 TSS2_RC
51 iesys_MU_IESYSC_PARAM_DECRYPT_Unmarshal(
52     const uint8_t *buffer,
53     size_t size,
54     size_t *offset,
55     IESYSC_PARAM_DECRYPT *out);
56 
57 TSS2_RC
58 iesys_MU_IESYSC_PARAM_DECRYPT_check(
59     const IESYSC_PARAM_DECRYPT *in);
60 
61 TSS2_RC
62 iesys_MU_IESYSC_TYPE_POLICY_AUTH_Marshal(
63     const IESYSC_TYPE_POLICY_AUTH in,
64     uint8_t *buffer,
65     size_t size,
66     size_t *offset);
67 
68 TSS2_RC
69 iesys_MU_IESYSC_TYPE_POLICY_AUTH_Unmarshal(
70     const uint8_t *buffer,
71     size_t size,
72     size_t *offset,
73     IESYSC_TYPE_POLICY_AUTH *out);
74 
75 TSS2_RC
76 iesys_MU_IESYSC_TYPE_POLICY_AUTH_check(
77     const IESYSC_TYPE_POLICY_AUTH *in);
78 
79 TSS2_RC
80 iesys_MU_IESYS_SESSION_Marshal(
81     const IESYS_SESSION *in,
82     uint8_t *buffer,
83     size_t size,
84     size_t *offset);
85 
86 TSS2_RC
87 iesys_MU_IESYS_SESSION_Unmarshal(const uint8_t *buffer,
88     size_t size,
89     size_t *offset,
90     IESYS_SESSION *out);
91 
92 
93 TSS2_RC
94 iesys_MU_IESYSC_RESOURCE_TYPE_Marshal(
95     const IESYSC_RESOURCE_TYPE in,
96     uint8_t *buffer,
97     size_t size,
98     size_t *offset);
99 
100 TSS2_RC
101 iesys_MU_IESYSC_RESOURCE_TYPE_Unmarshal(
102     const uint8_t *buffer,
103     size_t size,
104     size_t *offset,
105     IESYSC_RESOURCE_TYPE *out);
106 
107 TSS2_RC
108 iesys_MU_IESYSC_RESOURCE_TYPE_check(
109     const IESYSC_RESOURCE_TYPE *in);
110 
111 TSS2_RC
112 iesys_MU_IESYS_RSRC_UNION_Marshal(
113     const IESYS_RSRC_UNION *in,
114     UINT32 selector,
115     uint8_t *buffer,
116     size_t size,
117     size_t *offset);
118 
119 TSS2_RC
120 iesys_MU_IESYS_RSRC_UNION_Unmarshal(
121     const uint8_t *buffer,
122     size_t size,
123     size_t *offset,
124     UINT32 selector,
125     IESYS_RSRC_UNION *out);
126 
127 
128 TSS2_RC
129 iesys_MU_IESYS_RESOURCE_Marshal(
130     const IESYS_RESOURCE *in,
131     uint8_t *buffer,
132     size_t size,
133     size_t *offset);
134 
135 TSS2_RC
136 iesys_MU_IESYS_RESOURCE_Unmarshal(const uint8_t *buffer,
137     size_t size,
138     size_t *offset,
139     IESYS_RESOURCE *out);
140 
141 
142 TSS2_RC
143 iesys_MU_IESYS_METADATA_Marshal(
144     const IESYS_METADATA *in,
145     uint8_t *buffer,
146     size_t size,
147     size_t *offset);
148 
149 TSS2_RC
150 iesys_MU_IESYS_METADATA_Unmarshal(const uint8_t *buffer,
151     size_t size,
152     size_t *offset,
153     IESYS_METADATA *out);
154 
155 
156 TSS2_RC
157 iesys_MU_IESYS_CONTEXT_DATA_Marshal(
158     const IESYS_CONTEXT_DATA *in,
159     uint8_t *buffer,
160     size_t size,
161     size_t *offset);
162 
163 TSS2_RC
164 iesys_MU_IESYS_CONTEXT_DATA_Unmarshal(const uint8_t *buffer,
165     size_t size,
166     size_t *offset,
167     IESYS_CONTEXT_DATA *out);
168 
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 #endif /* ESYS_MU_H */

esys_types.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 
7 #ifndef ESYS_TYPES_H
8 #define ESYS_TYPES_H
9 
10 #define ESYS_MAX_SIZE_METADATA 3072
11 
12 typedef UINT32 TSS2_ESYS_RC;
13 
14 
15 #ifndef TSS2_RC_SUCCESS
16 #define TSS2_RC_SUCCESS 0
17 #endif
18 
19 
22 typedef UINT32 IESYSC_RESOURCE_TYPE_CONSTANT;
23 #define IESYSC_KEY_RSRC                1    
24 #define IESYSC_NV_RSRC                 2    
25 #define IESYSC_SESSION_RSRC            3    
26 #define IESYSC_DEGRADED_SESSION_RSRC   4    
27 #define IESYSC_WITHOUT_MISC_RSRC       0    
31 typedef UINT32 IESYSC_PARAM_ENCRYPT;
32 #define ENCRYPT                        1    
33 #define NO_ENCRYPT                     0    
37 typedef UINT32 IESYSC_PARAM_DECRYPT;
38 #define DECRYPT                        1    
39 #define NO_DECRYPT                     0    
43 typedef UINT32 IESYSC_TYPE_POLICY_AUTH;
44 #define POLICY_PASSWORD                2    
45 #define POLICY_AUTH                    1    
46 #define NO_POLICY_AUTH                 0    
51 typedef struct {
52     TPM2B_NAME                             bound_entity;    
53     TPM2B_ENCRYPTED_SECRET                encryptedSalt;    
54     TPM2B_DATA                                     salt;    
55     TPMT_SYM_DEF                              symmetric;    
56     TPMI_ALG_HASH                              authHash;    
57     TPM2B_DIGEST                             sessionKey;    
58     TPM2_SE                                 sessionType;    
59     TPMA_SESSION                      sessionAttributes;    
60     TPMA_SESSION                  origSessionAttributes;    
61     TPM2B_NONCE                             nonceCaller;    
62     TPM2B_NONCE                                nonceTPM;    
63     IESYSC_PARAM_ENCRYPT                        encrypt;    
64     IESYSC_PARAM_DECRYPT                        decrypt;    
65     IESYSC_TYPE_POLICY_AUTH         type_policy_session;    
66     UINT16                             sizeSessionValue;    
67     BYTE                 sessionValue [2*sizeof(TPMU_HA)];    
68     UINT16                                sizeHmacValue;    
69 } IESYS_SESSION;
70 
73 typedef UINT32                  IESYSC_RESOURCE_TYPE;
74 
77 typedef union {
78     TPM2B_PUBLIC                           rsrc_key_pub;    
79     TPM2B_NV_PUBLIC                         rsrc_nv_pub;    
80     IESYS_SESSION                          rsrc_session;    
81     TPMS_EMPTY                               rsrc_empty;    
82 } IESYS_RSRC_UNION;
83 
86 typedef struct {
87     TPM2_HANDLE                                  handle;    
88     TPM2B_NAME                                     name;    
89     IESYSC_RESOURCE_TYPE                       rsrcType;    
90     IESYS_RSRC_UNION                               misc;    
91 } IESYS_RESOURCE;
92 
95 typedef struct {
96     UINT16                                         size;    
97     IESYS_RESOURCE                                 data;    
99 } IESYS_METADATA;
100 
103 typedef struct {
104     UINT32                                     reserved;    
105     TPM2B_CONTEXT_DATA                       tpmContext;    
106     IESYS_METADATA                         esysMetadata;    
107 } IESYS_CONTEXT_DATA;
108 
109 #endif /* ESYS_TYPES_H */

efi_event.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 #ifndef TCG_EFI_EVENT_H
3 #define TCG_EFI_EVENT_H 1
4 
5 #include <uuid/uuid.h>
6 #include <uchar.h>
7 
8 #include "tss2_tpm2_types.h"
9 
10 /*
11  * Log event types. These are spread out over 2 specs:
12  * "TCG EFI Protocol Specification For TPM Family 1.1 or 1.2" and
13  * "TCG PC Client Specific Implementation Specification for Conventional BIOS"
14  */
15 #define EV_PREBOOT_CERT            0x0
16 #define EV_POST_CODE               0x1
17 #define EV_UNUSED                  0x2
18 #define EV_NO_ACTION               0x3
19 #define EV_SEPARATOR               0x4
20 #define EV_ACTION                  0x5
21 #define EV_EVENT_TAG               0x6
22 #define EV_S_CRTM_CONTENTS         0x7
23 #define EV_S_CRTM_VERSION          0x8
24 #define EV_CPU_MICROCODE           0x9
25 #define EV_PLATFORM_CONFIG_FLAGS   0xa
26 #define EV_TABLE_OF_DEVICES        0xb
27 #define EV_COMPACT_HASH            0xc
28 #define EV_IPL                     0xd
29 #define EV_IPL_PARTITION_DATA      0xe
30 #define EV_NONHOST_CODE            0xf
31 #define EV_NONHOST_CONFIG          0x10
32 #define EV_NONHOST_INFO            0x11
33 #define EV_OMIT_BOOT_DEVICE_EVENTS 0x12
34 
35 /* TCG EFI Platform Specification For TPM Family 1.1 or 1.2 */
36 #define EV_EFI_EVENT_BASE                0x80000000
37 #define EV_EFI_VARIABLE_DRIVER_CONFIG    EV_EFI_EVENT_BASE + 0x1
38 #define EV_EFI_VARIABLE_BOOT             EV_EFI_EVENT_BASE + 0x2
39 #define EV_EFI_BOOT_SERVICES_APPLICATION EV_EFI_EVENT_BASE + 0x3
40 #define EV_EFI_BOOT_SERVICES_DRIVER      EV_EFI_EVENT_BASE + 0x4
41 #define EV_EFI_RUNTIME_SERVICES_DRIVER   EV_EFI_EVENT_BASE + 0x5
42 #define EV_EFI_GPT_EVENT                 EV_EFI_EVENT_BASE + 0x6
43 #define EV_EFI_ACTION                    EV_EFI_EVENT_BASE + 0x7
44 #define EV_EFI_PLATFORM_FIRMWARE_BLOB    EV_EFI_EVENT_BASE + 0x8
45 #define EV_EFI_HANDOFF_TABLES            EV_EFI_EVENT_BASE + 0x9
46 #define EV_EFI_HCRTM_EVENT               EV_EFI_EVENT_BASE + 0x10
47 #define EV_EFI_VARIABLE_AUTHORITY        EV_EFI_EVENT_BASE + 0xe0
48 
49 #ifndef PACKED
50 #define PACKED __attribute__((__packed__))
51 #endif
52 
53 typedef struct {
54   UINT16 AlgorithmId;
55   UINT8 Digest[];
56 } PACKED TCG_DIGEST2;
57 
58 typedef struct {
59   UINT32 EventSize;
60   UINT8 Event [];
61 } PACKED TCG_EVENT2;
62 
63 typedef struct {
64   UINT32 PCRIndex;
65   UINT32 EventType;
66   UINT32 DigestCount;
67   TCG_DIGEST2 Digests [];
68  /* TCG_EVENT2 comes next */
69 } PACKED TCG_EVENT_HEADER2;
70 
71 /* Helper structure for dealing with unaligned char16_t */
72 typedef struct {
73     char16_t c;
74 } PACKED UTF16_CHAR;
75 
76 typedef struct {
77   uuid_t VariableName;
78   UINT64 UnicodeNameLength;
79   UINT64 VariableDataLength;
80   char16_t UnicodeName[];
81   /* INT8 VariableData[] comes next */
82 } PACKED UEFI_VARIABLE_DATA;
83 
84 typedef UINT64 UEFI_PHYSICAL_ADDRESS;
85 typedef struct {
86     UEFI_PHYSICAL_ADDRESS BlobBase;
87     UINT64 BlobLength;
88 } PACKED UEFI_PLATFORM_FIRMWARE_BLOB;
89 
90 typedef struct {
91     UINT32 pcrIndex;
92     UINT32 eventType;
93     BYTE digest[20];
94     UINT32 eventDataSize;
95     BYTE event[];
96 } PACKED TCG_EVENT;
97 
98 typedef struct {
99     UINT16 algorithmId;
100     UINT16 digestSize;
101 } PACKED TCG_SPECID_ALG;
102 
103 typedef struct {
104     UINT8 vendorInfoSize;
105     BYTE vendorInfo[];
106 } PACKED TCG_VENDOR_INFO;
107 
108 typedef struct {
109     BYTE Signature[16];
110     UINT32 platformClass;
111     UINT8 specVersionMinor;
112     UINT8 specVersionMajor;
113     UINT8 specErrata;
114     UINT8 uintnSize;
115     UINT32 numberOfAlgorithms;
116     TCG_SPECID_ALG digestSizes[];
117     /* then TCG_VendorStuff */
118 } PACKED TCG_SPECID_EVENT;
119 
120 typedef struct {
121     UEFI_PHYSICAL_ADDRESS ImageLocationInMemory;
122     UINT64 ImageLengthInMemory;
123     UINT64 ImageLinkTimeAddress;
124     UINT64 LengthOfDevicePath;
125     BYTE DevicePath[];
126 } PACKED UEFI_IMAGE_LOAD_EVENT;
127 
128 #endif

fapi_certificates.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef FAPI_CERTIFICATES_H
7 #define FAPI_CERTIFICATES_H
8 
9 static char * root_cert_list[] = {
10     /* NTZ root certificate */
11     "-----BEGIN CERTIFICATE-----\n"
12     "MIICRDCCAcqgAwIBAgIBATAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJDTjEhMB8G\n"
13     "A1UECgwYTmF0aW9ueiBUZWNobm9sb2dpZXMgSW5jMRswGQYDVQQLDBJOYXRpb256\n"
14     "IFRQTSBEZXZpY2UxHDAaBgNVBAMME05hdGlvbnogVFBNIFJvb3QgQ0EwHhcNMTcw\n"
15     "NTEyMDAwMDAwWhcNNDcwNTEzMDAwMDAwWjBrMQswCQYDVQQGEwJDTjEhMB8GA1UE\n"
16     "CgwYTmF0aW9ueiBUZWNobm9sb2dpZXMgSW5jMRswGQYDVQQLDBJOYXRpb256IFRQ\n"
17     "TSBEZXZpY2UxHDAaBgNVBAMME05hdGlvbnogVFBNIFJvb3QgQ0EwdjAQBgcqhkjO\n"
18     "PQIBBgUrgQQAIgNiAATvuDTN8TNvp3A9fSjWpDARLmvz7ItQrDq/mmuzvzInwQfs\n"
19     "YKUUJza4MXB3yS0PH1jjv1YMvaIBIalAgc+kahScQUy6W2fy6hd36pazmc/vQfG3\n"
20     "Gdhw56gGwRHx4rn4TuqjQjBAMB0GA1UdDgQWBBQ6vP8I314BDCtkB4vHzpUG9Aj9\n"
21     "5DAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo\n"
22     "ADBlAjApzqSmd4cCMKC7slJ4NE/7zweXZx89JzSEnEWGcq78jbbXCw6yM+R4nCNX\n"
23     "phflI9QCMQCeFOAvyR+DQvThfGFINABej+1zeDVIjuZHat3FHVyV0UQVClPgMlZu\n"
24     "TntipXwGOVY=\n"
25     "-----END CERTIFICATE-----\n",
26 
27     /* IFX RSA root certificate */
28     "-----BEGIN CERTIFICATE-----\n"
29     "MIIFqzCCA5OgAwIBAgIBAzANBgkqhkiG9w0BAQsFADB3MQswCQYDVQQGEwJERTEh\n"
30     "MB8GA1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQLDBJPUFRJ\n"
31     "R0EoVE0pIERldmljZXMxKDAmBgNVBAMMH0luZmluZW9uIE9QVElHQShUTSkgUlNB\n"
32     "IFJvb3QgQ0EwHhcNMTMwNzI2MDAwMDAwWhcNNDMwNzI1MjM1OTU5WjB3MQswCQYD\n"
33     "VQQGEwJERTEhMB8GA1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYD\n"
34     "VQQLDBJPUFRJR0EoVE0pIERldmljZXMxKDAmBgNVBAMMH0luZmluZW9uIE9QVElH\n"
35     "QShUTSkgUlNBIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n"
36     "AQC7E+gc0B5T7awzux66zMMZMTtCkPqGv6a3NVx73ICg2DSwnipFwBiUl9soEodn\n"
37     "25SVVN7pqmvKA2gMTR5QexuYS9PPerfRZrBY00xyFx84V+mIRPg4YqUMLtZBcAwr\n"
38     "R3GO6cffHp20SBH5ITpuqKciwb0v5ueLdtZHYRPq1+jgy58IFY/vACyF/ccWZxUS\n"
39     "JRNSe4ruwBgI7NMWicxiiWQmz1fE3e0mUGQ1tu4M6MpZPxTZxWzN0mMz9noj1oIT\n"
40     "ZUnq/drN54LHzX45l+2b14f5FkvtcXxJ7OCkI7lmWIt8s5fE4HhixEgsR2RX5hzl\n"
41     "8XiHiS7uD3pQhBYSBN5IBbVWREex1IUat5eAOb9AXjnZ7ivxJKiY/BkOmrNgN8k2\n"
42     "7vOS4P81ix1GnXsjyHJ6mOtWRC9UHfvJcvM3U9tuU+3dRfib03NGxSPnKteL4SP1\n"
43     "bdHfiGjV3LIxzFHOfdjM2cvFJ6jXg5hwXCFSdsQm5e2BfT3dWDBSfR4h3Prpkl6d\n"
44     "cAyb3nNtMK3HR5yl6QBuJybw8afHT3KRbwvOHOCR0ZVJTszclEPcM3NQdwFlhqLS\n"
45     "ghIflaKSPv9yHTKeg2AB5q9JSG2nwSTrjDKRab225+zJ0yylH5NwxIBLaVHDyAEu\n"
46     "81af+wnm99oqgvJuDKSQGyLf6sCeuy81wQYO46yNa+xJwQIDAQABo0IwQDAdBgNV\n"
47     "HQ4EFgQU3LtWq/EY/KaadREQZYQSntVBkrkwDgYDVR0PAQH/BAQDAgAGMA8GA1Ud\n"
48     "EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggIBAGHTBUx3ETIXYJsaAgb2pyyN\n"
49     "UltVL2bKzGMVSsnTCrXUU8hKrDQh3jNIMrS0d6dU/fGaGJvehxmmJfjaN/IFWA4M\n"
50     "BdZEnpAe2fJEP8vbLa/QHVfsAVuotLD6QWAqeaC2txpxkerveoV2JAwj1jrprT4y\n"
51     "rkS8SxZuKS05rYdlG30GjOKTq81amQtGf2NlNiM0lBB/SKTt0Uv5TK0jIWbz2WoZ\n"
52     "gGut7mF0md1rHRauWRcoHQdxWSQTCTtgoQzeBj4IS6N3QxQBKV9LL9UWm+CMIT7Y\n"
53     "np8bSJ8oW4UdpSuYWe1ZwSjZyzDiSzpuc4gTS6aHfMmEfoVwC8HN03/HD6B1Lwo2\n"
54     "DvEaqAxkya9IYWrDqkMrEErJO6cqx/vfIcfY/8JYmUJGTmvVlaODJTwYwov/2rjr\n"
55     "la5gR+xrTM7dq8bZimSQTO8h6cdL6u+3c8mGriCQkNZIZEac/Gdn+KwydaOZIcnf\n"
56     "Rdp3SalxsSp6cWwJGE4wpYKB2ClM2QF3yNQoTGNwMlpsxnU72ihDi/RxyaRTz9OR\n"
57     "pubNq8Wuq7jQUs5U00ryrMCZog1cxLzyfZwwCYh6O2CmbvMoydHNy5CU3ygxaLWv\n"
58     "JpgZVHN103npVMR3mLNa3QE+5MFlBlP3Mmystu8iVAKJas39VO5y5jad4dRLkwtM\n"
59     "6sJa8iBpdRjZrBp5sJBI\n"
60     "-----END CERTIFICATE-----\n",
61 
62     /* IFX RSA root certificate 2 */
63     "-----BEGIN CERTIFICATE-----\n"
64     "MIIFsTCCA5mgAwIBAgIBWTANBgkqhkiG9w0BAQsFADB5MQswCQYDVQQGEwJERTEh\n"
65     "MB8GA1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQLDBJPUFRJ\n"
66     "R0EoVE0pIERldmljZXMxKjAoBgNVBAMMIUluZmluZW9uIE9QVElHQShUTSkgUlNB\n"
67     "IFJvb3QgQ0EgMjAgFw0xOTExMjIwMDAwMDBaGA8yMDU0MTEyMjIzNTk1OVoweTEL\n"
68     "MAkGA1UEBhMCREUxITAfBgNVBAoMGEluZmluZW9uIFRlY2hub2xvZ2llcyBBRzEb\n"
69     "MBkGA1UECwwST1BUSUdBKFRNKSBEZXZpY2VzMSowKAYDVQQDDCFJbmZpbmVvbiBP\n"
70     "UFRJR0EoVE0pIFJTQSBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n"
71     "ggIKAoICAQClvyAQlJNoJwAXwO5AojnaZO3rYqEbnox1r4jVvsjVnbDYSm9qYMIh\n"
72     "X0lEweLh3GmC/B0VgN0eoVTdfUZ/H9laK+PETmzQnKya8Gsq/XSCq8nWKslTgdoY\n"
73     "w44ddSBrTKoLWLPb8VW0FU0YIZaQEdXtWCQ2UqP+3Y6HbR8+RPO5DW64VsaGbeDx\n"
74     "VZgskZauH0oZ4eU7pCa9z6WwhExHMqgTOMHNuCgAWD/OkxqBsS74/2L4nv6zJD9+\n"
75     "yPLF3PjbVolC5WzR8M3ZUhN2iGp9V80/SEmj8SGS/z5l0cIwqua9DLhj/VCTo2Tl\n"
76     "qJ1hjQVaKYRnPaLPnxOmjbwPkCBO/Tj4jHVLfjk1XArSR3tjZK2CvRERweLC/XdK\n"
77     "doJuPPASeR8qmbhaj39wHBT5CTpJ8Hlh3uL1nMpeRJHJ0qM+7enirx/7WPuoI6FZ\n"
78     "N9xEWh7k6kma8wjjettN8r8qHBJjQN6IeJ8p2dETfRK+Wva718S2TKf3RyrD2aX3\n"
79     "RUGjFPxZcwDAX+YlqW7p03/77nf1SYnvyX7EyTZ99fRUjghVnM2tnTC4Soi6Sv1Z\n"
80     "oXxWFSOMUeRb3YN+OlWvqnVIJ1UNiTe5l1qCnEE+P+lj87sSjwSP63ME4xaNFmlT\n"
81     "v50t3+Gxpj92h8/owOpUBTD1uwLiZNDXhBE3qTtqO5T655ulTBsiZQIDAQABo0Iw\n"
82     "QDAdBgNVHQ4EFgQU+0/LDx9uXdViIvTFSiU55L1NaigwDgYDVR0PAQH/BAQDAgAG\n"
83     "MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggIBAFUkfuMp8AubFwcY\n"
84     "id4j4W5d3vTkSHxLWQ+ILgw8t3goF/Zp1ikDJMPVynEaVEIet5qjT5jZe56j0HkI\n"
85     "gyrOtjUxXXXvjSYEiUsoghp4ECM6EMj3nUmSqFkP8A9eGLtfpjTDFml0kPsBrK3e\n"
86     "o0+moWLvRsFRL9wVKKu2OTdA3aUG8hfNocvu/H7yqsLNg1DAwmhBajQl3PtICjPB\n"
87     "xUmhE1mxq998CVvdId7PqkTrBmUK8mNTNnLsDqFP2API//XxPWI9/LCib4StwM1w\n"
88     "v0ECNelb/bAw3FDx6HcJqkA8mRqfjg+cngOCPQXa3MWXbod5RM6DzQhwgAaofSlv\n"
89     "PzZGZvOu84FILJkSxj9ZpPVDy3bgTS2AE9Iy0C6y/1GyeHhDYFYdxg40osoCOBxu\n"
90     "1WwsEPr0FkYYXX2YSRa3MmrkkWzXrgx1JKzJB6p/mQ14j1R3eMiYWKx5DjtkAmM9\n"
91     "9qsnIU42jIpbwvQF1YC41GYclP2pX45LmDGTWgBDSBBtjEPnn2gwYH6uaSR3zndx\n"
92     "nqu/imr4HSyvrsIGNak5RLEed8e02nbjTAehOLAZGdj+TMnvbQBS0AiZZO3qWx9T\n"
93     "/ABQ8gFSGgorfvS5Lg7ANIiBSsCsVIa28I2eiYrJZatuFAo1Xg4z3n2kvL7S1wZy\n"
94     "8MZsUVujMk+IInhi81MQZFUR2QbA\n"
95     "-----END CERTIFICATE-----\n",
96 
97     /* IFX RSA root certificate 3 */
98     "-----BEGIN CERTIFICATE-----\n"
99     "MIIFsTCCA5mgAwIBAgIBbDANBgkqhkiG9w0BAQwFADB5MQswCQYDVQQGEwJERTEh\n"
100     "MB8GA1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQLDBJPUFRJ\n"
101     "R0EoVE0pIERldmljZXMxKjAoBgNVBAMMIUluZmluZW9uIE9QVElHQShUTSkgUlNB\n"
102     "IFJvb3QgQ0EgMzAgFw0yMTAzMTgwMDAwMDBaGA8yMDk5MTIzMTIzNTk1OVoweTEL\n"
103     "MAkGA1UEBhMCREUxITAfBgNVBAoMGEluZmluZW9uIFRlY2hub2xvZ2llcyBBRzEb\n"
104     "MBkGA1UECwwST1BUSUdBKFRNKSBEZXZpY2VzMSowKAYDVQQDDCFJbmZpbmVvbiBP\n"
105     "UFRJR0EoVE0pIFJTQSBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n"
106     "ggIKAoICAQC/+dr0NstkJ4CW9dZrln8mzPB/hG+5RoKZTJQrPRH2wdWxEN/T/wu1\n"
107     "0CEPOIxgXnDB+PaoUNpQ7AUI2SaVhT9/JRvy6XzQLY/ab40lvI1FvpXMyqdxj268\n"
108     "g6Zdt6zsVd4bLLEMucCoEQhZH3gZHQhJear1PNHF6iCcDqXhFvxSR9A8mat5vgGs\n"
109     "M1er0RwvYy3kAjdW+GDVHN4ezs4WINLem0M88HTr1HGXWnE9EPbLjHEXNOzRgEjs\n"
110     "Bv8TLbbJ0HXQAxpVWJH9XbtZjBGqdeJNnsIuOg3mFn8MUitavClVXg6LVOnmRjpx\n"
111     "LrdvEwmrTH0DtxduQ6pD4GaaNEIsgwZWu0pAAitmw2dRTI+OwTNj3hrjCsO+tkuV\n"
112     "01WaElAWccNyAPr3jDAFK13mrvgDzlBCCsBrNBUQVUGMZKNbDTkgFk7r4ZJPBcAj\n"
113     "TRQxKwwMUyMvXMp6pG2sP+V66JooYk7IPgvIE6fFQi+QfN7v8awgAWhSX88xFKse\n"
114     "aflZ4S1Dp/E+QsZF5p1R4RQio5IsaKjVstvAbd/GzTNNHk30YKOktLPr2qdtXJZD\n"
115     "3AKwoW2X9zb2VuBPX360HLf9rtX5XL3xQZvhIZbSA1Q9T4/VOIBewCRVKjWSTmha\n"
116     "x5dymh1xh+27w3UgbD6ivdbwQOm8FX8ntXElnUwy3Uwq6kSUBCKNPQIDAQABo0Iw\n"
117     "QDAdBgNVHQ4EFgQUYh5hb/65MYZudXjknzpeQ1LRTp8wDgYDVR0PAQH/BAQDAgAG\n"
118     "MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAGpa0nrH8mvlpBY1\n"
119     "W8Ths/Cz0Kd0d5lbo+ax8VwiUgHpOZ1hVu0udI4SDi2sYkIV6xEZqYjl0OV4YI/3\n"
120     "1tF6Fvbig5iqsgKF77WxIMSRoul2biI7qVp0tfic8L9lQt7VYpZjuEsxl9DPsbiK\n"
121     "N8nVcCUP6ffOqKNyzPi822bGdBQTlWTv+krFt98MB1ND6QL9L06TOSC6pXyvUalr\n"
122     "fNCDRdqE5S+h8O3bgib17iVWxX/Xr5vfZLr+o+1gMyBayurUKMwJggoIVc4nyb6n\n"
123     "vag2YeY0qlbnjai8etJ/KhKzpV9ahWNNxuh12baQ/wFNfovbmrV1JKX6FjaahHsE\n"
124     "WzTkLyDqZPg29rmD5ImWW6DERi2BPNcPxhFT5vL5iKHphFLU9NgF3uvdnLiiETLK\n"
125     "cs20D1jjz0kHKWxb3BDmbgVVgsAVvWt4KyvwKuzBT0goNaFafLIvm5w9sB4gJR5z\n"
126     "EW8lXVDnjdetk1MKZhy0Rt0kG0CBNIh1t1F8PHCMKik3V5zI+TZP7TfJn1Rzg+7F\n"
127     "dUMbkxmNOzCHBi7luR1eYO0nDSsLsQ/+Kth20RL1VZSETKaTP/GZhjl2OFJwwkmi\n"
128     "h3K7BFqxU5Uozd5ZIYU+OEPbKajjkIDe6sbSuwCyYaB56Mmc1CjzBdkTKBnyluil\n"
129     "aJMJqCHSQs0BoOVxi2dwZpQvHB6p\n"
130     "-----END CERTIFICATE-----\n",
131 
132     /* IFX ECC root certificate */
133     "-----BEGIN CERTIFICATE-----\n"
134     "MIICWzCCAeKgAwIBAgIBBDAKBggqhkjOPQQDAzB3MQswCQYDVQQGEwJERTEhMB8G\n"
135     "A1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQLDBJPUFRJR0Eo\n"
136     "VE0pIERldmljZXMxKDAmBgNVBAMMH0luZmluZW9uIE9QVElHQShUTSkgRUNDIFJv\n"
137     "b3QgQ0EwHhcNMTMwNzI2MDAwMDAwWhcNNDMwNzI1MjM1OTU5WjB3MQswCQYDVQQG\n"
138     "EwJERTEhMB8GA1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQL\n"
139     "DBJPUFRJR0EoVE0pIERldmljZXMxKDAmBgNVBAMMH0luZmluZW9uIE9QVElHQShU\n"
140     "TSkgRUNDIFJvb3QgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQm1HxLVgvAu1q2\n"
141     "GM+ymTz12zdTEu0JBVG9CdsVEJv/pE7pSWOlsG3YwU792YAvjSy7zL+WtDK40KGe\n"
142     "Om8bSWt46QJ00MQUkYxz6YqXbb14BBr06hWD6u6IMBupNkPd9pKjQjBAMB0GA1Ud\n"
143     "DgQWBBS0GIXISkrFEnryQDnexPWLHn5K0TAOBgNVHQ8BAf8EBAMCAAYwDwYDVR0T\n"
144     "AQH/BAUwAwEB/zAKBggqhkjOPQQDAwNnADBkAjA6QZcV8DjjbPuKjKDZQmTRywZk\n"
145     "MAn8wE6kuW3EouVvBt+/2O+szxMe4vxj8R6TDCYCMG7c9ov86ll/jDlJb/q0L4G+\n"
146     "+O3Bdel9P5+cOgzIGANkOPEzBQM3VfJegfnriT/kaA==\n"
147     "-----END CERTIFICATE-----\n",
148 
149     /* IFX ECC root certificate 2 */
150     "-----BEGIN CERTIFICATE-----\n"
151     "MIICrTCCAg6gAwIBAgIBWjAKBggqhkjOPQQDBDB5MQswCQYDVQQGEwJERTEhMB8G\n"
152     "A1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQLDBJPUFRJR0Eo\n"
153     "VE0pIERldmljZXMxKjAoBgNVBAMMIUluZmluZW9uIE9QVElHQShUTSkgRUNDIFJv\n"
154     "b3QgQ0EgMjAgFw0xOTExMjIwMDAwMDBaGA8yMDU0MTEyMjIzNTk1OVoweTELMAkG\n"
155     "A1UEBhMCREUxITAfBgNVBAoMGEluZmluZW9uIFRlY2hub2xvZ2llcyBBRzEbMBkG\n"
156     "A1UECwwST1BUSUdBKFRNKSBEZXZpY2VzMSowKAYDVQQDDCFJbmZpbmVvbiBPUFRJ\n"
157     "R0EoVE0pIEVDQyBSb290IENBIDIwgZswEAYHKoZIzj0CAQYFK4EEACMDgYYABABD\n"
158     "6MnFaakBVM/vveSWg55BTIdxWdxAzGf2+fEUo5b9hMF6kVSWaR0wAAm2p9qeXNAV\n"
159     "j7tfQkhz1CxvNz4TauSBQQGf94WLcIKyh7d6zC6/AIloqPizTIGb5xl4ogqyz6ZC\n"
160     "T/D5FiOPA98TYzoThdqM8cpcI74e2xOyNgAffsm/BRiuFKNCMEAwHQYDVR0OBBYE\n"
161     "FIK4PcxxuD5+9pzWHchNUjJwbMedMA4GA1UdDwEB/wQEAwIABjAPBgNVHRMBAf8E\n"
162     "BTADAQH/MAoGCCqGSM49BAMEA4GMADCBiAJCAOXJYwRt86BtRKSuiN5LNATNX6Nc\n"
163     "hs4DUiggpQhbgggV3Lf+T39l71KvCIPb8n5ZjSi5AKflmPGzumCjqDAPsgmsAkIA\n"
164     "vpqNqptg4Sf3hrdAsLAqNPZGnx8gRBnsTvvQzNUOZETuBp+nbmSrKMWZpd5G7HkM\n"
165     "9uXFb5ctX1cZQUbYFA2qG5g=\n"
166     "-----END CERTIFICATE-----\n",
167 
168     /* IFX ECC root certificate 3 */
169     "-----BEGIN CERTIFICATE-----\n"
170     "MIICrTCCAg6gAwIBAgIBazAKBggqhkjOPQQDBDB5MQswCQYDVQQGEwJERTEhMB8G\n"
171     "A1UECgwYSW5maW5lb24gVGVjaG5vbG9naWVzIEFHMRswGQYDVQQLDBJPUFRJR0Eo\n"
172     "VE0pIERldmljZXMxKjAoBgNVBAMMIUluZmluZW9uIE9QVElHQShUTSkgRUNDIFJv\n"
173     "b3QgQ0EgMzAgFw0yMTAzMTgwMDAwMDBaGA8yMDk5MTIzMTIzNTk1OVoweTELMAkG\n"
174     "A1UEBhMCREUxITAfBgNVBAoMGEluZmluZW9uIFRlY2hub2xvZ2llcyBBRzEbMBkG\n"
175     "A1UECwwST1BUSUdBKFRNKSBEZXZpY2VzMSowKAYDVQQDDCFJbmZpbmVvbiBPUFRJ\n"
176     "R0EoVE0pIEVDQyBSb290IENBIDMwgZswEAYHKoZIzj0CAQYFK4EEACMDgYYABAFV\n"
177     "nmck8P1bISsq2lHszhrjnxOfxvzCCRFgyNw943gjql2PWGbmoXUn/qZ9D/Hy47i/\n"
178     "hwjr4uGyds/j2Lsbjq3eewDoogmD3EPWk2ta8pCHk5RoTr5e4Hiy9jhAenmzTri4\n"
179     "QiXnKmtlZYmQqEiLv1vYTLeHb/kDeUqLnx1el1eapVMZa6NCMEAwHQYDVR0OBBYE\n"
180     "FCwq8GA70CKIkoWj6c41h3JyQiz1MA4GA1UdDwEB/wQEAwIABjAPBgNVHRMBAf8E\n"
181     "BTADAQH/MAoGCCqGSM49BAMEA4GMADCBiAJCAYBYO5HXrgzE8z5oqTxoPk2KTa+i\n"
182     "cIZufqCemx6Yj091qqApCIatVLUGPGdQlLYbVGlSkmt2Bm4oFOMF2hUvQ6PqAkIB\n"
183     "sCwnSqqWfpFgA9xXPqTEwWsmxedt7H4t8/l5NwjICsEXA/doLoR5t+DtV7hQkXUW\n"
184     "anb6Z0IT1aEi+kQeohpkAlY=\n"
185     "-----END CERTIFICATE-----\n",
186 
187     /* Intel root certificate */
188     "-----BEGIN CERTIFICATE-----\n"
189     "MIICdzCCAh6gAwIBAgIUB+dPf7a3IyJGO923z34oQLRP7pwwCgYIKoZIzj0EAwIw\n"
190     "gYcxCzAJBgNVBAYMAlVTMQswCQYDVQQIDAJDQTEUMBIGA1UEBwwLU2FudGEgQ2xh\n"
191     "cmExGjAYBgNVBAoMEUludGVsIENvcnBvcmF0aW9uMSEwHwYDVQQLDBhUUE0gRUsg\n"
192     "cm9vdCBjZXJ0IHNpZ25pbmcxFjAUBgNVBAMMDXd3dy5pbnRlbC5jb20wHhcNMTQw\n"
193     "MTE1MDAwMDAwWhcNNDkxMjMxMjM1OTU5WjCBhzELMAkGA1UEBgwCVVMxCzAJBgNV\n"
194     "BAgMAkNBMRQwEgYDVQQHDAtTYW50YSBDbGFyYTEaMBgGA1UECgwRSW50ZWwgQ29y\n"
195     "cG9yYXRpb24xITAfBgNVBAsMGFRQTSBFSyByb290IGNlcnQgc2lnbmluZzEWMBQG\n"
196     "A1UEAwwNd3d3LmludGVsLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJR9\n"
197     "gVEsjUrMb+E/dl19ywJsKZDnghmwVyG16dAfQ0Pftp1bjhtPEGEguvbLGRRopKWH\n"
198     "VscAOlTFnvCHq+6/9/SjZjBkMB8GA1UdIwQYMBaAFOhSBcJP2NLVpSFHFrbODHtb\n"
199     "uncPMB0GA1UdDgQWBBToUgXCT9jS1aUhRxa2zgx7W7p3DzASBgNVHRMBAf8ECDAG\n"
200     "AQH/AgEBMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAgNHADBEAiAldFScWQ6L\n"
201     "PQgW/YT+2GILcATEA2TgzASaCrG+AzL6FgIgLH8ABRzm028hRYR/JZVGkHiomzYX\n"
202     "VILmTjHwSL7uZBU=\n"
203     "-----END CERTIFICATE-----",
204 
205     /* GlobalSign TPM RSA Root CA */
206     "-----BEGIN CERTIFICATE-----\n"
207     "MIID1zCCAr+gAwIBAgILBAAAAAABIBkJGa4wDQYJKoZIhvcNAQELBQAwgYcxOzA5\n"
208     "BgNVBAsTMkdsb2JhbFNpZ24gVHJ1c3RlZCBDb21wdXRpbmcgQ2VydGlmaWNhdGUg\n"
209     "QXV0aG9yaXR5MRMwEQYDVQQKEwpHbG9iYWxTaWduMTMwMQYDVQQDEypHbG9iYWxT\n"
210     "aWduIFRydXN0ZWQgUGxhdGZvcm0gTW9kdWxlIFJvb3QgQ0EwHhcNMDkwMzE4MTAw\n"
211     "MDAwWhcNNDkwMzE4MTAwMDAwWjCBhzE7MDkGA1UECxMyR2xvYmFsU2lnbiBUcnVz\n"
212     "dGVkIENvbXB1dGluZyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxEzARBgNVBAoTCkds\n"
213     "b2JhbFNpZ24xMzAxBgNVBAMTKkdsb2JhbFNpZ24gVHJ1c3RlZCBQbGF0Zm9ybSBN\n"
214     "b2R1bGUgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPi3\n"
215     "Gi0wHyTT7dq24caFAp31gXFDvALRGJrMiP+TunIYPacYD8eBVSNEiVoCUcVfYxzl\n"
216     "/DPTxmRyGXgQM8CVh9THrxDTW7N2PSAoZ7fvlmjTiBL/IQ7m1F+9wGI/FuaMTphz\n"
217     "w6lBda7HFlIYKTbM/vz24axCHLzJ8Xir2L889D9MMIerBRqouVsDGauH+TIOdw4o\n"
218     "IGKhorqfsDro57JHwViMWlbB1Ogad7PBX5X/e9GDNdZTdo4c0bZnKO+dEtzEgKCh\n"
219     "JmQ53Mxa9y4xPMGRRnjLsyxuM99vkkYXy7rnxctSo7GtGIJJVabNuXZ0peaY9ku0\n"
220     "CUgKAsQndLkTHz8bIh0CAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB\n"
221     "/wQFMAMBAf8wHQYDVR0OBBYEFB4jY/CFtfYlTu0awFC+ZXzH1BV6MA0GCSqGSIb3\n"
222     "DQEBCwUAA4IBAQCVb7lI4d49u7EtCX03/rUCCiaZ64NMxxqRmcSVdUx6yRrbl8NN\n"
223     "FNr6ym2kTvwe1+JkTCiDxKzJsOR/jcPczAFiYpFbZQYLA6RK0bzbL9RGcaw5LLhY\n"
224     "o/flqsu3N2/HNesWbekoxLosP6NLGEOnpj1B+R3y7HCQq/08U5l3Ete6TRKTAavc\n"
225     "0mty+uCFtLXf+tirl7xSaIGD0LwcYNdzLEB9g4je6FQSWL0QOXb+zR755QYupZAw\n"
226     "G1PnOgYWfqWowKcQQexFPrKGlzh0ncITV/nBEi++fnnZ7TFiwaKwe+WussrROV1S\n"
227     "DDF29dmoMcbSFDL+DgSMabVT6Qr6Ze1rbmSh\n"
228     "-----END CERTIFICATE-----",
229 
230     /* STM RSA root certificate (signed by GlobalSign TPM Root CA) */
231     "-----BEGIN CERTIFICATE-----\n"
232     "MIIEDDCCAvSgAwIBAgILBAAAAAABIsFs834wDQYJKoZIhvcNAQELBQAwgYcxOzA5\n"
233     "BgNVBAsTMkdsb2JhbFNpZ24gVHJ1c3RlZCBDb21wdXRpbmcgQ2VydGlmaWNhdGUg\n"
234     "QXV0aG9yaXR5MRMwEQYDVQQKEwpHbG9iYWxTaWduMTMwMQYDVQQDEypHbG9iYWxT\n"
235     "aWduIFRydXN0ZWQgUGxhdGZvcm0gTW9kdWxlIFJvb3QgQ0EwHhcNMDkwNzI4MTIw\n"
236     "MDAwWhcNMzkxMjMxMjM1OTU5WjBKMQswCQYDVQQGEwJDSDEeMBwGA1UEChMVU1RN\n"
237     "aWNyb2VsZWN0cm9uaWNzIE5WMRswGQYDVQQDExJTVE0gVFBNIEVLIFJvb3QgQ0Ew\n"
238     "ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDxBLG5wcB9J0MsiJMreoWQ\n"
239     "l21bBN12SSGZPJ3HoPjzcrzAz6SPy+TrFmZ6eUVspsFL/23wdPprqTUtDHi+C2pw\n"
240     "k/3dF3/Rb2t/yHgiPlbCshYpi5f/rJ7nzbQ1ca2LzX3saBe53VfNQQV0zd5uM0DT\n"
241     "SrmAKU1RIAj2WlZFWXoN4NWTyRtqT5suPHa2y8FlCWMZKlS0FiY4pfM20b5YQ+EL\n"
242     "4zqb9zN53u/TdYZegrfSlc30Nl9G13Mgi+8rtPFKwsxx05EBbhVroH7aKVI1djsf\n"
243     "E1MVrUzw62PHik3xlzznXML8OjY//xKeiCWcsApuGCaIAf7TsTRi2l8DNB3rCr1X\n"
244     "AgMBAAGjgbQwgbEwDgYDVR0PAQH/BAQDAgIEMBIGA1UdEwEB/wQIMAYBAf8CAQEw\n"
245     "HQYDVR0OBBYEFG/mxWwHt2yLCoGSg1zLQR72jtEnMEsGA1UdIAREMEIwQAYJKwYB\n"
246     "BAGgMgFaMDMwMQYIKwYBBQUHAgEWJWh0dHA6Ly93d3cuZ2xvYmFsc2lnbi5uZXQv\n"
247     "cmVwb3NpdG9yeS8wHwYDVR0jBBgwFoAUHiNj8IW19iVO7RrAUL5lfMfUFXowDQYJ\n"
248     "KoZIhvcNAQELBQADggEBAFrKpwFmRh7BGdpPZWc1Y6wIbdTAF6T+q1KwDJcyAjgJ\n"
249     "qThFp3xTAt3tvyVrCRf7T/YARYE24DNa0iFaXsIXeQASDYHJjAZ6LQTslYBeRYLb\n"
250     "C9v8ZE2ocKSCiC8ALYlJWk39Wob0H1Lk6l2zcUo3oKczGiAcRrlmwV496wvGyted\n"
251     "2RBcLZro7yhOOGr9KMabV14fNl0lG+31J1nWI2hgTqh53GXg1QH2YpggD3b7UbVm\n"
252     "c6GZaX37N3z15XfQafuAfHt10kYCNdePzC9tOwirHIsO8lrxoNlzOSxX8SqQGbBI\n"
253     "+kWoe5+SY3gdOGGDQKIdw3W1poMN8bQ5x7XFcgVMwVU=\n"
254     "-----END CERTIFICATE-----\n",
255 
256     /* GlobalSign TPM ECC Root CA */
257     "-----BEGIN CERTIFICATE-----\n"
258     "MIICszCCAjqgAwIBAgIORdycjBUV21nQRkudeekwCgYIKoZIzj0EAwMwgYsxOzA5\n"
259     "BgNVBAsTMkdsb2JhbFNpZ24gVHJ1c3RlZCBDb21wdXRpbmcgQ2VydGlmaWNhdGUg\n"
260     "QXV0aG9yaXR5MRMwEQYDVQQKEwpHbG9iYWxTaWduMTcwNQYDVQQDEy5HbG9iYWxT\n"
261     "aWduIFRydXN0ZWQgUGxhdGZvcm0gTW9kdWxlIEVDQyBSb290IENBMB4XDTE0MTEy\n"
262     "NjAwMDAwMFoXDTM4MDExOTAzMTQwN1owgYsxOzA5BgNVBAsTMkdsb2JhbFNpZ24g\n"
263     "VHJ1c3RlZCBDb21wdXRpbmcgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MRMwEQYDVQQK\n"
264     "EwpHbG9iYWxTaWduMTcwNQYDVQQDEy5HbG9iYWxTaWduIFRydXN0ZWQgUGxhdGZv\n"
265     "cm0gTW9kdWxlIEVDQyBSb290IENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAENTps\n"
266     "86FDUD+bep3kd1U5pnita316zBktOVNWxZQ+Ymua0oaR66ItzHrl19zYSGbW6ar0\n"
267     "1V91kktxWDJ6UFl3MyH3yXKsCHS2O5vxMlfmdRp8tpebMorHtIWf9u1+ctNFo2Mw\n"
268     "YTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUYT78\n"
269     "EZkKf7CpW5CgJl4pYUe3MAMwHwYDVR0jBBgwFoAUYT78EZkKf7CpW5CgJl4pYUe3\n"
270     "MAMwCgYIKoZIzj0EAwMDZwAwZAIwd02iAb5aN/pQGWdTJ7/lgMhFCuOLGtQ+ocdV\n"
271     "/xmoxdIWLtggAuq9fFDfsu/vzeJ7AjAGhdk03AjHpLl0dAp7aCI8D8qupwyYTBaL\n"
272     "rSJCZDMHhvNhETbbLu8uEPKt/U6/mGM=\n"
273     "-----END CERTIFICATE-----",
274 
275     /* STM ECC root certificate (signed by GlobalSign TPM ECC Root CA)*/
276     "-----BEGIN CERTIFICATE-----\n"
277     "MIICyDCCAk+gAwIBAgIORyzLp/OdsAvb9r+66LowCgYIKoZIzj0EAwMwgYsxOzA5\n"
278     "BgNVBAsTMkdsb2JhbFNpZ24gVHJ1c3RlZCBDb21wdXRpbmcgQ2VydGlmaWNhdGUg\n"
279     "QXV0aG9yaXR5MRMwEQYDVQQKEwpHbG9iYWxTaWduMTcwNQYDVQQDEy5HbG9iYWxT\n"
280     "aWduIFRydXN0ZWQgUGxhdGZvcm0gTW9kdWxlIEVDQyBSb290IENBMB4XDTE1MTAy\n"
281     "ODAwMDAwMFoXDTM4MDExOTAzMTQwN1owTjELMAkGA1UEBhMCQ0gxHjAcBgNVBAoT\n"
282     "FVNUTWljcm9lbGVjdHJvbmljcyBOVjEfMB0GA1UEAxMWU1RNIFRQTSBFQ0MgUm9v\n"
283     "dCBDQSAwMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABG7/OLXMiprQQHwNnkpT6aqG\n"
284     "zOGLcbbAgUtyjlXOZtuv0GB0ttJ6fwMwgFtt8RKlko8Bwn89/BoZOUcI4ne8ddRS\n"
285     "oqE6StnU3I13qqjalToq3Rnz61Omn6NErK1pxUe3j6OBtTCBsjAOBgNVHQ8BAf8E\n"
286     "BAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBATAdBgNVHQ4EFgQUIJJWPAtDqAVyUwMp\n"
287     "BxwH4OvsAwQwHwYDVR0jBBgwFoAUYT78EZkKf7CpW5CgJl4pYUe3MAMwTAYDVR0g\n"
288     "BEUwQzBBBgkrBgEEAaAyAVowNDAyBggrBgEFBQcCARYmaHR0cHM6Ly93d3cuZ2xv\n"
289     "YmFsc2lnbi5jb20vcmVwb3NpdG9yeS8wCgYIKoZIzj0EAwMDZwAwZAIwWnuUAzwy\n"
290     "vHUhHehymKTZ2QcPUwHX0LdcVTac4ohyEL3zcuv/dM0BN62kFxHgBOhWAjAIxt9i\n"
291     "50yAxy0Z/MeV2NTXqKpLwdhWNuzOSFZnzRKsh9MxY3zj8nebDNlHTDGSMR0=\n"
292     "-----END CERTIFICATE-----",
293 
294     /* NTC_TPM_EK_Root_CA_01 */
295     "-----BEGIN CERTIFICATE-----\n"
296     "MIIDSjCCAjKgAwIBAgIGAK3jXfbVMA0GCSqGSIb3DQEBBQUAMFIxUDAcBgNVBAMT\n"
297     "FU5UQyBUUE0gRUsgUm9vdCBDQSAwMTAlBgNVBAoTHk51dm90b24gVGVjaG5vbG9n\n"
298     "eSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTEyMDcxMTE2MjkzMFoXDTMyMDcx\n"
299     "MTE2MjkzMFowUjFQMBwGA1UEAxMVTlRDIFRQTSBFSyBSb290IENBIDAxMCUGA1UE\n"
300     "ChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwggEi\n"
301     "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDoNqxhtD4yUtXhqKQGGZemoKJy\n"
302     "uj1RnWvmNgzItLeejNU8B6fOnpMQyoS4K72tMhhFRK2jV9RYzyJMSjEwyX0ASTO1\n"
303     "2yMti2UJQS60d36eGwk8WLgrFnnITlemshi01h9t1MOmay3TO1LLH/3/VDKJ+jbd\n"
304     "cbfIO2bBquN8r3/ojYUaNSPj6pK1mmsMoJXF4dGRSEwb/4ozBIw5dugm1MEq4Zj3\n"
305     "GZ0YPg5wyLRugQbt7DkUOX4FGuK5p/C0u5zX8u33EGTrDrRz3ye3zO+aAY1xXF/m\n"
306     "qwEqgxX5M8f0/DXTTO/CfeIksuPeOzujFtXfi5Cy64eeIZ0nAUG3jbtnGjoFAgMB\n"
307     "AAGjJjAkMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMA0GCSqG\n"
308     "SIb3DQEBBQUAA4IBAQBBQznOPJAsD4Yvyt/hXtVJSgBX/+rRfoaqbdt3UMbUPJYi\n"
309     "pUoTUgaTx02DVRwommO+hLx7CS++1F2zorWC8qQyvNbg7iffQbbjWitt8NPE6kCr\n"
310     "q0Y5g7M/LkQDd5N3cFfC15uFJOtlj+A2DGzir8dlXU/0qNq9dBFbi+y+Y3rAT+wK\n"
311     "fktmN82UT861wTUzDvnXO+v7H5DYXjUU8kejPW6q+GgsccIbVTOdHNNWbMrcD9yf\n"
312     "oS91nMZ/+/n7IfFWXNN82qERsrvOFCDsbIzUOR30N0IP++oqGfwAbKFfCOCFUz6j\n"
313     "jpXUdJlh22tp12UMsreibmi5bsWYBgybwSbRgvzE\n"
314     "-----END CERTIFICATE-----\n",
315 
316     /* NTC_TPM_EK_Root_CA_02 */
317     "-----BEGIN CERTIFICATE-----\n"
318     "MIIDSjCCAjKgAwIBAgIGAPadBmPZMA0GCSqGSIb3DQEBBQUAMFIxUDAcBgNVBAMT\n"
319     "FU5UQyBUUE0gRUsgUm9vdCBDQSAwMjAlBgNVBAoTHk51dm90b24gVGVjaG5vbG9n\n"
320     "eSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTEyMDcxMTE2MzMyNFoXDTMyMDcx\n"
321     "MTE2MzMyNFowUjFQMBwGA1UEAxMVTlRDIFRQTSBFSyBSb290IENBIDAyMCUGA1UE\n"
322     "ChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwggEi\n"
323     "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSagWxaANT1YA2YUSN7sq7yzOT\n"
324     "1ymbIM+WijhE5AGcLwLFoJ9fmaQrYL6fAW2EW/Q3yu97Q9Ysr8yYZ2XCCfxfseEr\n"
325     "Vs80an8Nk6LkTDz8+0Hm0Cct0klvNUAZEIvWpmgHZMvGijXyOcp4z494d8B28Ynb\n"
326     "I7x0JMXZZQQKQi+WfuHtntF+2osYScweocipPrGeONLKU9sngWZ2vnnvw1SBneTa\n"
327     "irxq0Q0SD6Bx9jtxvdf87euk8JzfPhX8jp8GEeAjmLwGR+tnOQrDmczGNmp7YYNN\n"
328     "R+Q7NZVoYWHw5jaoZnNxbouWUXZZxFqDsB/ndCKWtsIzRYPuWcqrFcmUN4SVAgMB\n"
329     "AAGjJjAkMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMA0GCSqG\n"
330     "SIb3DQEBBQUAA4IBAQAIkdDSErzPLPYrVthw4lKjW4tRYelUicMPEHKjQeVUAAS5\n"
331     "y9XTzB4DWISDAFsgtQjqHJj0xCG+vpY0Rmn2FCO/0YpP+YBQkdbJOsiyXCdFy9e4\n"
332     "gGjQ24gw1B+rr84+pkI51y952NYBdoQDeb7diPe+24U94f//DYt/JQ8cJua4alr3\n"
333     "2Pohhh5TxCXXfU2EHt67KyqBSxCSy9m4OkCOGLHL2X5nQIdXVj178mw6DSAwyhwR\n"
334     "n3uJo5MvUEoQTFZJKGSXfab619mIgzEr+YHsIQToqf44VfDMDdM+MFiXQ3a5fLii\n"
335     "hEKQ9DhBPtpHAbhFA4jhCiG9HA8FdEplJ+M4uxNz\n"
336     "-----END CERTIFICATE-----\n",
337 
338     /* NTC_TPM_EK_Root_CA_ARSUF_01 */
339     "-----BEGIN CERTIFICATE-----\n"
340     "MIIDWTCCAkGgAwIBAgIJAMklAEG4bgQ6MA0GCSqGSIb3DQEBBQUAMFgxVjAiBgNV\n"
341     "BAMTG05UQyBUUE0gRUsgUm9vdCBDQSBBUlNVRiAwMTAlBgNVBAoTHk51dm90b24g\n"
342     "VGVjaG5vbG9neSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTE0MDQwMTE4MzQz\n"
343     "OFoXDTM0MDMyODE4MzQzOFowWDFWMCIGA1UEAxMbTlRDIFRQTSBFSyBSb290IENB\n"
344     "IEFSU1VGIDAxMCUGA1UEChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9u\n"
345     "MAkGA1UEBhMCVFcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDCxcfP\n"
346     "yaNsGhaR28qqisqkrb4Z2OPul7BRNlIEYP8jSFORygyfp4j7bKRyVTTONCUbPq+J\n"
347     "/a4yRcdbEs8dzvzXypQbVUjuC4sOKjPiWLfOhj1Z1yvOn19Xe3Ei4UzMKJm+xpb1\n"
348     "BYR4YfrnuVzL4do/B/lCr2AYs4Fmtn1uzXBp1St8TRJz9HTW1yKJ2ZOqTgW3DX80\n"
349     "6DP//3kIatTuLCZ6Zsdl6fsgMPxJGwrI35ThKBtaUMT93abb/KB/dugvoIgtEi9D\n"
350     "GEC2C0UWsvJEfu0Qi8zoxtYvd9Y2tRlMxMhK75uShXHxRcG+WOGEnm6uVpGphLKg\n"
351     "qxAl1tuFcb94vi7dAgMBAAGjJjAkMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8E\n"
352     "CDAGAQH/AgEAMA0GCSqGSIb3DQEBBQUAA4IBAQB7epeKy2Sa+9huMzK4PnIpjiaX\n"
353     "QrxPx+E8BVGw6VuQqTcTPQRvPhNpc4VF/6/7MA9qb6vDxWEf40tqNi8e/RPNlRFY\n"
354     "Dh4tQ1Hhl69NrZVYZeXl1cU/ometoAAbz79ugq78iFndJ5rHMQ85GRwtW9i/q0p1\n"
355     "VjJ8dLYJ7aRBDTP3hndc35GmZg3q1UX93WD6mM5KuE+mOdv7MXKMtYSrV+dE/iGM\n"
356     "ASrratJf57P6N8BpegPQaSb6UnElwBpwhRxzW7N9qgjQWIqrxe97CfJk41RvtnKu\n"
357     "SePqlm1PtWkygt9bYaInLZYkcknXTD/7BtzAyyS25HtG/YTvuMtKItCp7Z4n\n"
358     "-----END CERTIFICATE-----\n",
359 
360     /* Nuvoton TPM Root CA 1013 */
361     "-----BEGIN CERTIFICATE-----\n"
362     "MIIDkjCCAnqgAwIBAgIISN0JfIK6vE0wDQYJKoZIhvcNAQEFBQAwVTFTMB8GA1UE\n"
363     "AxMYTnV2b3RvbiBUUE0gUm9vdCBDQSAxMDEzMCUGA1UEChMeTnV2b3RvbiBUZWNo\n"
364     "bm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwHhcNMTUwNTExMDg0MzI1WhcN\n"
365     "MzUwNTA3MDg0MzI1WjBVMVMwHwYDVQQDExhOdXZvdG9uIFRQTSBSb290IENBIDEw\n"
366     "MTMwJQYDVQQKEx5OdXZvdG9uIFRlY2hub2xvZ3kgQ29ycG9yYXRpb24wCQYDVQQG\n"
367     "EwJUVzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALDAta6EZBlhF1MC\n"
368     "Z9GeMXqw8puwZEDI3qR/rwGhEUj2oqhFY/K9zUk2YQCkC6X5lrr/lbWfvZtUGMFC\n"
369     "P4VQlt+bGPTOladGg6zJ/7a6yCd9MqkZbw92niDNhWcXsiB7SRyHYdr/He8tNOoD\n"
370     "mVdNFXxknP8QH3soBPahxckqtrhhk+24Iran04jOAc0959VnP8H0Jyg4BjehIQjj\n"
371     "BGGK+bJWZXHYRFlDj4dRW+epChdOqTpWOulf5GOvwNm3sv4ojU2fJ8cA5TznX81z\n"
372     "+Se6hmw/RF8rUGjf1uiKbsxnbIf3An01mZYgD98FXEHAWAW92vAJUuEQJVBlTest\n"
373     "1YmsaT0CAwEAAaNmMGQwDgYDVR0PAQH/BAQDAgIEMBIGA1UdEwEB/wQIMAYBAf8C\n"
374     "AQAwHwYDVR0jBBgwFoAUoNc3KQ4WzyrivucQDPVrLwTF8EMwHQYDVR0OBBYEFKDX\n"
375     "NykOFs8q4r7nEAz1ay8ExfBDMA0GCSqGSIb3DQEBBQUAA4IBAQCOXMzQYz3vr9tg\n"
376     "SiFr6qha2+Jay+EK0iLjSKvNzcTv5yaO8I6pb7tdocvze8394PtM42d2OTOM99lJ\n"
377     "bZogquaJ6fLHMwzO7UEGndtm6YMp6APXk4ecRqUDLqofIWL6PQUVwSEYlAC6RM9k\n"
378     "n4MJqckIxsc6iC38lsjyn4ut8o/E3fIo8UzYDl2P+KK1VkjDcmmgNf6seHmBsOYC\n"
379     "vOc4xYpq0yWuZFfxeyC4wC4mOAKLZX2yLMYrYBmnDd60nc0hgI1/TKb1H/Ew2P7R\n"
380     "UxEDMGe8e3A9YR4M/09FLn8cTTjq7hflRlcqiarpPo6+9Z3dqzmqTQxvVQ/DIVqE\n"
381     "3r3WOnnr\n"
382     "-----END CERTIFICATE-----\n",
383 
384     /* Nuvoton TPM Root CA 1014 */
385     "-----BEGIN CERTIFICATE-----\n"
386     "MIIDkjCCAnqgAwIBAgIIbXSeZ/22esUwDQYJKoZIhvcNAQEFBQAwVTFTMB8GA1UE\n"
387     "AxMYTnV2b3RvbiBUUE0gUm9vdCBDQSAxMDE0MCUGA1UEChMeTnV2b3RvbiBUZWNo\n"
388     "bm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwHhcNMTcwODIxMTEwMzM2WhcN\n"
389     "MzcwODE3MTEwMzM2WjBVMVMwHwYDVQQDExhOdXZvdG9uIFRQTSBSb290IENBIDEw\n"
390     "MTQwJQYDVQQKEx5OdXZvdG9uIFRlY2hub2xvZ3kgQ29ycG9yYXRpb24wCQYDVQQG\n"
391     "EwJUVzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMd3U7eh2gF2h7LE\n"
392     "b6GZTP/TtWq3cK8QMFuGI6PrwXjwGm1JfG6vF+1u/z4tJbc8znK8Kc/XTZ1yqoZW\n"
393     "sz7dXP20eltU0fuB7qwa2yJOqbl6hZ6nAD+eOuteSUQ8AnEuFH2XqqN++pj9DJXS\n"
394     "zDpvHqP1J6PnpNi6gxVas6PBFrRZuYGOxJwG2miyObHK1/kKrkuE7/yh+ju1j0Rw\n"
395     "9DXhvmEelrztPOkm4TkLxkTQSL7jj+EWimpmGP8Wo+B/2FdVpJZdoFUa2v5GldK8\n"
396     "VBdkacDaSqQ0iX1tP2oI93Jyx1xu9JDqjThrtu+FFIlHFJLw2N91fSCmsJukUiCI\n"
397     "9PPakQUCAwEAAaNmMGQwDgYDVR0PAQH/BAQDAgIEMBIGA1UdEwEB/wQIMAYBAf8C\n"
398     "AQAwHwYDVR0jBBgwFoAUqdlH8/mBcu623MXtYJoA3nwGnLAwHQYDVR0OBBYEFKnZ\n"
399     "R/P5gXLuttzF7WCaAN58BpywMA0GCSqGSIb3DQEBBQUAA4IBAQBCVMox72wTII5D\n"
400     "fjznST8qr61I6ctKouW401l/x5EA2gBctsx5gl3tuq9EArM2TuA9F+leyJ8r/Tdu\n"
401     "do8TgM4iCVl+FthXlrkPVemd1le63v0Emaxd/8Vca9ZZbrLlC6WNiUj/nGyYThPK\n"
402     "3XIHQN0+OoNdXQM5IxUYylgiA3udzcLCS0oL8uWhpa5YX2ad2UB3xKiz3maI7sXF\n"
403     "Dk5ds45MimR0p/dd+4y2tnAB1f/neR9/CqE58GQcFDY10mpNUa3rBqcUnHcJCfvb\n"
404     "i5TX/clYY/wsVDPwjA5u3k7KSOip7FR33EfIPubE/nMeVqDTiZt+RBJ81xskBO0+\n"
405     "x7bKAs+x\n"
406     "-----END CERTIFICATE-----\n",
407 
408     /* Nuvoton TPM Root CA 1110 */
409     "-----BEGIN CERTIFICATE-----\n"
410     "MIICBjCCAaygAwIBAgIIEDiqn2SaqGMwCgYIKoZIzj0EAwIwVTFTMB8GA1UEAxMY\n"
411     "TnV2b3RvbiBUUE0gUm9vdCBDQSAxMTEwMCUGA1UEChMeTnV2b3RvbiBUZWNobm9s\n"
412     "b2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwHhcNMTUwNTExMDg0MzMzWhcNMzUw\n"
413     "NTA3MDg0MzMzWjBVMVMwHwYDVQQDExhOdXZvdG9uIFRQTSBSb290IENBIDExMTAw\n"
414     "JQYDVQQKEx5OdXZvdG9uIFRlY2hub2xvZ3kgQ29ycG9yYXRpb24wCQYDVQQGEwJU\n"
415     "VzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDVkEOpuyhuviaDH6xQj3faaV2Z4\n"
416     "FvXSdwUkTiB1JjPDgv1PU0SFYtEE1W9VmI1GcOn5FAUi2/QM36DPhmPTd+qjZjBk\n"
417     "MA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBQV\n"
418     "kdS26vmNAQSGS2kDpI3QAmB30zAfBgNVHSMEGDAWgBQVkdS26vmNAQSGS2kDpI3Q\n"
419     "AmB30zAKBggqhkjOPQQDAgNIADBFAiEAlfxysfHDcxYDed5dmRbvHPKHLEEq9Y9P\n"
420     "wAxoKqH7Q5kCIGfsxiLr2j9nJ9jELwXz0/VWN9PhUNdM3qmsx2JEne6p\n"
421     "-----END CERTIFICATE-----\n",
422 
423     /* Nuvoton TPM Root CA 1111 */
424     "-----BEGIN CERTIFICATE-----\n"
425     "MIICBzCCAa2gAwIBAgIJAN/u3L0l8osZMAoGCCqGSM49BAMCMFUxUzAfBgNVBAMT\n"
426     "GE51dm90b24gVFBNIFJvb3QgQ0EgMTExMTAlBgNVBAoTHk51dm90b24gVGVjaG5v\n"
427     "bG9neSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTE3MDgyMTAzMzI1M1oXDTM3\n"
428     "MDgxNzAzMzI1M1owVTFTMB8GA1UEAxMYTnV2b3RvbiBUUE0gUm9vdCBDQSAxMTEx\n"
429     "MCUGA1UEChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMC\n"
430     "VFcwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATRcgnHcQk99FFMQ+9UVVFzf64J\n"
431     "1jnhxpGAdZEHRleZfkfTYGHsdr3L9FLdGVUb+BA2cim30ovuPDZOGOUKPraLo2Yw\n"
432     "ZDAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQU\n"
433     "iC8Ee4cSHPmIXzEWC8e7VYavRxswHwYDVR0jBBgwFoAUiC8Ee4cSHPmIXzEWC8e7\n"
434     "VYavRxswCgYIKoZIzj0EAwIDSAAwRQIhANrKhBfLXyHCznBRtWRBmTbfYJR9mCl1\n"
435     "2N/xZkcohRZIAiBDufnmhZWCbX4pibbzAOgcxjsc5+qmpAovxW9ipWJEsA==\n"
436     "-----END CERTIFICATE-----\n",
437 
438     /* Nuvoton TPM Root CA 2010 */
439     "-----BEGIN CERTIFICATE-----\n"
440     "MIIDkjCCAnqgAwIBAgIIWAnP9p2CIZcwDQYJKoZIhvcNAQEFBQAwVTFTMB8GA1UE\n"
441     "AxMYTnV2b3RvbiBUUE0gUm9vdCBDQSAyMDEwMCUGA1UEChMeTnV2b3RvbiBUZWNo\n"
442     "bm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwHhcNMTUwNDIzMDY1OTE5WhcN\n"
443     "MzUwNDE5MDY1OTE5WjBVMVMwHwYDVQQDExhOdXZvdG9uIFRQTSBSb290IENBIDIw\n"
444     "MTAwJQYDVQQKEx5OdXZvdG9uIFRlY2hub2xvZ3kgQ29ycG9yYXRpb24wCQYDVQQG\n"
445     "EwJUVzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKcE9saVURE582ny\n"
446     "dHsZO7+3xmdMFbOPCdplBda/EJg9cg7n6bZ79Qv7hyymN5qE23SOPNFvm8SAdmCJ\n"
447     "ybmTnk1y+SyiDw5gUpckbXsRYAetTwqtdfBkF4TkFoRJDIraQC8miTdYqXMXfWTo\n"
448     "bhHXf/oV953laOCO/SRlqXzAWzm5d8PwixUBLZTnvcgxM+pXwv6JY6wgXpv55fY1\n"
449     "D3M1hyiNALib+rg0LwazalU0DOryAAIqFzMgkR2IaefkAmpmQ1xpfMJsK+BMixcI\n"
450     "XUCzSGGKKdkc3WUDye/vsyXYQ5zoYuLt3xb7BEZxes31lqbs1gniNz4oD5ptmrS4\n"
451     "8V7Rz/kCAwEAAaNmMGQwDgYDVR0PAQH/BAQDAgIEMBIGA1UdEwEB/wQIMAYBAf8C\n"
452     "AQAwHwYDVR0jBBgwFoAUCDAPQ6j0uMjmJKT3Bgz1nnRQFecwHQYDVR0OBBYEFAgw\n"
453     "D0Oo9LjI5iSk9wYM9Z50UBXnMA0GCSqGSIb3DQEBBQUAA4IBAQAE0pMnjz5o3QUd\n"
454     "S3lLQn3+vXkS2xc1EmPxcVFxjPbrJDtnNRMWwglC8zo70VgWu/+ulwzy783zJSiT\n"
455     "nkWPeuszqp3xOtCPWDE4D2sxVbWH3pvel2tgZJv0KJsJH93QE53WbHUwSn2JjHNH\n"
456     "UJiBpq0genUxGD+zBI3NGDGB1iti66aJfCdjn8C0G0gTmQ8jFpZ6AsX1GSvPYeU6\n"
457     "EqN9ynIEYUVcRKwoHQaSmqDd7HVp97fwD+mkOfFYByLVUqC09rNFW81Va4Ze2gw2\n"
458     "HiKz/SVSA5mA/91wfEZSZ6azOgDZNQlbgBo27mZFJ5mR7iJbWgtD+vO4+wRZK8Bc\n"
459     "8yWxV8ri\n"
460     "-----END CERTIFICATE-----\n",
461 
462     /* Nuvoton TPM Root CA 2011 */
463     "-----BEGIN CERTIFICATE-----\n"
464     "MIIDkjCCAnqgAwIBAgIIGCgneR7Ow/EwDQYJKoZIhvcNAQEFBQAwVTFTMB8GA1UE\n"
465     "AxMYTnV2b3RvbiBUUE0gUm9vdCBDQSAyMDExMCUGA1UEChMeTnV2b3RvbiBUZWNo\n"
466     "bm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwHhcNMTcwOTExMDcxMDEyWhcN\n"
467     "MzcwOTA3MDcxMDEyWjBVMVMwHwYDVQQDExhOdXZvdG9uIFRQTSBSb290IENBIDIw\n"
468     "MTEwJQYDVQQKEx5OdXZvdG9uIFRlY2hub2xvZ3kgQ29ycG9yYXRpb24wCQYDVQQG\n"
469     "EwJUVzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAfy7Iu3eTXYdXe\n"
470     "WWc8ZPHb1ekofnHWY4Y6QD+z256j2rXTGmk5bA1Y6nCsYtBqUV4B2gfPAaZXunMD\n"
471     "k3KDEBaI8Fkd7BTXbWHrfgxZstGHlWzVqi1r2Jj31MdDMz0NRovWXJwgG5N9tgs5\n"
472     "KEeQ0Kk2ock1Vdn/jIqx3xY9vBMZm97N11m/WtZ5U2NyxbfqIIloIhxuvoPZRzx8\n"
473     "c6MmI77MtM2ylm+2nbXf1DtbEKXQYuGnvM3Ib9K5f2+PTjNi/nWGAcCgLo89BNSB\n"
474     "LdG9GxK1hO9QXYcCkAWsEWUD+8DM1v+zAl2cnrtj4iu48sU5i6hVO0CTtCP0yOkf\n"
475     "VdVfNVsCAwEAAaNmMGQwDgYDVR0PAQH/BAQDAgIEMBIGA1UdEwEB/wQIMAYBAf8C\n"
476     "AQAwHwYDVR0jBBgwFoAUpSy2R+CQm9ouf32RP2LYixOJ4sYwHQYDVR0OBBYEFKUs\n"
477     "tkfgkJvaLn99kT9i2IsTieLGMA0GCSqGSIb3DQEBBQUAA4IBAQAUwrhniUs4CLgb\n"
478     "UIFPslx3aly8M2P8Vn0GR+EcE0GklFa26WOT+YZxacUP3rMGteZGCtbFggYcM94n\n"
479     "pog7FBnnDR1ySHbHOY0kWBO75ePVBmytqpPeZX8E5202sRgagnojl59bPj1tqhlH\n"
480     "vwj6Xj6/XAFZDo0Or2GhCC5NzRbXmc6wB0zIjTlhPwVXQ+ikKBqdt3/HKCB4i3Sv\n"
481     "7Dxyy/N4aPg/s6MJxgmUjtGxRyjU6RVgrzqVN/0Csv8L75g2SvzgXnqrqcpk82XT\n"
482     "CnJgflpaCfV2SC5MGWHEjmj1tghC133JcEMQlsodWRm+0x7E/fsHvJNj4A0nh9K3\n"
483     "H3TryFJ7\n"
484     "-----END CERTIFICATE-----\n",
485 
486     /* Nuvoton TPM Root CA 2110 */
487     "-----BEGIN CERTIFICATE-----\n"
488     "MIICBjCCAaygAwIBAgIIP5MvnZk8FrswCgYIKoZIzj0EAwIwVTFTMB8GA1UEAxMY\n"
489     "TnV2b3RvbiBUUE0gUm9vdCBDQSAyMTEwMCUGA1UEChMeTnV2b3RvbiBUZWNobm9s\n"
490     "b2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwHhcNMTUxMDE5MDQzMjAwWhcNMzUx\n"
491     "MDE1MDQzMjAwWjBVMVMwHwYDVQQDExhOdXZvdG9uIFRQTSBSb290IENBIDIxMTAw\n"
492     "JQYDVQQKEx5OdXZvdG9uIFRlY2hub2xvZ3kgQ29ycG9yYXRpb24wCQYDVQQGEwJU\n"
493     "VzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABPv9uK2BNm8/nmIyNsc2/aKHV0WR\n"
494     "ptzge3jKAIgUMosQIokl4LE3iopXWD3Hruxjf9vkLMDJrTeK3hWh2ySS4ySjZjBk\n"
495     "MA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBSf\n"
496     "u3mqD1JieL7RUJKacXHpajW+9zAfBgNVHSMEGDAWgBSfu3mqD1JieL7RUJKacXHp\n"
497     "ajW+9zAKBggqhkjOPQQDAgNIADBFAiEA/jiywhOKpiMOUnTfDmXsXfDFokhKVNTX\n"
498     "B6Xtqm7J8L4CICjT3/Y+rrSnf8zrBXqWeHDh8Wi41+w2ppq6Ev9orZFI\n"
499     "-----END CERTIFICATE-----\n",
500 
501     /* Nuvoton TPM Root CA 2111 */
502     "-----BEGIN CERTIFICATE-----\n"
503     "MIICBzCCAa2gAwIBAgIJAOCIUWvKMfuGMAoGCCqGSM49BAMCMFUxUzAfBgNVBAMT\n"
504     "GE51dm90b24gVFBNIFJvb3QgQ0EgMjExMTAlBgNVBAoTHk51dm90b24gVGVjaG5v\n"
505     "bG9neSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTE3MDkxMTA3MDk0OVoXDTM3\n"
506     "MDkwNzA3MDk0OVowVTFTMB8GA1UEAxMYTnV2b3RvbiBUUE0gUm9vdCBDQSAyMTEx\n"
507     "MCUGA1UEChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMC\n"
508     "VFcwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATanNywPkE/RICBZ4VjwCymLDts\n"
509     "B7Unv52Oj0HyEsAfc7+vjOl2DP8JbrcozY05s7GFfQqR3vhv4ZdkJMalgOr2o2Yw\n"
510     "ZDAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQU\n"
511     "I/TiKtO+N0pEl3KVSqKDrtdSVy4wHwYDVR0jBBgwFoAUI/TiKtO+N0pEl3KVSqKD\n"
512     "rtdSVy4wCgYIKoZIzj0EAwIDSAAwRQIgXgXs2eVt2U4sCoRf1GLoUTf2ZzYTSsyg\n"
513     "6I5w6hPTLigCIQDLLFlXK1xw1a1D1/idVhdd3a8gkE0FnTJO890WwiQbpg==\n"
514     "-----END CERTIFICATE-----"
515 };
516 
517 #endif /* FAPI_CERTIFICATES_H */

fapi_crypto.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef FAPI_CRYPTO_H
7 #define FAPI_CRYPTO_H
8 
9 #include "fapi_int.h"
10 
11 TSS2_RC
12 ifapi_get_profile_sig_scheme(
13     const IFAPI_PROFILE     *profile,
14     const TPMT_PUBLIC           *tpmPublic,
15     TPMT_SIG_SCHEME             *signatureScheme);
16 
17 TSS2_RC
18 ifapi_der_sig_to_tpm(
19     const TPMT_PUBLIC           *tpmPublic,
20     const unsigned char         *signature,
21     size_t                      signatureSize,
22     TPMI_ALG_HASH               hashAlgorithm,
23     TPMT_SIGNATURE              *tpmSignature);
24 
25 TSS2_RC
26 ifapi_tpm_ecc_sig_to_der(
27     const TPMT_SIGNATURE        *tpmSignature,
28     uint8_t                     **signature,
29     size_t                      *signatureSize);
30 
31 TSS2_RC
32 ifapi_pub_pem_key_from_tpm(
33     const TPM2B_PUBLIC          *tpmPublicKey,
34     char                        **pemKey,
35     int                         *pemKeySize);
36 
37 TSS2_RC
38 ifapi_verify_signature(
39     const IFAPI_OBJECT          *keyObject,
40     const uint8_t               *signature,
41     size_t                      signatureSize,
42     const uint8_t               *digest,
43     size_t                      digestSize);
44 
45 TSS2_RC
46 ifapi_verify_signature_quote(
47     const IFAPI_OBJECT          *keyObject,
48     const uint8_t               *signature,
49     size_t                      signatureSize,
50     const uint8_t               *digest,
51     size_t                      digestSize,
52     const TPMT_SIG_SCHEME       *signatureScheme);
53 
54 
55 typedef struct _IFAPI_CRYPTO_CONTEXT IFAPI_CRYPTO_CONTEXT_BLOB;
56 
57 TSS2_RC
58 ifapi_crypto_hash_start(
59     IFAPI_CRYPTO_CONTEXT_BLOB   **context,
60     TPM2_ALG_ID                 hashAlgorithm);
61 
62 TSS2_RC
63 ifapi_crypto_hash_update(
64     IFAPI_CRYPTO_CONTEXT_BLOB   *context,
65     const uint8_t               *buffer,
66     size_t                      size);
67 
68 TSS2_RC
69 ifapi_crypto_hash_finish(
70     IFAPI_CRYPTO_CONTEXT_BLOB   **context,
71     uint8_t                     *digest,
72     size_t                      *digestSize);
73 
74 void
75 ifapi_crypto_hash_abort(
76     IFAPI_CRYPTO_CONTEXT_BLOB   **context);
77 
78 TSS2_RC
79 ifapi_cert_to_pem(
80     const uint8_t               *certBuffer,
81     size_t                      certBufferSize,
82     char                        **pemCert,
83     TPM2_ALG_ID                 *certAlgorithmId,
84     TPM2B_PUBLIC                *tpmPublic);
85 
86 size_t
87 ifapi_hash_get_digest_size(
88     TPM2_ALG_ID                 hashAlgorithm);
89 
90 TSS2_RC
91 ifapi_get_tpm2b_public_from_pem(
92     const char                  *pemKey,
93     TPM2B_PUBLIC                *tpmPublic);
94 
95 TSS2_RC
96 ifapi_get_hash_alg_for_size(
97     uint16_t                    size,
98     TPMI_ALG_HASH               *hashAlgorithm);
99 
100 TSS2_RC
101 ifapi_get_public_from_pem_cert(
102     const char*                 pem_cert,
103     TPM2B_PUBLIC *tpm_public);
104 
105 TSS2_RC
106 ifapi_initialize_sign_public(
107     TPM2_ALG_ID                 signatureAlgorithm,
108     TPM2B_PUBLIC                *template);
109 
110 TPM2_ALG_ID
111 ifapi_get_signature_algorithm_from_pem(
112     const char                  *pemKey);
113 
114 TSS2_RC
115 ifapi_get_tpm_key_fingerprint(
116     const TPM2B_PUBLIC *tpmPublicKey,
117     TPMI_ALG_HASH hashAlg,
118     TPM2B_DIGEST *fingerprint);
119 
120 TSS2_RC
121 ifapi_base64encode(
122     uint8_t *buffer,
123     size_t buffer_size,
124     char** b64_data);
125 
126 #endif /* FAPI_CRYPTO_H */

fapi_int.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef FAPI_INT_H
7 #define FAPI_INT_H
8 
9 #include "fapi_types.h"
10 #include "ifapi_policy_types.h"
11 #include "ifapi_policy_instantiate.h"
12 #include "ifapi_eventlog.h"
13 #include "ifapi_io.h"
14 #include "ifapi_profiles.h"
15 #include "ifapi_macros.h"
16 #include "ifapi_keystore.h"
17 #include "ifapi_policy_store.h"
18 #include "ifapi_config.h"
19 
20 #include <stdlib.h>
21 #include <stdint.h>
22 #include <unistd.h>
23 #include <string.h>
24 #include <inttypes.h>
25 #include <stdarg.h>
26 #include <stdbool.h>
27 #include <sys/stat.h>
28 #include <stdio.h>
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <json-c/json.h>
32 #include <poll.h>
33 
34 #include "tss2_esys.h"
35 #include "tss2_fapi.h"
36 
37 #define DEFAULT_LOG_DIR "/run/tpm2_tss"
38 #define IFAPI_PCR_LOG_FILE "pcr.log"
39 #define IFAPI_OBJECT_TYPE ".json"
40 #define IFAPI_OBJECT_FILE "object.json"
41 #define IFAPI_SRK_KEY_PATH "/HS/SRK"
42 #define IFAPI_EK_KEY_PATH "/HE/EK"
43 #define IFAPI_HS_PATH "/HS"
44 #define IFAPI_HE_PATH "/HE"
45 #define IFAPI_HN_PATH "/HN"
46 #define IFAPI_LOCKOUT_PATH "/LOCKOUT"
47 #define IFAPI_SRK_OBJECT_PATH "/HS/SRK/object.json"
48 #define IFAPI_HS_OBJECT_PATH "/HS/object.json"
49 
50 typedef UINT32 TSS2_KEY_TYPE;
51 #define TSS2_SRK 2
52 #define TSS2_EK 3
53 #define MIN_EK_CERT_HANDLE 0x1c00000
54 #define MIN_PLATFORM_CERT_HANDLE 0x01C08000
55 #define MAX_PLATFORM_CERT_HANDLE 0x01C0FFFF
56 
57 typedef UINT8 IFAPI_SESSION_TYPE;
58 #define IFAPI_SESSION_GENEK 0x01
59 #define IFAPI_SESSION1      0x02
60 #define IFAPI_SESSION2      0x04
61 
62 #define IFAPI_POLICY_PATH "policy"
63 #define IFAPI_NV_PATH "nv"
64 #define IFAPI_EXT_PATH "ext"
65 #define IFAPI_FILE_DELIM "/"
66 #define IFAPI_LIST_DELIM ":"
67 #define IFAPI_FILE_DELIM_CHAR '/'
68 #define IFAPI_PUB_KEY_DIR "ext"
69 #define IFAPI_POLICY_DIR "policy"
70 #define IFAPI_PEM_PUBLIC_STRING "-----BEGIN PUBLIC KEY-----"
71 #define IFAPI_PEM_PRIVATE_KEY "-----PRIVATE KEY-----"
72 #define IFAPI_JSON_TAG_POLICY "policy"
73 #define IFAPI_JSON_TAG_OBJECT_TYPE "objectType"
74 #define IFAPI_JSON_TAG_DUPLICATE "public_parent"
75 
76 #define FAPI_WRITE W_OK
77 #define FAPI_READ R_OK
78 
79 #if TPM2_MAX_NV_BUFFER_SIZE > TPM2_MAX_DIGEST_BUFFER
80 #define IFAPI_MAX_BUFFER_SIZE TPM2_MAX_NV_BUFFER_SIZE
81 #else
82 #define IFAPI_MAX_BUFFER_SIZE TPM2_MAX_DIGEST_BUFFER
83 #endif
84 
85 #define IFAPI_FLUSH_PARENT true
86 #define IFAPI_NOT_FLUSH_PARENT false
87 
88 /* Definition of FAPI buffer for TPM2B transmission */
89 typedef struct {
90     UINT16 size;
91     BYTE buffer[IFAPI_MAX_BUFFER_SIZE];
92 } IFAPI_MAX_BUFFER;
93 
94 #define OSSL_FREE(S,TYPE) if((S) != NULL) {TYPE##_free((void*) (S)); (S)=NULL;}
95 
96 
97 #define FAPI_COPY_DIGEST(dest_buffer, dest_size, src, src_size) \
98     if (src_size > sizeof(TPMU_HA)) { \
99         return_error(TSS2_FAPI_RC_BAD_VALUE, "Digest size too large."); \
100     } \
101     memcpy(dest_buffer, (src), (src_size));  \
102     dest_size = src_size
103 
104 #define HASH_UPDATE(CONTEXT, TYPE, OBJECT, R, LABEL)    \
105     { \
106         uint8_t buffer[sizeof(TYPE)]; \
107         size_t offset = 0; \
108         R = Tss2_MU_ ## TYPE ## _Marshal(OBJECT, \
109                                          &buffer[0], sizeof(TYPE), &offset); \
110         goto_if_error(R, "Marshal for hash update", LABEL); \
111         R = ifapi_crypto_hash_update(CONTEXT, \
112                                      (const uint8_t *) &buffer[0], \
113                                      offset);                     \
114         goto_if_error(R, "crypto hash update", LABEL); }
115 
116 #define HASH_UPDATE_BUFFER(CONTEXT, BUFFER, SIZE, R, LABEL) \
117     R = ifapi_crypto_hash_update(CONTEXT, \
118                                  (const uint8_t *) BUFFER, SIZE) ; \
119     goto_if_error(R, "crypto hash update", LABEL);
120 
121 #define FAPI_SYNC(r,msg,label, ...)             \
122     if (base_rc(r) == TSS2_BASE_RC_TRY_AGAIN) \
123         return TSS2_FAPI_RC_TRY_AGAIN; \
124     if (r != TSS2_RC_SUCCESS) { \
125         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
126         goto label;  \
127     }
128 
130 enum IFAPI_GET_CERT_STATE {
131     GET_CERT_INIT = 0,
132     GET_CERT_WAIT_FOR_GET_CAP,
133     GET_CERT_GET_CERT_NV,
134     GET_CERT_GET_CERT_NV_FINISH,
135     GET_CERT_GET_CERT_READ_PUBLIC,
136     GET_CERT_GET_CERT_READ_HIERARCHY,
137     GET_CERT_READ_CERT
138 };
139 
141 enum IFAPI_CLEANUP_STATE {
142     CLEANUP_INIT = 0,
143     CLEANUP_SESSION1,
144     CLEANUP_SESSION2,
145     CLEANUP_SRK
146 };
147 
149 enum IFAPI_READ_NV_PUBLIC_STATE {
150     READ_NV_PUBLIC_INIT = 0,
151     READ_NV_PUBLIC_GET_ESYS_TR,
152     READ_NV_PUBLIC_GET_PUBLIC
153 };
154 
155 #define IFAPI_MAX_CAP_INFO 17
156 
157 typedef struct {
158     char                                  *description;
159     TPMS_CAPABILITY_DATA                   *capability;
160 } IFAPI_CAP_INFO;
161 
162 typedef struct {
163     char                                 *fapi_version;    
164     IFAPI_CONFIG                           fapi_config;    
165     IFAPI_CAP_INFO             cap[IFAPI_MAX_CAP_INFO];
166 } IFAPI_INFO;
167 
170 typedef struct {
171     TPMI_YES_NO                                  system;    
173     TPMI_YES_NO                              persistent;    
174     UINT32                            persistent_handle;    
175     TPM2B_PUBLIC                                 public;    
176 } IFAPI_KEY_TEMPLATE;
177 
180 typedef struct {
181     TPMI_YES_NO                                  system;    
183     TPMI_RH_HIERARCHY                         hierarchy;    
184     char                                   *description;    
185     TPMS_NV_PUBLIC                               public;    
186 } IFAPI_NV_TEMPLATE;
187 
190 typedef struct {
191     TPMT_SIG_SCHEME                          sig_scheme;    
192     TPMS_ATTEST                                  attest;    
193 } FAPI_QUOTE_INFO;
194 
195 
197 enum _FAPI_STATE_NV_READ {
198     NV_READ_INIT = 0,
199     NV_READ_AUTHORIZE,
200     NV_READ_AUTHORIZE2,
201     NV_READ_AUTH_SENT,
202     NV_READ_CHECK_HANDLE,
203     NV_READ_GET_CAPABILITY,
204     NV_READ_GET_ESYS_HANDLE,
205     NV_READ_GET_NV_PUBLIC
206 };
207 
209 enum _FAPI_STATE_NV_WRITE {
210     NV2_WRITE_INIT = 0,
211     NV2_WRITE_READ,
212     NV2_WRITE_WAIT_FOR_SESSSION,
213     NV2_WRITE_NULL_AUTH_SENT,
214     NV2_WRITE_AUTH_SENT,
215     NV2_WRITE_WRITE_PREPARE,
216     NV2_WRITE_WRITE,
217     NV2_WRITE_AUTHORIZE,
218     NV2_WRITE_AUTHORIZE2
219 };
220 
223 typedef struct {
224     char *nvPath ;              
225     char *policyPath;           
226     TPM2B_NV_PUBLIC public;     
227     ESYS_TR esys_auth_handle;   
228     ESYS_TR esys_handle;        
229     TPM2_HANDLE tpm_handle;     
230     size_t numBytes;            
231     UINT16 bytesRequested;      
232     UINT16 offset;              
233     size_t data_idx;            
234     const uint8_t *data;        
235     uint8_t *rdata;             
236     size_t size;                
237     IFAPI_OBJECT auth_object;   
238     IFAPI_OBJECT nv_object;     
239     TPM2B_AUTH auth;            
240     IFAPI_NV nv_obj;            
241     ESYS_TR auth_index;         
242     uint64_t bitmap;            
243     IFAPI_NV_TEMPLATE public_templ; 
245     enum _FAPI_STATE_NV_READ nv_read_state; 
246     enum _FAPI_STATE_NV_WRITE nv_write_state; 
247     uint8_t *write_data;
248     char *logData;               
249     json_object *jso_event_log;  
250     TPMI_RH_NV_INDEX maxNvIndex; 
251     IFAPI_EVENT pcr_event;       
252     TPML_DIGEST_VALUES digests;  
253     bool skip_policy_computation; 
254 } IFAPI_NV_Cmds;
255 
258 typedef struct {
259     TPMS_CAPABILITY_DATA *capability; /* TPM capability data to check available algs */
260     char **pathlist;                  
261     size_t numPaths;                  
262     size_t numNullPrimaries;         
264     size_t primary_idx;              
265     size_t path_idx;                 
266     IFAPI_OBJECT *null_primaries;    
267 } IFAPI_INITIALIZE;
268 
271 typedef struct {
272     TPML_DIGEST_VALUES digest_list;    
273     TPML_DIGEST_VALUES *event_digests; 
274     ESYS_TR PCR;                       
275     TPML_PCR_SELECTION pcr_selection;  
276     TPML_PCR_SELECTION *pcr_selection_out; 
277     UINT32 update_count;
278     TPML_DIGEST *pcrValues;            /* The values returned by PCR_Read */
279     TPM2_HANDLE pcrIndex;
280     TPMI_ALG_HASH hashAlg;
281     const char *keyPath;              
282     ESYS_TR handle;                   
283     IFAPI_OBJECT *key_object;         
284     TPMS_CAPABILITY_DATA *capabilityData; /* TPM capability data to check available algs */
285     uint32_t *pcrList;                 
286     size_t pcrListSize;                
287     TPM2B_DATA qualifyingData;         
288     uint8_t  const *eventData;
289     TPM2B_EVENT event;
290     size_t eventDataSize;
291     uint32_t const *hashAlgs;
292     uint32_t *hashAlgs2;
293     size_t numHashAlgs;
294     char    const *quoteInfo;
295     TPM2B_ATTEST *tpm_quoted;
296     TPMT_SIGNATURE *tpm_signature;
297     uint8_t *signature;
298     size_t signatureSize;
299     char const *logData;
300     char *pcrLog;
301     IFAPI_EVENT pcr_event;
302     json_object *event_list;
303     FAPI_QUOTE_INFO fapi_quote_info;
304     uint8_t *pcrValue;
305     size_t pcrValueSize;
306     char *event_log_file;
307 } IFAPI_PCR;
308 
311 typedef struct {
312     char *description;             
313     UINT8_ARY appData;             
314     IFAPI_OBJECT object;           
315     char *object_path;             
316     json_object *jso;              
317     char *jso_string;              
318 } IFAPI_Path_SetDescription;
319 
322 typedef struct {
323     size_t numBytes;              
324     size_t idx;                   
325     UINT16 bytesRequested;        
326     uint8_t *data;                
327     uint8_t *ret_data;            
328 } IFAPI_GetRandom;
329 
332 typedef struct {
333     const char *pem_cert;        
334     char *pem_cert_dup;          
335     const char *key_path;        
336     NODE_STR_T *path_list;       
337     IFAPI_OBJECT key_object;     
338 } IFAPI_Key_SetCertificate;
339 
341 enum IFAPI_KEY_CREATE_STATE {
342     KEY_CREATE_INIT = 0,
343     KEY_CREATE_WAIT_FOR_SESSION,
344     KEY_CREATE_WAIT_FOR_PARENT,
345     KEY_CREATE_AUTH_SENT,
346     KEY_CREATE_WAIT_FOR_LOAD_AUTHORIZATION,
347     KEY_CREATE_WAIT_FOR_KEY,
348     KEY_CREATE_WAIT_FOR_HIERARCHY,
349     KEY_CREATE_AUTHORIZE_HIERARCHY,
350     KEY_CREATE_WAIT_FOR_EVICT_CONTROL,
351     KEY_CREATE_WRITE_PREPARE,
352     KEY_CREATE_WRITE,
353     KEY_CREATE_FLUSH1,
354     KEY_CREATE_FLUSH2,
355     KEY_CREATE_CALCULATE_POLICY,
356     KEY_CREATE_PRIMARY_CALCULATE_POLICY,
357     KEY_CREATE_WAIT_FOR_AUTHORIZATION,
358     KEY_CREATE_CLEANUP,
359     KEY_CREATE_WAIT_FOR_RANDOM,
360     KEY_CREATE_PRIMARY_INIT,
361     KEY_CREATE_PRIMARY_WAIT_FOR_SESSION,
362     KEY_CREATE_PRIMARY_WAIT_FOR_HIERARCHY,
363     KEY_CREATE_PRIMARY_WAIT_FOR_AUTHORIZE1,
364     KEY_CREATE_PRIMARY_WAIT_FOR_AUTHORIZE2,
365     KEY_CREATE_PRIMARY_WAIT_FOR_PRIMARY,
366     KEY_CREATE_PRIMARY_WAIT_FOR_EVICT_CONTROL,
367     KEY_CREATE_PRIMARY_FLUSH,
368     KEY_CREATE_PRIMARY_WRITE_PREPARE,
369     KEY_CREATE_PRIMARY_WRITE,
370     KEY_CREATE_PRIMARY_CLEANUP
371 };
372 
375 typedef struct {
376     enum IFAPI_KEY_CREATE_STATE state;
377     const char *keyPath;         
378     NODE_STR_T *path_list;       
379     IFAPI_OBJECT parent;         
380     IFAPI_OBJECT object;          
381     IFAPI_KEY_TEMPLATE public_templ;  
382     TPM2B_PUBLIC public;         
383     IFAPI_OBJECT hierarchy;     
384     TPM2B_SENSITIVE_CREATE inSensitive;
385     TPM2B_DATA outsideInfo;
386     TPML_PCR_SELECTION creationPCR;
387     ESYS_TR handle;
388     const char *authValue;
389     const char *policyPath;
390     const IFAPI_PROFILE *profile;
391     bool gen_sensitive_random;   
393 } IFAPI_Key_Create;
394 
397 typedef struct {
398     char const *keyPath;            
399     uint8_t const *in_data;
400     size_t in_dataSize;
401     IFAPI_OBJECT *key_object;       
402     ESYS_TR key_handle;                 
403     size_t numBytes;                
404     size_t decrypt;                 
405     UINT16 bytesRequested;          
406     TPMT_RSA_DECRYPT rsa_scheme;
407     ESYS_TR object_handle;
408     char *policy_path;
409     ESYS_TR auth_session;
410     const IFAPI_PROFILE *profile;
411     uint8_t *plainText;
412     size_t plainTextSize;
413     uint8_t *cipherText;
414     size_t cipherTextSize;
415 } IFAPI_Data_EncryptDecrypt;
416 
418 enum FAPI_SIGN_STATE {
419     SIGN_INIT = 0,
420     SIGN_WAIT_FOR_SESSION,
421     SIGN_WAIT_FOR_KEY,
422     SIGN_AUTH_SENT,
423     SIGN_WAIT_FOR_FLUSH
424 };
425 
428 typedef struct {
429     enum FAPI_SIGN_STATE state;          
430     const char *keyPath;            
431     ESYS_TR handle;                 
432     TPM2B_DIGEST digest;            
433     TPMT_SIG_SCHEME scheme;         
434     IFAPI_OBJECT *key_object;       
435     TPMT_SIGNATURE *tpm_signature;  
436     TPMI_YES_NO decrypt;            
437     TPMT_SIGNATURE *signature;      
438     char const *padding;            
439     char *certificate;              
440     uint8_t *ret_signature;         
441     size_t signatureSize;
442     char *publicKey;                
443 } IFAPI_Key_Sign;
444 
447 typedef struct {
448     const char *keyPath;            
449     IFAPI_OBJECT *object;           
450     TPM2B_SENSITIVE_DATA *unseal_data; 
451 } IFAPI_Unseal;
452 
453 
456 typedef struct {
457     TPMS_CAPABILITY_DATA *capability_data;   
458     TPMS_CAPABILITY_DATA *fetched_data;       
459     size_t idx_info_cap;
460     IFAPI_INFO  info_obj;
461     UINT32 property_count;
462     UINT32 property;
463 } IFAPI_GetInfo;
464 
466 enum IFAPI_HIERACHY_AUTHORIZATION_STATE {
467     HIERARCHY_CHANGE_AUTH_INIT = 0,
468     HIERARCHY_CHANGE_AUTH_NULL_AUTH_SENT,
469     HIERARCHY_CHANGE_AUTH_AUTH_SENT
470 };
471 
473 enum IFAPI_HIERACHY_POLICY_AUTHORIZATION_STATE {
474     HIERARCHY_CHANGE_POLICY_INIT = 0,
475     HIERARCHY_CHANGE_POLICY_NULL_AUTH_SENT,
476     HIERARCHY_CHANGE_POLICY_AUTHORIZE,
477     HIERARCHY_CHANGE_POLICY_AUTH_SENT
478 };
479 
482 typedef struct {
483     const char *entityPath;         
484     ESYS_TR handle;                 
485     IFAPI_OBJECT *key_object;       
486     const char  *authValue;         
487     TPM2B_AUTH newAuthValue;        
488     TPM2B_PRIVATE *newPrivate;      
489     IFAPI_OBJECT object;            
490     IFAPI_OBJECT hiearchy_object;   
491     ESYS_TR nv_index;               
492     ESYS_TR hierarchy_handle;       
493     char **pathlist;                
494     size_t numPaths;                
495     size_t numPathsCleanup;         
496 } IFAPI_Entity_ChangeAuth;
497 
500 typedef struct {
501     const char *policyPath;           
502     const char *signingKeyPath;       
503     TPM2B_DIGEST policyRef;
504     TPMS_POLICYAUTHORIZATION  authorization;
505 } IFAPI_Fapi_AuthorizePolicy;
506 
509 typedef struct {
510     const char *policyPath;            
511     TPMI_ALG_HASH *hash_alg;           
512     size_t hash_size;                  
513     size_t digest_idx;                 
514 } IFAPI_api_WriteAuthorizeNv;
515 
518 typedef struct {
519     IFAPI_OBJECT hierarchy_lockout; 
520     IFAPI_OBJECT hierarchy_hs;      
521     IFAPI_OBJECT hierarchy_he;      
522     IFAPI_OBJECT hierarchy_hn;      
523     IFAPI_OBJECT *hierarchy;         
524     TPMS_POLICY *hierarchy_policy;  
525     IFAPI_KEY_TEMPLATE public_templ;  
526     TPM2B_PUBLIC public;       
527     char **pathlist;                
528     size_t numPaths;                
529     size_t numHierarchyObjects;      
530     size_t hiearchy_idx;            
531     size_t path_idx;                
532     IFAPI_OBJECT *hierarchies;     
533     TPM2B_SENSITIVE_CREATE inSensitive;
534     TPM2B_DATA outsideInfo;
535     TPML_PCR_SELECTION creationPCR;
536     ESYS_TR handle;
537     const char *authValueLockout;
538     const char *authValueEh;
539     const char *policyPathEh;
540     const char *authValueSh;
541     const char *policyPathSh;
542     size_t digest_idx;
543     size_t hash_size;
544     TPM2_HANDLE cert_nv_idx;
545     TPM2B_NV_PUBLIC *nvPublic;
546     ESYS_TR esys_nv_cert_handle;
547     char *pem_cert;
548     TPM2_ALG_ID cert_key_type;
549     size_t cert_count;
550     size_t cert_idx;
551     TPMS_CAPABILITY_DATA *capabilityData;
552     IFAPI_OBJECT hierarchy_object;
553     TPM2B_AUTH hierarchy_auth;
554     TPM2B_DIGEST policy_digest;
555     char *intermed_crt;
556     char *root_crt;
557     TPMA_PERMANENT auth_state;
558     ESYS_TR srk_esys_handle;
559     ESYS_TR ek_esys_handle;
560     ESYS_TR srk_tpm_handle;
561     ESYS_TR ek_tpm_handle;
562     bool srk_exists;
563     TPM2_HANDLE template_nv_index;
564     TPM2_HANDLE nonce_nv_index;
565 } IFAPI_Provision;
566 
569 typedef struct {
570     char *path;                   
571     IFAPI_OBJECT hierarchy;     
572     IFAPI_OBJECT pkey_object;
573     TPM2B_SENSITIVE_CREATE inSensitive;
574     TPM2B_DATA outsideInfo;
575     TPML_PCR_SELECTION creationPCR;
576     ESYS_TR handle;
577     TPMI_DH_PERSISTENT persistent_handle;
578     TPMS_CAPABILITY_DATA *capabilityData;
579 } IFAPI_CreatePrimary;
580 
583 typedef struct {
584     const char    *keyPath;
585     uint8_t const *signature;
586     size_t         signatureSize;
587     uint8_t const *digest;
588     size_t         digestSize;
589     IFAPI_OBJECT   key_object;
590 } IFAPI_Key_VerifySignature;
591 
593 enum IFAPI_STATE_POLICY {
594     POLICY_INIT = 0,
595     POLICY_READ,
596     POLICY_READ_FINISH,
597     POLICY_INSTANTIATE_PREPARE,
598     POLICY_INSTANTIATE,
599     POLICY_EXECUTE_PREPARE,
600     POLICY_EXECUTE,
601     POLICY_FLUSH
602 };
603 
604 typedef struct IFAPI_POLICY_EXEC_CTX IFAPI_POLICY_EXEC_CTX;
605 typedef struct IFAPI_POLICYUTIL_STACK IFAPI_POLICYUTIL_STACK;
606 
608 enum FAPI_CREATE_SESSION_STATE {
609     CREATE_SESSION_INIT = 0,
610     CREATE_SESSION,
611     WAIT_FOR_CREATE_SESSION
612 };
613 
616 typedef struct {
617     enum IFAPI_STATE_POLICY state;
618     struct TPMS_POLICY policy;
619     size_t digest_idx;
620     size_t hash_size;
621     char **pathlist;                  
622     TPMI_ALG_HASH hash_alg;
623     IFAPI_POLICY_EXEC_CTX *policy_stack; 
626     IFAPI_POLICYUTIL_STACK *util_current_policy;
627     IFAPI_POLICYUTIL_STACK *policyutil_stack;
631     ESYS_TR session;                  
633     enum FAPI_CREATE_SESSION_STATE create_session_state;
634     char *path;
635     IFAPI_POLICY_EVAL_INST_CTX eval_ctx;
636 } IFAPI_POLICY_CTX;
637 
639 enum IFAPI_STATE_FILE_SEARCH {
640     FSEARCH_INIT = 0,
641     FSEARCH_READ,
642     FSEARCH_OBJECT
643 };
644 
647 typedef struct {
648     enum IFAPI_STATE_FILE_SEARCH state;
649     char **pathlist;                
650     size_t path_idx;                
651     size_t numPaths;                
652     char *current_path;
653 } IFAPI_FILE_SEARCH_CTX;
654 
656 enum _FAPI_STATE_PREPARE_LOAD_KEY {
657     PREPARE_LOAD_KEY_INIT = 0,
658     PREPARE_LOAD_KEY_WAIT_FOR_SESSION,
659     PREPARE_LOAD_KEY_INIT_KEY,
660     PREPARE_LOAD_KEY_WAIT_FOR_KEY
661 };
662 
664 enum _FAPI_STATE_LOAD_KEY {
665     LOAD_KEY_GET_PATH = 0,
666     LOAD_KEY_READ_KEY,
667     LOAD_KEY_WAIT_FOR_PRIMARY,
668     LOAD_KEY_LOAD_KEY,
669     LOAD_KEY_AUTH,
670     LOAD_KEY_AUTHORIZE
671 };
672 
675 typedef struct {
676     char   const *pathOfKeyToDuplicate;          
677     char   const *pathToPublicKeyOfNewParent;    
678     TPM2B_PUBLIC public_parent;                  
679     IFAPI_OBJECT *key_object;                    
680     IFAPI_OBJECT export_tree;                    
681     IFAPI_OBJECT pub_key;                        
682     IFAPI_OBJECT dup_key;                        
683     struct TPMS_POLICY policy;
684     ESYS_TR handle_ext_key;
685     char *exportedData;
686 } IFAPI_ExportKey;
687 
690 typedef struct {
691     char   const  *path;                          
693     IFAPI_OBJECT  object;                         
694     TPMS_POLICY   policy;                         
695     TPMI_ALG_HASH hashAlg;                        
696     size_t        profile_idx;                    
697     bool         compute_policy;                  
700 } IFAPI_ExportPolicy;
701 
704 typedef struct {
705     IFAPI_OBJECT object;
706     TPM2B_NAME parent_name;
707     IFAPI_OBJECT *parent_object;
708     IFAPI_OBJECT new_object;
709     char *parent_path;
710     char *out_path;
711     TPM2B_PRIVATE *private;
712     char *jso_string;
713     const IFAPI_PROFILE *profile;
714 } IFAPI_ImportKey;
715 
716 
719 typedef struct {
720     enum _FAPI_STATE_LOAD_KEY state;   
721     enum  _FAPI_STATE_PREPARE_LOAD_KEY prepare_state;
722     NODE_STR_T *path_list;        
723     NODE_OBJECT_T *key_list;
724     IFAPI_OBJECT auth_object;
725     size_t position;
726     ESYS_TR handle;
727     ESYS_TR parent_handle;
728     bool parent_handle_persistent;
729     IFAPI_OBJECT *key_object;
730     char *key_path;
731     char const *path;
732 } IFAPI_LoadKey;
733 
736 typedef struct {
737     bool is_key;                    
738     bool is_persistent_key;         
739     ESYS_TR new_object_handle;
740     TPM2_HANDLE permanentHandle;    
741     IFAPI_OBJECT auth_object;       
742     ESYS_TR auth_index;             
743     char *path;                     
744     IFAPI_OBJECT object;            
745     char **pathlist;                
746     size_t numPaths;                
747     size_t path_idx;                
748 } IFAPI_Entity_Delete;
749 
752 typedef struct {
753     uint8_t type;                   
754     uint8_t *data;                   
755     size_t length;                  
756     bool is_key;                    
757     bool is_persistent_key;         
758     ESYS_TR new_object_handle;
759     TPM2_HANDLE permanentHandle;    
760     IFAPI_OBJECT auth_object;       
761     ESYS_TR auth_index;             
762     char *path;                     
763     IFAPI_OBJECT object;            
764     IFAPI_OBJECT *key_object;       
765 } IFAPI_GetEsysBlob;
766 
769 typedef struct {
770     const char *searchPath;               
771 } IFAPI_Entities_List;
772 
778 typedef union {
779     IFAPI_Provision Provision;
780     IFAPI_Key_Create Key_Create;
781     IFAPI_Key_SetCertificate Key_SetCertificate;
782     IFAPI_Entity_ChangeAuth Entity_ChangeAuth;
783     IFAPI_Entity_Delete Entity_Delete;
784     IFAPI_GetEsysBlob GetEsysBlob;
785     IFAPI_Entities_List Entities_List;
786     IFAPI_Key_VerifySignature Key_VerifySignature;
787     IFAPI_Data_EncryptDecrypt Data_EncryptDecrypt;
788     IFAPI_PCR pcr;
789     IFAPI_INITIALIZE Initialize;
790     IFAPI_Path_SetDescription path_set_info;
791     IFAPI_Fapi_AuthorizePolicy Policy_AuthorizeNewPolicy;
792     IFAPI_api_WriteAuthorizeNv WriteAuthorizeNV;
793     IFAPI_ExportKey ExportKey;
794     IFAPI_ImportKey ImportKey;
795     IFAPI_Unseal Unseal;
796     IFAPI_GetInfo GetInfo;
797     IFAPI_ExportPolicy ExportPolicy;
798 } IFAPI_CMD_STATE;
799 
801 enum _FAPI_STATE_PRIMARY {
802     PRIMARY_INIT = 0,
803     PRIMARY_READ_KEY,
804     PRIMARY_READ_HIERARCHY,
805     PRIMARY_READ_HIERARCHY_FINISH,
806     PRIMARY_AUTHORIZE_HIERARCHY,
807     PRIMARY_GET_AUTH_VALUE,
808     PRIMARY_WAIT_FOR_PRIMARY,
809     PRIMARY_HAUTH_SENT,
810     PRIMARY_CREATED,
811     PRIMARY_VERIFY_PERSISTENT,
812     PRIMARY_GET_CAP
813 };
814 
816 enum _FAPI_STATE_SESSION {
817     SESSION_INIT = 0,
818     SESSION_WAIT_FOR_PRIMARY,
819     SESSION_CREATE_SESSION,
820     SESSION_WAIT_FOR_SESSION1,
821     SESSION_WAIT_FOR_SESSION2
822 };
823 
825 enum _FAPI_STATE_GET_RANDOM {
826     GET_RANDOM_INIT = 0,
827     GET_RANDOM_SENT
828 };
829 
831 enum _FAPI_FLUSH_STATE {
832     FLUSH_INIT = 0,
833     WAIT_FOR_FLUSH
834 };
835 
837 enum _FAPI_STATE {
838     _FAPI_STATE_INIT = 0,         
841     _FAPI_STATE_INTERNALERROR,     
843     INITIALIZE_READ,
844     INITIALIZE_INIT_TCTI,
845     INITIALIZE_GET_CAP,
846     INITIALIZE_WAIT_FOR_CAP,
847     INITIALIZE_READ_PROFILE,
848     INITIALIZE_READ_PROFILE_INIT,
849     INITIALIZE_READ_TIME,
850     INITIALIZE_CHECK_NULL_PRIMARY,
851     INITIALIZE_READ_NULL_PRIMARY,
852     PROVISION_WAIT_FOR_GET_CAP_AUTH_STATE,
853     PROVISION_WAIT_FOR_GET_CAP0,
854     PROVISION_WAIT_FOR_GET_CAP1,
855     PROVISION_INIT_GET_CAP2,
856     PROVISION_WAIT_FOR_GET_CAP2,
857     PROVISION_GET_CERT_NV,
858     PROVISION_GET_CERT_NV_FINISH,
859     PROVISION_GET_CERT_READ_PUBLIC,
860     PROVISION_READ_CERT,
861     PROVISION_PREPARE_READ_ROOT_CERT,
862     PROVISION_READ_ROOT_CERT,
863     PROVISION_PREPARE_READ_INT_CERT,
864     PROVISION_READ_INT_CERT,
865     PROVISION_INIT,
866     PROVISION_INIT_SRK,
867     PROVISION_WAIT_FOR_EK_SESSION,
868     PROVISION_WAIT_FOR_SRK_SESSION,
869     PROVISION_AUTH_EK_NO_AUTH_SENT,
870     PROVISION_AUTH_EK_AUTH_SENT,
871     PROVISION_AUTH_SRK_NO_AUTH_SENT,
872     PROVISION_AUTH_SRK_AUTH_SENT,
873     PROVISION_CLEAN_EK_SESSION,
874     PROVISION_CLEAN_SRK_SESSION,
875     PROVISION_EK_WRITE_PREPARE,
876     PROVISION_EK_WRITE,
877     PROVISION_EK_CHECK_CERT,
878     PROVISION_SRK_WRITE_PREPARE,
879     PROVISION_SRK_WRITE,
880     PROVISION_WAIT_FOR_EK_PERSISTENT,
881     PROVISION_WAIT_FOR_SRK_PERSISTENT,
882     PROVISION_CHANGE_LOCKOUT_AUTH,
883     PROVISION_CHANGE_EH_CHECK,
884     PROVISION_CHANGE_EH_AUTH,
885     PROVISION_CHANGE_SH_CHECK,
886     PROVISION_CHANGE_SH_AUTH,
887     PROVISION_EH_CHANGE_POLICY,
888     PROVISION_SH_CHANGE_POLICY,
889     PROVISION_LOCKOUT_CHANGE_POLICY,
890     PROVISION_FINISHED,
891     PROVISION_WRITE_SH,
892     PROVISION_WRITE_EH,
893     PROVISION_PREPARE_NULL,
894     PROVISION_WRITE_NULL,
895     PROVISION_WRITE_LOCKOUT,
896     PROVISION_WRITE_LOCKOUT_PARAM,
897     PROVISION_PREPARE_LOCKOUT_PARAM,
898     PROVISION_AUTHORIZE_LOCKOUT,
899     PROVISION_FLUSH_SRK,
900     PROVISION_FLUSH_EK,
901     PROVISION_CHECK_FOR_VENDOR_CERT,
902     PROVISION_GET_VENDOR,
903     PROVISION_GET_HIERARCHIES,
904     PROVISION_READ_HIERARCHIES,
905     PROVISION_READ_HIERARCHY,
906     PROVISION_WRITE_HIERARCHIES,
907     PROVISION_WRITE_HIERARCHY,
908     PROVISION_PREPARE_GET_CAP_AUTH_STATE,
909     PROVISION_SRK_GET_PERSISTENT_NAME,
910     PROVISION_CHECK_SRK_EVICT_CONTROL,
911     PROVISION_AUTHORIZE_HS_FOR_EK_EVICT,
912     PROVISION_PREPARE_EK_EVICT,
913     PROVISION_READ_EK_TEMPLATE,
914     PROVISION_READ_EK_NONCE,
915 
916     KEY_CREATE,
917     KEY_CREATE_PRIMARY,
918 
919     CREATE_SEAL,
920 
921     KEY_SET_CERTIFICATE_READ,
922     KEY_SET_CERTIFICATE_WRITE,
923 
924     KEY_GET_CERTIFICATE_READ,
925 
926     GET_RANDOM_WAIT_FOR_SESSION,
927     GET_RANDOM_WAIT_FOR_RANDOM,
928     GET_RANDOM_CLEANUP,
929 
930     NV_CREATE_READ_PROFILE,
931     NV_CREATE_READ_HIERARCHY,
932     NV_CREATE_AUTHORIZE_HIERARCHY,
933     NV_CREATE_GET_INDEX,
934     NV_CREATE_FIND_INDEX,
935     NV_CREATE_WAIT_FOR_SESSION,
936 
937     NV_CREATE_AUTH_SENT,
938     NV_CREATE_WRITE,
939     NV_CREATE_CALCULATE_POLICY,
940 
941     NV_WRITE_READ,
942     NV_WRITE_WRITE,
943     NV_WRITE_CLEANUP,
944 
945     NV_EXTEND_READ,
946     NV_EXTEND_WAIT_FOR_SESSION,
947     NV_EXTEND_AUTHORIZE,
948     NV_EXTEND_AUTH_SENT,
949     NV_EXTEND_WRITE,
950     NV_EXTEND_CLEANUP,
951 
952     NV_INCREMENT_READ,
953     NV_INCREMENT_WAIT_FOR_SESSION,
954     NV_INCREMENT_AUTHORIZE,
955     NV_INCREMENT_AUTH_SENT,
956     NV_INCREMENT_WRITE,
957     NV_INCREMENT_CLEANUP,
958 
959     NV_SET_BITS_READ,
960     NV_SET_BITS_WAIT_FOR_SESSION,
961     NV_SET_BITS_AUTHORIZE,
962     NV_SET_BITS_AUTH_SENT,
963     NV_SET_BITS_WRITE,
964     NV_SET_BITS_CLEANUP,
965 
966     NV_READ_READ,
967     NV_READ_WAIT,
968     NV_READ_WAIT_FOR_SESSION,
969     NV_READ_CLEANUP,
970 
971     ENTITY_DELETE_GET_FILE,
972     ENTITY_DELETE_READ,
973     ENTITY_DELETE_WAIT_FOR_SESSION,
974     ENTITY_DELETE_NULL_AUTH_SENT_FOR_KEY,
975     ENTITY_DELETE_AUTH_SENT_FOR_KEY,
976     ENTITY_DELETE_NULL_AUTH_SENT_FOR_NV,
977     ENTITY_DELETE_AUTH_SENT_FOR_NV,
978     ENTITY_DELETE_KEY,
979     ENTITY_DELETE_KEY_WAIT_FOR_HIERARCHY,
980     ENTITY_DELETE_KEY_WAIT_FOR_AUTHORIZATION,
981     ENTITY_DELETE_AUTHORIZE_NV,
982     ENTITY_DELETE_FILE,
983     ENTITY_DELETE_POLICY,
984     ENTITY_DELETE_REMOVE_DIRS,
985     ENTITY_DELETE_CLEANUP,
986     ENTITY_DELETE_READ_HIERARCHY,
987 
988     GET_ESYS_BLOB_GET_FILE,
989     GET_ESYS_BLOB_READ,
990     GET_ESYS_BLOB_NULL_AUTH_SENT_FOR_KEY,
991     GET_ESYS_BLOB_AUTH_SENT_FOR_KEY,
992     GET_ESYS_BLOB_NULL_AUTH_SENT_FOR_NV,
993     GET_ESYS_BLOB_AUTH_SENT_FOR_NV,
994     GET_ESYS_BLOB_KEY,
995     GET_ESYS_BLOB_WAIT_FOR_KEY,
996     GET_ESYS_BLOB_WAIT_FOR_CONTEXT_SAVE,
997     GET_ESYS_BLOB_SERIALIZE,
998     GET_ESYS_BLOB_FILE,
999     GET_ESYS_BLOB_WAIT_FOR_FLUSH,
1000     GET_ESYS_BLOB_CLEANUP,
1001 
1002     ENTITY_GET_TPM_BLOBS_READ,
1003 
1004     KEY_SIGN_WAIT_FOR_KEY,
1005     KEY_SIGN_WAIT_FOR_SIGN,
1006     KEY_SIGN_CLEANUP,
1007 
1008     ENTITY_CHANGE_AUTH_WAIT_FOR_SESSION,
1009     ENTITY_CHANGE_AUTH_WAIT_FOR_KEY,
1010     ENTITY_CHANGE_AUTH_AUTH_SENT,
1011     ENTITY_CHANGE_AUTH_WAIT_FOR_FLUSH,
1012     ENTITY_CHANGE_AUTH_WRITE_PREPARE,
1013     ENTITY_CHANGE_AUTH_WRITE,
1014     ENTITY_CHANGE_AUTH_WAIT_FOR_KEY_AUTH,
1015     ENTITY_CHANGE_AUTH_WAIT_FOR_NV_READ,
1016     ENTITY_CHANGE_AUTH_WAIT_FOR_NV_AUTH,
1017     ENTITY_CHANGE_AUTH_WAIT_FOR_NV_CHANGE_AUTH,
1018     ENTITY_CHANGE_AUTH_HIERARCHY_CHANGE_AUTH,
1019     ENTITY_CHANGE_AUTH_HIERARCHY_READ,
1020     ENTITY_CHANGE_AUTH_HIERARCHY_AUTHORIZE,
1021     ENTITY_CHANGE_AUTH_SAVE_HIERARCHIES_PREPARE,
1022     ENTITY_CHANGE_AUTH_SAVE_HIERARCHIES_FINISH,
1023     ENTITY_CHANGE_AUTH_CLEANUP,
1024 
1025     DATA_ENCRYPT_WAIT_FOR_PROFILE,
1026     DATA_ENCRYPT_WAIT_FOR_SESSION,
1027     DATA_ENCRYPT_WAIT_FOR_KEY,
1028     DATA_ENCRYPT_WAIT_FOR_FLUSH,
1029     DATA_ENCRYPT_WAIT_FOR_RSA_ENCRYPTION,
1030     DATA_ENCRYPT_CLEAN,
1031 
1032     DATA_DECRYPT_WAIT_FOR_PROFILE,
1033     DATA_DECRYPT_WAIT_FOR_SESSION,
1034     DATA_DECRYPT_WAIT_FOR_KEY,
1035     DATA_DECRYPT_WAIT_FOR_FLUSH,
1036     DATA_DECRYPT_WAIT_FOR_RSA_DECRYPTION,
1037     DATA_DECRYPT_AUTHORIZE_KEY,
1038     DATA_DECRYPT_CLEANUP,
1039 
1040     PCR_EXTEND_WAIT_FOR_SESSION,
1041     PCR_EXTEND_WAIT_FOR_GET_CAP,
1042     PCR_EXTEND_READ_EVENT_LOG,
1043     PCR_EXTEND_APPEND_EVENT_LOG,
1044     PCR_EXTEND_FINISH,
1045     PCR_EXTEND_CLEANUP,
1046 
1047     PCR_READ_READ_PCR,
1048     PCR_READ_READ_EVENT_LIST,
1049 
1050     PCR_QUOTE_WAIT_FOR_GET_CAP,
1051     PCR_QUOTE_WAIT_FOR_SESSION,
1052     PCR_QUOTE_WAIT_FOR_KEY,
1053     PCR_QUOTE_AUTH_SENT,
1054     PCR_QUOTE_AUTHORIZE,
1055     PCR_QUOTE_WAIT_FOR_FLUSH,
1056     PCR_QUOTE_READ_EVENT_LIST,
1057     PCR_QUOTE_CLEANUP,
1058 
1059     PATH_SET_DESCRIPTION_READ,
1060     PATH_SET_DESCRIPTION_WRITE,
1061 
1062     PATH_GET_DESCRIPTION_READ,
1063 
1064     APP_DATA_SET_READ,
1065     APP_DATA_SET_WRITE,
1066 
1067     AUTHORIZE_NEW_CALCULATE_POLICY,
1068     AUTHORIZE_NEW_LOAD_KEY,
1069     AUTHORIZE_NEW_KEY_SIGN_POLICY,
1070     AUTHORIZE_NEW_WRITE_POLICY_PREPARE,
1071     AUTHORIZE_NEW_WRITE_POLICY,
1072     AUTHORIZE_NEW_CLEANUP,
1073 
1074     WRITE_AUTHORIZE_NV_READ_NV,
1075     WRITE_AUTHORIZE_NV_CALCULATE_POLICY,
1076     WRITE_AUTHORIZE_NV_WRITE_NV_RAM_PREPARE,
1077     WRITE_AUTHORIZE_NV_WRITE_NV_RAM,
1078     WRITE_AUTHORIZE_NV_WRITE_OBJCECT,
1079     WRITE_AUTHORIZE_NV_WRITE_POLICY_PREPARE,
1080     WRITE_AUTHORIZE_NV_WRITE_POLICY,
1081     WRITE_AUTHORIZE_NV_CLEANUP,
1082 
1083     EXPORT_KEY_READ_PUB_KEY,
1084     EXPORT_KEY_READ_PUB_KEY_PARENT,
1085     EXPORT_KEY_WAIT_FOR_KEY,
1086     EXPORT_KEY_WAIT_FOR_DUPLICATE,
1087     EXPORT_KEY_WAIT_FOR_EXT_KEY,
1088     EXPORT_KEY_WAIT_FOR_AUTHORIZATON,
1089     EXPORT_KEY_WAIT_FOR_FLUSH1,
1090     EXPORT_KEY_WAIT_FOR_FLUSH2,
1091     EXPORT_KEY_CLEANUP,
1092 
1093     IMPORT_KEY_WRITE_POLICY,
1094     IMPORT_KEY_WRITE,
1095     IMPORT_KEY_SEARCH,
1096     IMPORT_KEY_LOAD_PARENT,
1097     IMPORT_KEY_AUTHORIZE_PARENT,
1098     IMPORT_KEY_IMPORT,
1099     IMPORT_KEY_WAIT_FOR_FLUSH,
1100     IMPORT_KEY_WRITE_OBJECT_PREPARE,
1101     IMPORT_KEY_WRITE_OBJECT,
1102     IMPORT_KEY_CLEANUP,
1103     IMPORT_WAIT_FOR_SESSION,
1104     IMPORT_WAIT_FOR_PARENT,
1105     IMPORT_WAIT_FOR_AUTHORIZATION,
1106     IMPORT_WAIT_FOR_KEY,
1107     IMPORT_WRITE,
1108     IMPORT_FLUSH_PARENT,
1109     IMPORT_FLUSH_KEY,
1110     IMPORT_CLEANUP,
1111 
1112     UNSEAL_WAIT_FOR_KEY,
1113     UNSEAL_AUTHORIZE_OBJECT,
1114     UNSEAL_WAIT_FOR_UNSEAL,
1115     UNSEAL_WAIT_FOR_FLUSH,
1116     UNSEAL_CLEANUP,
1117 
1118     GET_PLATFORM_CERTIFICATE,
1119 
1120     POLICY_EXPORT_READ_OBJECT,
1121     POLICY_EXPORT_READ_OBJECT_FINISH,
1122     POLICY_EXPORT_READ_POLICY,
1123     POLICY_EXPORT_READ_POLICY_FINISH,
1124     POLICY_EXPORT_CHECK_DIGEST,
1125     POLICY_EXPORT_COMPUTE_POLICY_DIGEST,
1126 
1127     VERIFY_QUOTE_READ,
1128 
1129     GET_INFO_GET_CAP,
1130     GET_INFO_GET_CAP_MORE,
1131     GET_INFO_WAIT_FOR_CAP
1132 };
1133 
1140 struct IFAPI_CALLBACKS {
1141     Fapi_CB_Auth auth;
1142     void *authData;
1143     Fapi_CB_Branch branch;
1144     void *branchData;
1145     Fapi_CB_Sign sign;
1146     void *signData;
1147     Fapi_CB_PolicyAction action;
1148     void *actionData;
1149 };
1150 
1157 struct FAPI_CONTEXT {
1158     ESYS_CONTEXT *esys;              
1160     struct IFAPI_CALLBACKS callbacks;       
1161     struct IFAPI_IO io;
1162     struct IFAPI_EVENTLOG eventlog;
1163     struct IFAPI_KEYSTORE keystore;
1164     struct IFAPI_POLICY_STORE pstore;
1165     struct IFAPI_PROFILES profiles;
1166     TPMS_TIME_INFO init_time;        
1168     enum _FAPI_STATE state;          
1169     enum _FAPI_STATE_PRIMARY primary_state; 
1170     enum _FAPI_STATE_SESSION session_state; 
1171     enum _FAPI_STATE_GET_RANDOM get_random_state; 
1172     enum IFAPI_HIERACHY_AUTHORIZATION_STATE hierarchy_state;
1173     enum IFAPI_HIERACHY_POLICY_AUTHORIZATION_STATE hierarchy_policy_state;
1174     enum IFAPI_GET_CERT_STATE get_cert_state;
1175     enum _FAPI_FLUSH_STATE flush_object_state;  
1176     enum IFAPI_CLEANUP_STATE cleanup_state;     
1177     enum IFAPI_READ_NV_PUBLIC_STATE read_nv_public_state;
1178     IFAPI_CONFIG config;             
1179     UINT32 nv_buffer_max;            
1180     IFAPI_CMD_STATE cmd;             
1182     IFAPI_NV_Cmds nv_cmd;
1183     IFAPI_GetRandom get_random;
1184     IFAPI_CreatePrimary createPrimary;
1185     IFAPI_LoadKey loadKey;
1186     ESYS_TR session1;                
1187     ESYS_TR session2;                
1188     ESYS_TR policy_session;          
1189     ESYS_TR ek_handle;
1190     ESYS_TR srk_handle;
1191     TPMI_DH_PERSISTENT ek_persistent;
1192     TPMI_DH_PERSISTENT srk_persistent;
1193     IFAPI_SESSION_TYPE session_flags;
1194     TPMA_SESSION session1_attribute_flags;
1195     TPMA_SESSION session2_attribute_flags;
1196     IFAPI_MAX_BUFFER aux_data; 
1197     IFAPI_POLICY_CTX policy;  
1198     IFAPI_FILE_SEARCH_CTX fsearch;  
1199     IFAPI_Key_Sign Key_Sign; 
1200     enum IFAPI_IO_STATE io_state;
1201     NODE_OBJECT_T *object_list;
1202     IFAPI_OBJECT *duplicate_key; 
1203     IFAPI_OBJECT *current_auth_object;
1204 };
1205 
1206 #define VENDOR_IFX  0x49465800
1207 #define VENDOR_INTC 0x494E5443
1208 #define VEDNOR_IBM  0x49424D20
1209 
1210 #endif /* FAPI_INT_H */

fapi_policy.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef FAPI_POLICY_H
7 #define FAPI_POLICY_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "tss2_esys.h"
17 #include "tss2_fapi.h"
18 #include "fapi_int.h"
19 
20 #include "ifapi_policy_types.h"
21 #include "ifapi_policy_json_serialize.h"
22 #include "ifapi_policy_json_deserialize.h"
23 #include "ifapi_policy.h"
24 #include "ifapi_policy_calculate.h"
25 #include "ifapi_policy_execute.h"
26 #include "ifapi_json_serialize.h"
27 #include "ifapi_json_deserialize.h"
28 
29 
30 #endif /* FAPI_POLICY_H */

fapi_types.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef FAPI_TYPES_H
7 #define FAPI_TYPES_H
8 
9 #include <stdlib.h>
10 #include <stdint.h>
11 #include <stdbool.h>
12 
15 typedef struct {
16     size_t size;
17     uint8_t *buffer;
18 } UINT8_ARY;
19 
24 typedef struct str_node {
25     char *str;              
26     bool free_string;       
27     struct str_node *next;  
28 } NODE_STR_T;
29 
34 typedef struct object_node {
35     void   *object;             
36     size_t size;                
37     struct object_node *next;   
38 } NODE_OBJECT_T;
39 
40 #endif /* FAPI_TYPES_H */

fapi_util.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef FAPI_UTIL_H
7 #define FAPI_UTIL_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "util/aux_util.h"
17 #include "tss2_esys.h"
18 #include "tss2_fapi.h"
19 #include "fapi_int.h"
20 #include "ifapi_helpers.h"
21 
22 TSS2_RC
23 ifapi_flush_object(FAPI_CONTEXT *context, ESYS_TR session);
24 
25 TSS2_RC
26 ifapi_get_session_async(
27     ESYS_CONTEXT *esys,
28     ESYS_TR saltkey,
29     const IFAPI_PROFILE*profile,
30     TPMI_ALG_HASH hashAlg);
31 
32 TSS2_RC
33 ifapi_get_session_finish(ESYS_CONTEXT *esys, ESYS_TR *session,
34                          TPMA_SESSION flags);
35 
36 const char *
37 ifapi_get_object_path(IFAPI_OBJECT *object);
38 
39 TSS2_RC
40 ifapi_set_auth(
41     FAPI_CONTEXT *context,
42     IFAPI_OBJECT *auth_object,
43     const char *description);
44 
45 TSS2_RC
46 ifapi_get_free_handle_async(FAPI_CONTEXT *fctx, TPM2_HANDLE *handle);
47 
48 TSS2_RC
49 ifapi_get_free_handle_finish(FAPI_CONTEXT *fctx, TPM2_HANDLE *handle,
50                              TPM2_HANDLE max);
51 
52 TSS2_RC
53 ifapi_init_primary_async(
54     FAPI_CONTEXT *context,
55     TSS2_KEY_TYPE ktype);
56 
57 TSS2_RC
58 ifapi_init_primary_finish(
59     FAPI_CONTEXT *context,
60     TSS2_KEY_TYPE ktype,
61     IFAPI_OBJECT *hierarchy);
62 
63 TSS2_RC
64 ifapi_session_init(FAPI_CONTEXT *context);
65 
66 TSS2_RC
67 ifapi_non_tpm_mode_init(FAPI_CONTEXT *context);
68 
69 void
70 ifapi_session_clean(FAPI_CONTEXT *context);
71 
72 TSS2_RC
73 ifapi_cleanup_session(FAPI_CONTEXT *context);
74 
75 void
76 ifapi_primary_clean(FAPI_CONTEXT *context);
77 
78 TSS2_RC
79 ifapi_get_sessions_async(
80     FAPI_CONTEXT *context,
81     IFAPI_SESSION_TYPE session_flags,
82     TPMA_SESSION attribute_flags1,
83     TPMA_SESSION attribute_flags2);
84 
85 TSS2_RC
86 ifapi_get_sessions_finish(
87     FAPI_CONTEXT *context,
88     const IFAPI_PROFILE *profile,
89     TPMI_ALG_HASH hash_alg);
90 
91 TSS2_RC
92 ifapi_merge_profile_into_nv_template(
93     FAPI_CONTEXT *context,
94     IFAPI_NV_TEMPLATE *template);
95 
96 TSS2_RC
97 ifapi_merge_profile_into_template(
98     const IFAPI_PROFILE *profile,
99     IFAPI_KEY_TEMPLATE *template);
100 
101 TSS2_RC
102 ifapi_load_key_async(FAPI_CONTEXT *context, size_t position);
103 
104 TSS2_RC
105 ifapi_load_parent_keys_async(FAPI_CONTEXT *context, char const *keyPath);
106 
107 TSS2_RC
108 ifapi_load_key_finish(FAPI_CONTEXT *context, bool flush_parent);
109 
110 TSS2_RC
111 ifapi_load_keys_async(
112     FAPI_CONTEXT *context,
113     char const *keyPath);
114 
115 TSS2_RC
116 ifapi_load_keys_finish(
117     FAPI_CONTEXT *context,
118     bool flush_parent,
119     ESYS_TR *handle,
120     IFAPI_OBJECT **key_object);
121 
122 TSS2_RC
123 ifapi_nv_read(
124     FAPI_CONTEXT *context,
125     uint8_t     **data,
126     size_t       *size);
127 
128 void
129 ifapi_flush_policy_session(
130     FAPI_CONTEXT *context,
131     ESYS_TR session,
132     TSS2_RC r);
133 
134 TSS2_RC
135 ifapi_nv_write(
136     FAPI_CONTEXT *context,
137     char         *nvPath,
138     size_t         param_offset,
139     uint8_t const *data,
140     size_t         size);
141 
142 TSS2_RC
143 ifapi_get_random(
144     FAPI_CONTEXT *context,
145     size_t numBytes,
146     uint8_t **data);
147 
148 TSS2_RC
149 ifapi_load_key(
150     FAPI_CONTEXT  *context,
151     char    const *keyPath,
152     IFAPI_OBJECT **key_object);
153 
154 TSS2_RC
155 ifapi_key_sign(
156     FAPI_CONTEXT    *context,
157     IFAPI_OBJECT    *sig_key_object,
158     char const      *padding,
159     TPM2B_DIGEST    *digest,
160     TPMT_SIGNATURE **tpm_signature,
161     char           **publicKey,
162     char           **certificate);
163 
164 TSS2_RC
165 ifapi_authorize_object(
166     FAPI_CONTEXT *context,
167     IFAPI_OBJECT *object,
168     ESYS_TR      *session);
169 
170 TSS2_RC
171 ifapi_get_json(
172     FAPI_CONTEXT *context,
173     IFAPI_OBJECT *object,
174     char **json_string);
175 
176 TSS2_RC
177 ifapi_key_create_prepare(
178     FAPI_CONTEXT  *context,
179     char   const *keyPath,
180     char   const *policyPath);
181 
182 TSS2_RC
183 ifapi_key_create_prepare_auth(
184     FAPI_CONTEXT  *context,
185     char   const *keyPath,
186     char   const *policyPath,
187     char   const *authValue);
188 
189 TSS2_RC
190 ifapi_key_create_prepare_sensitive(
191     FAPI_CONTEXT  *context,
192     char    const *keyPath,
193     char    const *policyPath,
194     size_t         dataSize,
195     char    const *authValue,
196     uint8_t const *data);
197 
198 TSS2_RC
199 ifapi_key_create(
200     FAPI_CONTEXT *context,
201     IFAPI_KEY_TEMPLATE *template);
202 
203 TSS2_RC
204 ifapi_get_sig_scheme(
205     FAPI_CONTEXT *context,
206     IFAPI_OBJECT *object,
207     char const *padding,
208     TPM2B_DIGEST *digest,
209     TPMT_SIG_SCHEME *sig_scheme);
210 
211 TSS2_RC
212 ifapi_change_auth_hierarchy(
213     FAPI_CONTEXT *context,
214     ESYS_TR handle,
215     IFAPI_OBJECT *hierarchy_object,
216     TPM2B_AUTH *newAuthValue);
217 
218 TSS2_RC
219 ifapi_change_policy_hierarchy(
220     FAPI_CONTEXT *context,
221     ESYS_TR handle,
222     IFAPI_OBJECT *hierarchy_object,
223     TPMS_POLICY *policy);
224 
225 IFAPI_OBJECT
226 *ifapi_allocate_object(FAPI_CONTEXT *context);
227 
228 void
229 ifapi_free_objects(FAPI_CONTEXT *context);
230 
231 void
232 ifapi_free_object(FAPI_CONTEXT *context, IFAPI_OBJECT **object);
233 
234 TPM2_RC
235 ifapi_capability_init(FAPI_CONTEXT *context);
236 
237 TPM2_RC
238 ifapi_capability_get(FAPI_CONTEXT *context, TPM2_CAP capability,
239                      UINT32 count, TPMS_CAPABILITY_DATA **capability_data);
240 
241 TSS2_RC
242 ifapi_get_certificates(
243     FAPI_CONTEXT *context,
244     UINT32 min_handle,
245     UINT32 max_handle,
246     NODE_OBJECT_T **cert_list);
247 
248 TSS2_RC
249 ifapi_initialize_object(
250     ESYS_CONTEXT *ectx,
251     IFAPI_OBJECT *object);
252 
253 TSS2_RC
254 ifapi_esys_serialize_object(
255     ESYS_CONTEXT *ectx,
256     IFAPI_OBJECT *object);
257 
258 TSS2_RC
259 ifapi_get_description(IFAPI_OBJECT *object, char **description);
260 
261 void
262 ifapi_set_description(IFAPI_OBJECT *object, char *description);
263 
264 TSS2_RC
265 ifapi_get_key_properties(
266     FAPI_CONTEXT *context,
267     char const *key_path,
268     bool *is_primary,
269     bool *in_null_hierarchy);
270 
271 TSS2_RC
272 ifapi_create_primary(FAPI_CONTEXT *context, IFAPI_KEY_TEMPLATE *template);
273 
274 #endif /* FAPI_UTIL_H */

ifapi_config.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef IFAPI_CONFIG_H
7 #define IFAPI_CONFIG_H
8 
9 #include <stdint.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include "tss2_tpm2_types.h"
13 #include "ifapi_io.h"
14 
15 #define ENV_FAPI_CONFIG "TSS2_FAPICONF"
16 
20 typedef struct {
22     char                *profile_dir;
24     char                *user_dir;
26     char                *keystore_dir;
28     char                *profile_name;
30     char                *tcti;
32     char                *log_dir;
34     TPML_PCR_SELECTION   system_pcrs;
36     TPMT_HA              ek_fingerprint;
37     /* URL for EC certificate */
38     char                *ek_cert_file;
39      /* Switch whether certificate validation will done */
40     TPMI_YES_NO         ek_cert_less;
42     char                *intel_cert_service;
43     /* File with firmware measurements. */
44     char                *firmware_log_file;
45     /* File with ima measurements. */
46     char                *ima_log_file;
47 
48 } IFAPI_CONFIG;
49 
50 TSS2_RC
51 ifapi_config_initialize_async(
52     IFAPI_IO            *io
53         );
54 
55 TSS2_RC
56 ifapi_config_initialize_finish(
57     IFAPI_IO            *io,
58     IFAPI_CONFIG        *config
59     );
60 
61 #endif /* IFAPI_CONFIG_H */

ifapi_curl.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 #ifndef IFAPI_CURL_H
3 #define IFAPI_CURL_H
4 
5 #include "fapi_int.h"
6 
7 TSS2_RC
8 ifapi_curl_verify_ek_cert(
9     char* root_cert_pem,
10     char* intermed_cert_pem,
11     char* ek_cert_pem);
12 
13 int
14 ifapi_get_curl_buffer(
15     unsigned char * url,
16     unsigned char ** buffer,
17     size_t *cert_size);
18 
19 #endif /* IFAPI_CURL_H */

ifapi_eventlog.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef IFAPI_EVENTLOG_H
7 #define IFAPI_EVENTLOG_H
8 
9 #include <json-c/json.h>
10 
11 #include "tss2_tpm2_types.h"
12 #include "ifapi_io.h"
13 #include "efi_event.h"
14 #include "ifapi_ima_eventlog.h"
15 #include "ifapi_eventlog_system.h"
16 
17 #define CONTENT_TYPE "content_type"
18 #define CONTENT "content"
19 
22 typedef UINT32 IFAPI_EVENT_TYPE;
23 #define IFAPI_TSS_EVENT_TAG            2    
24 #define IFAPI_IMA_EVENT_TAG            3    
25 #define IFAPI_IMA_NG_EVENT_TAG         4    
26 #define IFAPI_IMA_SIG_EVENT_TAG        5    
27 #define IFAPI_PC_CLIENT                6    
28 #define IFAPI_CEL_TAG                  8    
30 /* Definition of TPMI_CELMGTTYPE Type */
31 typedef UINT32 TPMI_CELMGTTYPE;
32 #define CEL_VERSION  1
33 #define FIRMWARE_END 2
34 #define CEL_TIMESTAMP 80
35 #define STATE_TRANS 81
36 
37 /* Structures of canonical event log format. */
38 
39 /* Definition of TPMS_CEL_VERSION Structure */
40 typedef struct {
41     UINT16 major;     /* The major version */
42     UINT16 minor;     /* The minor version */
43 } TPMS_CEL_VERSION;
44 
45 /* Definition of TPMU_CAPABILITIES Union <OUT> */
46 typedef union {
47     TPMS_CEL_VERSION cel_version;
48     TPMS_EMPTY firmware_end;
49     UINT64 cel_timestamp;
50 } TPMU_CELMGT;
51 
52 /* Definition of TPMS_EVENT_CELMGT Structure*/
53 typedef struct {
54     TPMI_CELMGTTYPE type;      /* type of the cel event structure */
55     TPMU_CELMGT data;          /* the type-specific cel event information */
56 } TPMS_EVENT_CELMGT;
57 
60 typedef struct {
61     TPM2B_EVENT                                    data;    
62     char                                         *event;    
63 } IFAPI_TSS_EVENT;
64 
67 typedef union {
68     IFAPI_TSS_EVENT                           tss_event;    
69     IFAPI_IMA_EVENT                           ima_event;    
70     IFAPI_FIRMWARE_EVENT                 firmware_event;    
71     TPMS_EVENT_CELMGT                         cel_event;    
73 } IFAPI_EVENT_UNION;
74 
77 typedef struct IFAPI_EVENT {
78     UINT32                                       recnum;    
79     TPM2_HANDLE                                     pcr;    
80     TPML_DIGEST_VALUES                          digests;    
81     IFAPI_EVENT_TYPE                       content_type;    
82     IFAPI_EVENT_UNION                           content;    
83     bool                                         verify;    
85 } IFAPI_EVENT;
86 
87 enum IFAPI_EVENTLOG_STATE {
88     IFAPI_EVENTLOG_STATE_INIT = 0,
89     IFAPI_EVENTLOG_STATE_READING,
90     IFAPI_EVENTLOG_STATE_APPENDING,
91     IFAPI_EVENTLOG_STATE_WRITING
92 };
93 
94 typedef struct IFAPI_EVENTLOG {
95     enum IFAPI_EVENTLOG_STATE state;
96     char *log_dir;
97     const char *firmware_log_file;
98     const char *ima_log_file;
99     struct IFAPI_EVENT event;
100     TPM2_HANDLE pcrList[TPM2_MAX_PCRS];
101     size_t pcrListSize;
102     size_t pcrListIdx;
103     json_object *log;
104 } IFAPI_EVENTLOG;
105 
106 TSS2_RC
107 ifapi_eventlog_initialize(
108     IFAPI_EVENTLOG *eventlog,
109     const char *log_dir,
110     const char *firmware_log_file,
111     const char *ima_log_file);
112 
113 TSS2_RC
114 ifapi_eventlog_get_async(
115     IFAPI_EVENTLOG *eventlog,
116     IFAPI_IO *io,
117     const TPM2_HANDLE *pcrList,
118     size_t pcrListSize);
119 
120 TSS2_RC
121 ifapi_eventlog_get_finish(
122     IFAPI_EVENTLOG *eventlog,
123     IFAPI_IO *io,
124     char **log);
125 
126 TSS2_RC
127 ifapi_eventlog_append_check(
128     IFAPI_EVENTLOG *eventlog,
129     IFAPI_IO *io);
130 
131 TSS2_RC
132 ifapi_eventlog_append_finish(
133     IFAPI_EVENTLOG *eventlog,
134     IFAPI_IO *io,
135     const IFAPI_EVENT *event);
136 
137 void
138 ifapi_cleanup_event(
139     IFAPI_EVENT * event);
140 
141 #endif /* IFAPI_EVENTLOG_H */

ifapi_eventlog_system.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef IFAPI_EVENTLOG_SYSTEM_H
7 #define IFAPI_EVENTLOG_SYSTEM_H
8 
9 #include <json-c/json.h>
10 #include "efi_event.h"
11 #include "util/aux_util.h"
12 
13 typedef UINT32 TCG_EVENT_TYPE;
14 
15 typedef struct {
16     TCG_EVENT_TYPE in;
17     char *name;
18 } TCG_EVENT_TYPE_ASSIGN;
19 
20 typedef bool (*DIGEST2_CALLBACK)(TCG_DIGEST2 const *digest, size_t size,
21                                  void *data);
22 typedef bool (*EVENT2_CALLBACK)(TCG_EVENT_HEADER2 const *event_hdr, size_t size,
23                                 void *data);
24 typedef bool (*EVENT2DATA_CALLBACK)(TCG_EVENT2 const *event, UINT32 type,
25                                     void *data);
26 typedef bool (*SPECID_CALLBACK)(TCG_EVENT const *event, void *data);
27 typedef bool (*LOG_EVENT_CALLBACK)(TCG_EVENT const *event_hdr, size_t size,
28                                    void *data);
29 
30 typedef struct {
31     void *data;
32     SPECID_CALLBACK specid_cb;
33     LOG_EVENT_CALLBACK log_eventhdr_cb;
34     EVENT2_CALLBACK event2hdr_cb;
35     DIGEST2_CALLBACK digest2_cb;
36     EVENT2DATA_CALLBACK event2_cb;
37     uint32_t sha1_used;
38     uint32_t sha256_used;
39     uint32_t sha384_used;
40     uint32_t sha512_used;
41     uint32_t sm3_256_used;
42     uint8_t sha1_pcrs[TPM2_MAX_PCRS][TPM2_SHA1_DIGEST_SIZE];
43     uint8_t sha256_pcrs[TPM2_MAX_PCRS][TPM2_SHA256_DIGEST_SIZE];
44     uint8_t sha384_pcrs[TPM2_MAX_PCRS][TPM2_SHA384_DIGEST_SIZE];
45     uint8_t sha512_pcrs[TPM2_MAX_PCRS][TPM2_SHA512_DIGEST_SIZE];
46     uint8_t sm3_256_pcrs[TPM2_MAX_PCRS][TPM2_SM3_256_DIGEST_SIZE];
47 } tpm2_eventlog_context;
48 
51 typedef struct {
52     UINT32 event_type;
53     UINT8_ARY data;
54 } IFAPI_FIRMWARE_EVENT;
55 
56 
57 bool digest2_accumulator_callback(TCG_DIGEST2 const *digest, size_t size,
58                                   void *data);
59 
60 bool parse_event2body(TCG_EVENT2 const *event, UINT32 type);
61 bool foreach_digest2(tpm2_eventlog_context *ctx, UINT32 event_type, unsigned pcr_index,
62                      TCG_DIGEST2 const *event_hdr, size_t count, size_t size);
63 bool parse_event2(TCG_EVENT_HEADER2 const *eventhdr, size_t buf_size,
64                   size_t *event_size, size_t *digests_size);
65 bool foreach_event2(tpm2_eventlog_context *ctx, TCG_EVENT_HEADER2 const *eventhdr_start, size_t size);
66 bool specid_event(TCG_EVENT const *event, size_t size, TCG_EVENT_HEADER2 **next);
67 bool parse_eventlog(tpm2_eventlog_context *ctx, BYTE const *eventlog, size_t size);
68 
69 TSS2_RC
70 ifapi_json_IFAPI_FIRMWARE_EVENT_deserialize(
71     json_object *jso,
72     IFAPI_FIRMWARE_EVENT *out,
73     bool *verify);
74 
75 #endif /* IFAPI_EVENTLOG_SYSTEM_H */

ifapi_get_intl_cert.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_GET_INTL_CERT_H
7 #define IFAPI_GET_INTL_CERT_H
8 
9 TSS2_RC
10 ifapi_get_intl_ek_certificate(
11     FAPI_CONTEXT *context,
12     TPM2B_PUBLIC *ek_public,
13     unsigned char ** buffer,
14     size_t *cert_size);
15 
16 #endif /* IFAPI_GET_INTL_CERT_H */

ifapi_helpers.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef IFAPI_HELPERS_H
7 #define IFAPI_HELPERS_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "tss2_esys.h"
17 #include "tss2_fapi.h"
18 #include "fapi_int.h"
19 
20 TSS2_RC
21 ifapi_create_dirs(const char *supdir, const char *path);
22 
23 TSS2_RC
24 ifapi_set_key_flags(const char *type, bool policy, IFAPI_KEY_TEMPLATE *template);
25 
26 TSS2_RC
27 ifapi_set_nv_flags(const char *type, IFAPI_NV_TEMPLATE *template,
28                    const char *policy);
29 
30 bool
31 ifapi_path_type_p(const char *path, const char *type);
32 
33 ESYS_TR
34 ifapi_get_hierary_handle(const char *path);
35 
36 bool
37 ifapi_null_primary_p(const char *path);
38 
39 bool
40 ifapi_hierarchy_path_p(const char *path);
41 
42 bool
43 ifapi_TPMT_PUBLIC_cmp(TPMT_PUBLIC *in1, TPMT_PUBLIC *in2);
44 
45 void
46 ifapi_init_hierarchy_object(
47     IFAPI_OBJECT *hierarchy,
48     ESYS_TR esys_handle);
49 
50 TSS2_RC
51 ifapi_set_name_hierarchy_object(
52     IFAPI_OBJECT *hierarchy);
53 
54 char *
55 get_description(IFAPI_OBJECT *object);
56 
57 size_t
58 ifapi_path_length(NODE_STR_T *node);
59 
60 void
61 ifapi_free_object_list(NODE_OBJECT_T *node);
62 
63 void
64 ifapi_free_node_list(NODE_OBJECT_T *node);
65 
66 TSS2_RC
67 ifapi_path_string(char **dest, const char *supdir, NODE_STR_T *node, char *name);
68 
69 TSS2_RC
70 ifapi_path_string_n(
71     char **dest,
72     const char *supdir,
73     NODE_STR_T *node,
74     char *name,
75     size_t n);
76 
77 TSS2_RC
78 ifapi_asprintf(char **str, const char *fmt, ...);
79 
80 NODE_STR_T *
81 split_string(const char *string, char *delimiter);
82 
83 NODE_STR_T *
84 init_string_list(const char *string);
85 
86 bool
87 add_string_to_list(NODE_STR_T *str_list, char *string);
88 
89 void
90 free_string_list(NODE_STR_T *node);
91 
92 void
93 ifapi_cleanup_policy(
94     TPMS_POLICY *policy);
95 
96 TPMS_POLICY *
97 ifapi_copy_policy(
98     const TPMS_POLICY *from_policy);
99 
100 TSS2_RC
101 ifapi_get_name(
102     TPMT_PUBLIC *publicInfo,
103     TPM2B_NAME *name);
104 
105 TSS2_RC
106 ifapi_nv_get_name(
107     TPMS_NV_PUBLIC *publicInfo,
108     TPM2B_NAME *name);
109 
110 TSS2_RC
111 ifapi_object_cmp_name(
112     IFAPI_OBJECT *object,
113     void *name,
114     bool *equal);
115 
116 TSS2_RC
117 ifapi_object_cmp_nv_public(
118     IFAPI_OBJECT *object,
119     void *nv_public,
120     bool *equal);
121 
122 TSS2_RC
123 ifapi_tpm_to_fapi_signature(
124     IFAPI_OBJECT *sig_key_object,
125     TPMT_SIGNATURE *tpm_signature,
126     uint8_t **signature,
127     size_t *signatureSize);
128 
129 TSS2_RC
130 ifapi_compute_quote_info(
131     IFAPI_OBJECT *sig_key_object,
132     TPM2B_ATTEST *tpm_quoted,
133     char **quoteInfo);
134 
135 TSS2_RC
136 ifapi_get_quote_info(
137     char const *quoteInfo,
138     TPM2B_ATTEST *tpm_quoted,
139     FAPI_QUOTE_INFO *fapi_quote_ingo);
140 
141 TSS2_RC
142 push_object_to_list(void *object, NODE_OBJECT_T **object_list);
143 
144 TSS2_RC
145 append_object_to_list(void *object, NODE_OBJECT_T **object_list);
146 
147 bool
148 object_with_auth(IFAPI_OBJECT *object);
149 
150 TSS2_RC
151 ifapi_get_nv_start_index(const char *path, TPM2_HANDLE *start_nv_index);
152 
153 TSS2_RC
154 ifapi_check_nv_index(const char *path, TPM2_HANDLE nv_index);
155 
156 TSS2_RC
157 ifapi_check_profile_pcr_selection(
158     const TPML_PCR_SELECTION *pcr_profile,
159     const TPML_PCR_SELECTION *pcr_capablity);
160 
161 TSS2_RC
162 ifapi_filter_pcr_selection_by_index(
163     TPML_PCR_SELECTION *pcr_selection,
164     const TPM2_HANDLE *pcr_index,
165     size_t pcr_count);
166 
167 TSS2_RC ifapi_calculate_pcr_digest(
168     json_object *jso_event_list,
169     const FAPI_QUOTE_INFO *quote_info,
170     TPM2B_DIGEST *pcr_digest);
171 
172 TSS2_RC
173 ifapi_compute_policy_digest(
174     TPML_PCRVALUES *pcrs,
175     TPML_PCR_SELECTION *pcr_selection,
176     TPMI_ALG_HASH hash_alg,
177     TPM2B_DIGEST *pcr_digest);
178 
179 bool
180 ifapi_cmp_public_key(
181     TPM2B_PUBLIC *key1,
182     TPM2B_PUBLIC *key2);
183 
184 void
185 ifapi_check_json_object_fields(
186     json_object *jso,
187     char** field_tab,
188     size_t size_of_tab);
189 
190 TSS2_RC
191 ifapi_extend_pcr(
192     TPMI_ALG_HASH alg,
193     uint8_t *pcr,
194     const uint8_t *digest,
195     size_t alg_size);
196 
197 TSS2_RC ifapi_pcr_selection_to_pcrvalues(
198         TPML_PCR_SELECTION *pcr_selection,
199         TPML_DIGEST *pcr_digests,
200         TPML_PCRVALUES **out);
201 
202 void
203 ifapi_helper_init_policy_pcr_selections(
204         TSS2_POLICY_PCR_SELECTION *s,
205         TPMT_POLICYELEMENT *pol_element);
206 
207 #endif /* IFAPI_HELPERS_H */

ifapi_ima_eventlog.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef IFAPI_IMA_EVENTLOG_H
7 #define IFAPI_IMA_EVENTLOG_H
8 
9 #include <json-c/json.h>
10 
11 #include "fapi_types.h"
12 
13 /* Defines from kernel ima.h" */
14 #define TCG_EVENT_NAME_LEN_MAX 255
15 #define IMA_TEMPLATE_FIELD_ID_MAX_LEN 16
16 #define IMA_TEMPLATE_NUM_FIELDS_MAX 15
17 
18 /* Define from kernel crypt.h */
19 #define CRYPTO_MAX_ALG_NAME 128
20 
21 typedef UINT32 IFAPI_IMA_EVENT_TYPE;
22 #define IFAPI_IMA_EVENT_TAG_IMA        1   
23 #define IFAPI_IMA_EVENT_TAG_NG         2   
24 #define IFAPI_IMA_EVENT_TAG_SIG        3   
26 /* Structure to store event header and data of IMA template */
27 typedef struct {
28     /* header is the First part of the template which will be read
29        beforte the rest of the event will be read and parsed. */
30     struct {
31         UINT32 pcr;
32         UINT8  digest[TPM2_SHA512_DIGEST_SIZE + sizeof(UINT32) + 3];
33     } header;
34     UINT32 ima_type_size;
35     size_t hash_size;
36     TPMI_ALG_HASH hash_alg;
37     char ima_type[TCG_EVENT_NAME_LEN_MAX + 1];
38     char *name;
39     UINT32 event_size;
40     UINT8 *event_buffer; 
41 } IFAPI_IMA_TEMPLATE;
42 
45 typedef struct {
46     IFAPI_IMA_EVENT_TYPE template_name;
47     UINT8_ARY template_value;    
48 } IFAPI_IMA_EVENT;
49 
50 TSS2_RC
51 ifapi_json_IFAPI_IMA_EVENT_deserialize(json_object *jso,  IFAPI_IMA_EVENT *out);
52 
53 TSS2_RC
54 ifapi_json_IFAPI_IMA_EVENT_TYPE_deserialize_txt(json_object *jso,
55                                                 IFAPI_IMA_EVENT_TYPE *out);
56 
57 TSS2_RC ifapi_read_ima_event_log(
58     const char   *filename,
59     const uint32_t *pcrList,
60     const size_t  pcrListSize,
61     json_object **jso_list);
62 
63 TSS2_RC
64 ifapi_get_ima_eventname(IFAPI_IMA_EVENT *event, char **name);
65 
66 #endif /* IFAPI_IMA_EVENTLOG_H */

ifapi_io.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 
7 #ifndef IFAPI_IO_H
8 #define IFAPI_IO_H
9 
10 #include <stdio.h>
11 #include <stdbool.h>
12 #include "tss2_common.h"
13 #include "tss2_fapi.h"
14 
15 typedef struct IFAPI_IO {
16     FILE *stream;
17     short pollevents;
18     const char *char_buffer;
19     char *char_rbuffer;
20     size_t buffer_length;
21     size_t buffer_idx;
22 } IFAPI_IO;
23 
24 #ifdef TEST_FAPI_ASYNC
25 #define _IFAPI_IO_RETRIES 1
26 #else /* TEST_FAPI_ASYNC */
27 #define _IFAPI_IO_RETRIES 0
28 #endif /* TEST_FAPI_ASYNC */
29 
30 static int _ifapi_io_retry __attribute__((unused)) = _IFAPI_IO_RETRIES;
31 
32 #define IFAPI_IO_STREAM context->io.stream
33 #define IFAPI_IO_BUFF context->io.char_buffer
34 #define IFAPI_IO_RBUFF context->io.char_rbuffer
35 #define IFAPI_IO_BUFFLEN context->io.buffer_length
36 #define IFAPI_IO_BUFFIDX context->io.buffer_idx
37 
38 TSS2_RC
39 ifapi_io_read_async(
40     struct IFAPI_IO *io,
41     const char *filename);
42 
43 TSS2_RC
44 ifapi_io_read_finish(
45     struct IFAPI_IO *io,
46     uint8_t **buffer,
47     size_t *length);
48 
49 TSS2_RC
50 ifapi_io_write_async(
51     struct IFAPI_IO *io,
52     const char *filename,
53     const uint8_t *buffer,
54     size_t length);
55 
56 TSS2_RC
57 ifapi_io_write_finish(
58     struct IFAPI_IO *io);
59 
60 TSS2_RC
61 ifapi_io_check_file_writeable(
62     const char *file);
63 
64 TSS2_RC
65 ifapi_io_check_create_dir(
66     const char *dirname, int mode);
67 
68 TSS2_RC
69 ifapi_io_remove_file(
70     const char *file);
71 
72 TSS2_RC
73 ifapi_io_remove_directories(
74     const char *dirname,
75     const char *keystore_path,
76     const char *sub_dir);
77 
78 TSS2_RC
79 ifapi_io_dirfiles(
80     const char *dirname,
81     char ***files,
82     size_t *numfiles);
83 
84 TSS2_RC
85 ifapi_io_dirfiles_all(
86     const char *searchPath,
87     char ***pathlist,
88     size_t *numPaths);
89 
90 bool
91 ifapi_io_path_exists(const char *path);
92 
93 TSS2_RC
94 ifapi_io_poll(IFAPI_IO * io);
95 
96 TSS2_RC
97 ifapi_io_poll_handles(IFAPI_IO *io, FAPI_POLL_HANDLE **handles, size_t *num_handles);
98 
99 #endif /* IFAPI_IO_H */

ifapi_json_deserialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_JSON_DESERIALIZE_H
7 #define IFAPI_JSON_DESERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "ifapi_keystore.h"
15 #include "fapi_int.h"
16 #include "ifapi_eventlog_system.h"
17 
18 #define YES 1
19 #define NO 0
20 
21 #define GET_OPTIONAL(name, json_name, type) \
22     if (!ifapi_get_sub_object(jso, json_name, &jso2)) { \
23         memset(&out->name, 0, sizeof(type)); \
24     } else { \
25         r =  ifapi_json_ ## type ## _deserialize (jso2, &out->name); \
26         return_if_error2(r, "Bad value for field \"%s\".", json_name);  \
27     }
28 
29 
30 /*
31  * Deserialize an embedded structure of an complex TPM2B.
32  * To achieve backward compatibility both JSON representations, of the complex
33  * TPM2B, and of the embedded structure will be allowed.
34  */
35 #define GET_CONDITIONAL_TPM2B(name, json_name, tpm2b_type, type, field_name, cond_cnt) \
36     if (!ifapi_get_sub_object(jso, json_name, &jso2)) { \
37         memset(&out->name, 0, sizeof(type)); \
38     } else { \
39         cond_cnt++; \
40         json_object* jso_size; \
41         if (ifapi_get_sub_object(jso2, "size", &jso_size)) { \
42             tpm2b_type tmp = { 0 }; \
43             r =  ifapi_json_ ## tpm2b_type ## _deserialize (jso2, &tmp); \
44             return_if_error2(r, "Bad value for field \"%s\".", json_name); \
45             out->name = tmp.field_name; \
46         } else { \
47             r =  ifapi_json_ ## type ## _deserialize (jso2, &out->name); \
48             return_if_error2(r, "Bad value for field \"%s\".", json_name); \
49         } \
50     }
51 
52 bool
53 ifapi_get_sub_object(json_object *jso, char *name, json_object **sub_jso);
54 
55 TSS2_RC
56 ifapi_json_char_deserialize(json_object *jso, char **out);
57 
58 TSS2_RC
59 ifapi_json_IFAPI_KEY_deserialize(json_object *jso, IFAPI_KEY *out);
60 
61 TSS2_RC
62 ifapi_json_import_IFAPI_KEY_deserialize(json_object *jso, IFAPI_KEY *out);
63 
64 TSS2_RC
65 ifapi_json_IFAPI_EXT_PUB_KEY_deserialize(json_object *jso,
66         IFAPI_EXT_PUB_KEY *out);
67 
68 TSS2_RC
69 ifapi_json_IFAPI_NV_deserialize(json_object *jso, IFAPI_NV *out);
70 
71 TSS2_RC
72 ifapi_json_IFAPI_HIERARCHY_deserialize(json_object *jso,  IFAPI_HIERARCHY *out);
73 
74 TSS2_RC
75 ifapi_json_IFAPI_OBJECT_deserialize(json_object *jso, IFAPI_OBJECT *out);
76 
77 TSS2_RC
78 ifapi_json_FAPI_QUOTE_INFO_deserialize(json_object *jso, FAPI_QUOTE_INFO *out);
79 
80 TSS2_RC
81 ifapi_json_IFAPI_EVENT_TYPE_deserialize(json_object *jso,
82                                         IFAPI_EVENT_TYPE *out);
83 
84 TSS2_RC
85 ifapi_json_IFAPI_EVENT_TYPE_deserialize_txt(json_object *jso,
86         IFAPI_EVENT_TYPE *out);
87 
88 TSS2_RC
89 ifapi_json_IFAPI_TSS_EVENT_deserialize(json_object *jso,
90                                        IFAPI_TSS_EVENT *out);
91 
92 TSS2_RC
93 ifapi_json_IFAPI_EVENT_UNION_deserialize(
94     UINT32 selector,
95     json_object *jso,
96     IFAPI_EVENT_UNION *out,
97     bool *verify);
98 
99 enum IFAPI_EVENT_ERROR_HANDLING {
100     DIGEST_CHECK_WARNING = 0,
101     DIGEST_CHECK_ERROR,
102     DO_NOT_CHECK_DIGEST
103 };
104 
105 TSS2_RC
106 ifapi_json_IFAPI_EVENT_deserialize(json_object *jso, IFAPI_EVENT *out,
107                                    enum IFAPI_EVENT_ERROR_HANDLING error_handling);
108 
109 TSS2_RC
110 ifapi_json_TPMS_EVENT_CELMGT_deserialize(json_object *jso,  TPMS_EVENT_CELMGT *out);
111 
112 #endif /* IFAPI_JSON_DESERIALIZE_H */

ifapi_json_eventlog_deserialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_JSON_EVENTLOG_DESERIALIZE_H
7 #define IFAPI_JSON_EVENTLOG_DESERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "fapi_int.h"
15 #include "ifapi_keystore.h"
16 
17 
18 TSS2_RC
19 ifapi_json_TCG_EVENT_TYPE_deserialize(
20     json_object *jso,
21     IFAPI_EVENT_TYPE *out);
22 
23 TSS2_RC
24 ifapi_json_TCG_EVENT_TYPE_deserialize(json_object *jso, IFAPI_EVENT_TYPE *out);
25 
26 TSS2_RC
27 ifapi_tcg_event_deserialize(
28     json_object *jso,
29     size_t max_size,
30     uint8_t *buffer,
31     size_t *buf_size);
32 
33 TSS2_RC
34 ifapi_tcg_event_list_deserialize(
35     const char *jso_string,
36     size_t max_size, uint8_t *eventlog,
37     size_t *eventlog_size);
38 
39 #endif /* IFAPI_JSON_DESERIALIZE_H */

ifapi_json_eventlog_serialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_JSON_EVENTLOG_SERIALIZE_H
7 #define IFAPI_JSON_EVENTLOG_SERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "fapi_int.h"
15 #include "ifapi_keystore.h"
16 
17 typedef struct {
18     json_object *jso_event_list;
19     const uint32_t *pcr_list;
20     size_t pcr_list_size;
21     bool skip_event;
22     size_t recnum_tab[TPM2_MAX_PCRS];
23 } callback_data;
24 
25 bool ifapi_pcr_used(
26     uint32_t pcr,
27     const uint32_t *pcr_list,
28     size_t pcr_list_size);
29 
30 TSS2_RC ifapi_tcg_eventlog_serialize(
31     UINT8 const *eventlog,
32     size_t size,
33     const uint32_t *pcr_list,
34     size_t  pcr_list_size,
35     json_object **eventlog_json);
36 
37 TSS2_RC ifapi_get_tcg_firmware_event_list(
38     char const *filename,
39     const uint32_t *pcr_list,
40     size_t  pcr_list_size,
41     json_object **json_eventlog);
42 
43 #endif /* IFAPI_JSON_EVENTLOG_SERIALIZE_H */

ifapi_json_serialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_JSON_SERIALIZE_H
7 #define IFAPI_JSON_SERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "fapi_int.h"
15 #include "ifapi_keystore.h"
16 
17 #define YES 1
18 #define NO 0
19 
20 TSS2_RC
21 ifapi_json_UINT8_ARY_serialize(const UINT8_ARY *in, json_object **jso);
22 
23 TSS2_RC
24 ifapi_json_IFAPI_OBJECT_TYPE_CONSTANT_serialize(const IFAPI_OBJECT_TYPE_CONSTANT
25         in, json_object **jso);
26 
27 TSS2_RC
28 ifapi_json_IFAPI_KEY_serialize(const IFAPI_KEY *in, json_object **jso);
29 
30 TSS2_RC
31 ifapi_json_IFAPI_EXT_PUB_KEY_serialize(const IFAPI_EXT_PUB_KEY *in,
32                                        json_object **jso);
33 
34 TSS2_RC
35 ifapi_json_IFAPI_NV_serialize(const IFAPI_NV *in, json_object **jso);
36 
37 TSS2_RC
38 ifapi_json_IFAPI_HIERARCHY_serialize(const IFAPI_HIERARCHY *in, json_object **jso);
39 
40 TSS2_RC
41 ifapi_json_IFAPI_OBJECT_serialize(const IFAPI_OBJECT *in,
42                                   json_object **jso);
43 
44 TSS2_RC
45 ifapi_json_FAPI_QUOTE_INFO_serialize(const FAPI_QUOTE_INFO *in,
46                                      json_object **jso);
47 
48 TSS2_RC
49 ifapi_json_IFAPI_DUPLICATE_serialize(const IFAPI_DUPLICATE *in,
50                                      json_object **jso);
51 TSS2_RC
52 ifapi_json_IFAPI_CAP_INFO_serialize(const IFAPI_CAP_INFO *in, json_object **jso);
53 
54 TSS2_RC
55 ifapi_json_IFAPI_INFO_serialize(const IFAPI_INFO *in, json_object **jso);
56 
57 TSS2_RC
58 ifapi_json_IFAPI_EVENT_TYPE_serialize(const IFAPI_EVENT_TYPE in,
59                                       json_object **jso);
60 
61 TSS2_RC
62 ifapi_json_IFAPI_EVENT_TYPE_serialize_txt(const IFAPI_EVENT_TYPE in,
63         json_object **jso);
64 
65 TSS2_RC
66 ifapi_json_IFAPI_TSS_EVENT_serialize(const IFAPI_TSS_EVENT *in,
67                                      json_object **jso);
68 
69 TSS2_RC
70 ifapi_json_IFAPI_IMA_EVENT_serialize(const IFAPI_IMA_EVENT *in,
71                                      json_object **jso);
72 
73 TSS2_RC
74 ifapi_json_IFAPI_EVENT_UNION_serialize(const IFAPI_EVENT_UNION *in,
75                                        UINT32 selector, json_object **jso);
76 
77 TSS2_RC
78 ifapi_json_IFAPI_EVENT_serialize(const IFAPI_EVENT *in, json_object **jso);
79 
80 
81 TSS2_RC
82 ifapi_json_IFAPI_CONFIG_serialize(const IFAPI_CONFIG *in, json_object **jso);
83 
84 
85 TSS2_RC
86 ifapi_json_TPMS_EVENT_CELMGT_serialize(const TPMS_EVENT_CELMGT *in, json_object **jso);
87 
88 #endif /* IFAPI_JSON_SERIALIZE_H */

ifapi_keystore.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 
7 #ifndef IFAPI_KEYSTORE_H
8 #define IFAPI_KEYSTORE_H
9 
10 #include <stdlib.h>
11 
12 #include "tss2_common.h"
13 #include "tss2_tpm2_types.h"
14 #include "fapi_types.h"
15 #include "ifapi_policy_types.h"
16 #include "tss2_esys.h"
17 #include "tss2_policy.h"
18 
19 typedef UINT32 IFAPI_OBJECT_TYPE_CONSTANT;
20 #define IFAPI_OBJ_NONE                 0    
21 #define IFAPI_KEY_OBJ                  1    
22 #define IFAPI_NV_OBJ                   2    
23 #define IFAPI_EXT_PUB_KEY_OBJ          3    
24 #define IFAPI_HIERARCHY_OBJ            4    
25 #define IFAPI_DUPLICATE_OBJ            5    
29 typedef struct {
30     UINT32                            persistent_handle;    
31     TPM2B_PUBLIC                                 public;    
32     UINT8_ARY                             serialization;    
33     UINT8_ARY                                   private;    
34     char                                *policyInstance;    
35     TPM2B_DIGEST                            creationHash;   
36     TPM2B_CREATION_DATA                    creationData;    
37     TPMT_TK_CREATION                     creationTicket;    
38     char                                   *description;    
39     UINT8_ARY                                   appData;    
40     char                                   *certificate;    
41     TPMT_SIG_SCHEME                      signing_scheme;    
42     TPM2B_NAME                                     name;    
43     TPMI_YES_NO                               with_auth;    
44     UINT32                                  reset_count;    
45     TPMI_YES_NO                       delete_prohibited;    
46     TPMI_YES_NO                              ek_profile;    
48     TPM2B_DIGEST                                  nonce;    
49 } IFAPI_KEY;
50 
53 typedef struct {
54     char                                *pem_ext_public;    
55     char                                   *certificate;    
56     TPM2B_PUBLIC                                 public;    
57 } IFAPI_EXT_PUB_KEY;
58 
61 typedef struct {
62     TPMI_YES_NO                               with_auth;    
63     char                                   *description;    
64     TPM2B_DIGEST                             authPolicy;
65     ESYS_TR                                  esysHandle;
66     bool                                      authorized;   
67     TPM2B_NAME                                     name;    
68 } IFAPI_HIERARCHY;
69 
72 typedef struct {
73     TPM2B_NV_PUBLIC                              public;    
74     UINT8_ARY                             serialization;    
75     UINT32                                    hierarchy;    
76     char                                *policyInstance;    
77     char                                   *description;    
78     UINT8_ARY                                   appData;    
79     TPMI_YES_NO                               with_auth;    
80     char*                                     event_log;    
81 } IFAPI_NV;
82 
85 typedef struct {
86 
87     TPM2B_PRIVATE                             duplicate; 
88     TPM2B_ENCRYPTED_SECRET               encrypted_seed; 
89     TPM2B_PUBLIC                                 public; 
90     TPM2B_PUBLIC                          public_parent; 
91     char                                   *certificate; 
92     TPMS_POLICY                                 *policy; 
93 } IFAPI_DUPLICATE;
94 
97 typedef union {
98     IFAPI_EXT_PUB_KEY                       ext_pub_key;    
99     IFAPI_KEY                                       key;    
100     IFAPI_NV                                         nv;    
101     IFAPI_DUPLICATE                            key_tree;    
102     IFAPI_HIERARCHY                           hierarchy;    
103 } IFAPI_OBJECT_UNION;
104 
106 enum FAPI_SEARCH_STATE {
107     KSEARCH_INIT = 0,
108     KSEARCH_SEARCH_OBJECT,
109     KSEARCH_READ
110 };
111 
114 typedef struct {
115     size_t path_idx;                
116     size_t numPaths;                
117     char **pathlist;                
118     enum FAPI_SEARCH_STATE state;
119 } IFAPI_KEY_SEARCH;
120 
121 typedef struct IFAPI_KEYSTORE {
122     char *systemdir;
123     char *userdir;
124     char *defaultprofile;
125     IFAPI_KEY_SEARCH key_search;
126     const char* rel_path;
127 } IFAPI_KEYSTORE;
128 
129 
131 enum IFAPI_AUTHORIZATION_STATE {
132     AUTH_INIT = 0,
133     AUTH_CHECK_POLICY,
134     AUTH_CREATE_SESSION,
135     AUTH_EXEC_POLICY,
136     AUTH_FLUSH_OLD_POLICY,
137     AUTH_DONE
138 };
139 
141 enum IFAPI_IO_STATE {
142     IO_INIT = 0,
143     IO_ACTIVE,
144 };
145 
146 #define TSS2_OBJECT_TO_IFAPI_OBJECT(p) ((IFAPI_OBJECT *)p)
147 
150 typedef struct _IFAPI_OBJECT {
151     /* TSS2_OBJECT MUST GO FIRST. In C pointer of first element
152      * is equal to pointer of base type, use this to hide data by
153      * only passing pointer to public in callbacks, however, internal
154      * FAPI code can do a simple upcast it back to the original.
155      *
156      * **NOTE**: One could use offset of, and play the same trick
157      * the linux kernel linked list uses with container_of, but
158      * since offsetof isn't C99, we won't use it here.
159      */
160     TSS2_OBJECT                                  public;    
161     TPMS_POLICY                                 *policy;
162     IFAPI_OBJECT_TYPE_CONSTANT               objectType;    
163     IFAPI_OBJECT_UNION                             misc;    
164     TPMI_YES_NO                                  system;    
166     enum IFAPI_AUTHORIZATION_STATE  authorization_state;    
167     enum IFAPI_IO_STATE                           state;
168     const char                                *rel_path;    
170 } IFAPI_OBJECT;
171 
172 TSS2_RC
173 ifapi_check_valid_path(const char *path);
174 
175 TSS2_RC
176 ifapi_keystore_initialize(
177     IFAPI_KEYSTORE *keystore,
178     const char *config_systemdir,
179     const char *config_userdir,
180     const char *config_defaultprofile);
181 
182 TSS2_RC
183 ifapi_keystore_load_async(
184     IFAPI_KEYSTORE *keystore,
185     IFAPI_IO *io,
186     const char *path);
187 
188 TSS2_RC
189 ifapi_keystore_load_finish(
190     IFAPI_KEYSTORE *keystore,
191     IFAPI_IO *io,
192     IFAPI_OBJECT *object);
193 
194 TSS2_RC
195 ifapi_keystore_object_does_not_exist(
196     IFAPI_KEYSTORE *keystore,
197     const char *path,
198     const IFAPI_OBJECT *object);
199 
200 TSS2_RC
201 ifapi_keystore_store_async(
202     IFAPI_KEYSTORE *keystore,
203     IFAPI_IO *io,
204     const char *path,
205     const IFAPI_OBJECT *object);
206 
207 TSS2_RC
208 ifapi_keystore_store_finish(
209     IFAPI_IO *io);
210 
211 TSS2_RC
212 ifapi_keystore_list_all(
213     IFAPI_KEYSTORE *keystore,
214     const char *searchpath,
215     char ***results,
216     size_t *numresults);
217 
218 TSS2_RC
219 ifapi_keystore_delete(
220      IFAPI_KEYSTORE *keystore,
221      char *path);
222 
223 TSS2_RC
224 ifapi_keystore_remove_directories(
225     IFAPI_KEYSTORE *keystore,
226     const char *dir_name);
227 
228 TSS2_RC
229 ifapi_keystore_search_obj(
230     IFAPI_KEYSTORE *keystore,
231     IFAPI_IO *io,
232     TPM2B_NAME *name,
233     char **found_path);
234 
235 TSS2_RC
236 ifapi_keystore_search_nv_obj(
237     IFAPI_KEYSTORE *keystore,
238     IFAPI_IO *io,
239     TPM2B_NV_PUBLIC *nv_public,
240     char **found_path);
241 
242 TSS2_RC
243 ifapi_keystore_check_overwrite(
244     IFAPI_KEYSTORE *keystore,
245     const char *path);
246 
247 TSS2_RC
248 ifapi_keystore_check_writeable(
249     IFAPI_KEYSTORE *keystore,
250     const char *path);
251 
252 TSS2_RC
253 ifapi_copy_ifapi_key(
254     IFAPI_KEY * dest,
255     const IFAPI_KEY * src);
256 
257 TSS2_RC
258 ifapi_copy_ifapi_hierarchy(
259     IFAPI_HIERARCHY * dest,
260     const IFAPI_HIERARCHY * src);
261 
262 TSS2_RC
263 ifapi_copy_ifapi_key_object(
264     IFAPI_OBJECT * dest,
265     const IFAPI_OBJECT * src);
266 
267 TSS2_RC
268 ifapi_copy_ifapi_hierarchy_object(
269     IFAPI_OBJECT * dest,
270     const IFAPI_OBJECT * src);
271 
272 
273 void ifapi_cleanup_ifapi_key(
274     IFAPI_KEY * key);
275 
276 void ifapi_cleanup_ifapi_ext_pub_key(
277     IFAPI_EXT_PUB_KEY * key);
278 
279 void ifapi_cleanup_ifapi_hierarchy(
280     IFAPI_HIERARCHY * hierarchy);
281 
282 void ifapi_cleanup_ifapi_nv(
283     IFAPI_NV * nv);
284 
285 void ifapi_cleanup_ifapi_duplicate(
286     IFAPI_DUPLICATE * duplicate);
287 
288 void ifapi_cleanup_ifapi_key_search(
289     IFAPI_KEY_SEARCH * key_search);
290 
291 void ifapi_cleanup_ifapi_keystore(
292     IFAPI_KEYSTORE * keystore);
293 
294 void
295 ifapi_cleanup_ifapi_object(
296     IFAPI_OBJECT *object);
297 
298 TSS2_RC
299 ifapi_check_provisioned(
300     IFAPI_KEYSTORE *keystore,
301     const char *rel_path,
302     bool *ok);
303 
304 #endif /* IFAPI_KEYSTORE_H */

ifapi_macros.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef IFAPI_MACROS_H
7 #define IFAPI_MACROS_H
8 
9 #define strdup_check(dest, str, r, label) \
10     if (str) {                             \
11        dest = strdup(str); \
12        if (!dest) { \
13           r = TSS2_FAPI_RC_MEMORY; \
14           LOG_ERROR("Out of memory.");          \
15           goto label; \
16        } \
17     } else { \
18         dest = NULL; \
19     }
20 
21 #define calloc_check(dest, size, r, label) \
22     {                             \
23        dest = callock(size,1);     \
24        if (!dest) { \
25           r = TSS2_FAPI_RC_MEMORY; \
26           LOG_ERROR("Out of memory.");          \
27           goto label; \
28        } \
29     }
30 
31 #define goto_if_null2(p,msg, r, ec, label, ...) \
32     if ((p) == NULL) { \
33         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(ec), ## __VA_ARGS__); \
34         r = (ec); \
35         goto label;  \
36     }
37 
38 #define goto_if_error2(r,msg,label, ...)             \
39     if (r != TSS2_RC_SUCCESS) { \
40         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
41         goto label;  \
42     }
43 
44 #define return_if_error2(r,msg, ...)                \
45     if (r != TSS2_RC_SUCCESS) { \
46         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
47         return r;  \
48     }
49 
50 #define try_again_or_error(r,msg, ...)                \
51     if (base_rc(r) == TSS2_BASE_RC_TRY_AGAIN) \
52         return TSS2_FAPI_RC_TRY_AGAIN; \
53     if (r != TSS2_RC_SUCCESS) { \
54         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
55         return r;  \
56     }
57 
58 #define try_again_or_error_goto(r,msg, label, ...)            \
59     if (base_rc(r) == TSS2_BASE_RC_TRY_AGAIN) \
60         return TSS2_FAPI_RC_TRY_AGAIN; \
61     if (r != TSS2_RC_SUCCESS) { \
62         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
63         goto label;  \
64     }
65 
66 #define return_error2(r,msg, ...) {               \
67     LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
68     return (r); }
69 
70 
71 #define return_if_error_reset_state(r,msg, ...)     \
72     if (r != TSS2_RC_SUCCESS) { \
73         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
74         context->state = _FAPI_STATE_INIT; \
75         return r;  \
76     }
77 
78 #define goto_if_error_reset_state(r,msg,label, ...) \
79     if (r != TSS2_RC_SUCCESS) { \
80         LOG_ERROR(TPM2_ERROR_FORMAT " " msg, TPM2_ERROR_TEXT(r), ## __VA_ARGS__); \
81         context->state = _FAPI_STATE_INIT; \
82         goto label;  \
83     }
84 
85 #define goto_error_reset_state(r,v,msg,label) {  \
86     r = v; \
87     LOG_ERROR("%s " TPM2_ERROR_FORMAT, msg, TPM2_ERROR_TEXT(r));    \
88     context->state = _FAPI_STATE_INIT;                              \
89     goto label; }
90 
91 #define goto_if_null_reset_state(p,msg,r,ec,label)  \
92     if ((p) == NULL) { \
93         LOG_ERROR("%s ", (msg)); \
94         context->state = _FAPI_STATE_INIT;      \
95         (r) = (ec);                             \
96         goto label;  \
97     }
98 
99 #define return_try_again(r) \
100     if (base_rc(r) == TSS2_BASE_RC_TRY_AGAIN) { \
101         LOG_TRACE("Received TRY_AGAIN; returning TRY_AGAIN"); \
102         return TSS2_FAPI_RC_TRY_AGAIN; \
103     }
104 
105 #define check_not_null(X) \
106     if (X == NULL) { \
107         LOG_ERROR(str(X) " is NULL: BAD_REFERENCE"); \
108         return TSS2_FAPI_RC_BAD_REFERENCE; \
109     }
110 
111 #define check_oom(X) \
112     if (X == NULL) { \
113         LOG_ERROR("Out of memory"); \
114         return TSS2_FAPI_RC_MEMORY; \
115     }
116 
117 #if defined __GNUC__ && __GNUC__ < 7
118 #define fallthrough { }
119 #else
120 #define fallthrough __attribute__((fallthrough))
121 #endif
122 
123 #define statecase(VAR, STATE) \
124     case STATE: \
125         LOG_TRACE("State " str(VAR) " reached " str(STATE)); \
126         VAR=STATE;
127 
128 #define general_failure(VAR) \
129     default: \
130         LOG_ERROR("Bad state for " str(VAR)); \
131         return TSS2_FAPI_RC_GENERAL_FAILURE;
132 
133 #define statecasedefault(VAR) \
134     default: \
135         LOG_ERROR("Bad state for " str(VAR)); \
136         return TSS2_FAPI_RC_BAD_SEQUENCE;
137 
138 #define statecasedefault_error(VAR, r, label)         \
139     default: \
140         LOG_ERROR("Bad state for " str(VAR)); \
141         r = TSS2_FAPI_RC_BAD_SEQUENCE; \
142         goto label;
143 
144 #endif /* IFAPI_MACROS_H */

ifapi_policy.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef IFAPI_POLICY_H
7 #define IFAPI_POLICY_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "tss2_esys.h"
17 #include "tss2_fapi.h"
18 #include "fapi_int.h"
19 #include "ifapi_policy_callbacks.h"
20 
21 TSS2_RC
22 get_policy_digest_idx(
23     TPML_DIGEST_VALUES *digest_values,
24     TPMI_ALG_HASH hashAlg,
25     size_t *idx);
26 
27 TSS2_RC
28 ifapi_compute_policy_digest(
29     TPML_PCRVALUES *pcrs,
30     TPML_PCR_SELECTION *pcr_selection,
31     TPMI_ALG_HASH hash_alg,
32     TPM2B_DIGEST *pcr_digest);
33 
34 static inline void ifapi_policy_ctx_init(FAPI_CONTEXT *context) {
35 
36     TSS2_POLICY_CALC_CALLBACKS *callbacks = &context->policy.eval_ctx.callbacks;
37     callbacks->cbname = ifapi_get_object_name;
38     callbacks->cbname_userdata = context;
39     callbacks->cbpublic = ifapi_get_key_public;
40     callbacks->cbpublic_userdata = context;
41     callbacks->cbnvpublic = ifapi_get_nv_public;
42     callbacks->cbnvpublic_userdata = context;
43     callbacks->cbpcr = ifapi_read_pcr;
44     callbacks->cbpcr_userdata = context;
45 }
46 
47 TSS2_RC
48 ifapi_calculate_tree_ex(
49     IFAPI_POLICY_CTX *policyContext,
50     IFAPI_POLICY_STORE *pstore,
51     IFAPI_IO *io,
52     const char *policyPath,
53     TPMS_POLICY *policy,
54     TPMI_ALG_HASH hash_alg,
55     size_t *digest_idx,
56     size_t *hash_size);
57 
58 TSS2_RC
59 ifapi_execute_tree_ex(
60     enum IFAPI_STATE_POLICY *state,
61     IFAPI_POLICY_EXEC_CTX *context,
62     IFAPI_POLICY_EVAL_INST_CTX *eval_ctx,
63     IFAPI_POLICY_STORE *pstore,
64     IFAPI_IO *io,
65     const char *policyPath,
66     TPMS_POLICY *policy,
67     ESYS_CONTEXT *esys_ctx,
68     TPMI_ALG_HASH hash_alg,
69     bool do_flush);
70 
71 static inline TSS2_RC
72 ifapi_calculate_tree(
73     FAPI_CONTEXT *context,
74     const char *policyPath,
75     TPMS_POLICY *policy,
76     TPMI_ALG_HASH hash_alg,
77     size_t *digest_idx,
78     size_t *hash_size) {
79 
80     return ifapi_calculate_tree_ex(&context->policy,
81             &context->pstore,
82             &context->io,
83             policyPath,
84             policy,
85             hash_alg,
86             digest_idx,
87             hash_size);
88 }
89 
90 #endif /* IFAPI_POLICY_H */

ifapi_policy_calculate.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef FAPI_POLICY_CALCULATE_H
7 #define FAPI_POLICY_CALCULATE_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "tss2_esys.h"
17 #include "tss2_fapi.h"
18 #include "fapi_int.h"
19 //#include "fapi_policy.h"
20 //#include "ifapi_keystore.h"
21 
22 TSS2_RC
23 ifapi_calculate_policy(
24     TPML_POLICYELEMENTS *policy,
25     TPML_DIGEST_VALUES *policyDigests,
26     TPMI_ALG_HASH hash_alg,
27     size_t hash_size,
28     size_t digest_idx);
29 
30 #endif /* FAPI_POLICY_CALCULATE_H */

ifapi_policy_callbacks.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef FAPI_POLICY_CALLBACKS_H
7 #define FAPI_POLICY_CALLBACKS_H
8 
9 
11 enum IFAPI_STATE_POL_CB_EXCECUTE {
12     POL_CB_EXECUTE_INIT = 0,
13     POL_CB_LOAD_KEY,
14     POL_CB_LOAD_KEY_FINISH,
15     POL_CB_SEARCH_POLICY,
16     POL_CB_EXECUTE_SUB_POLICY,
17     POL_CB_NV_READ,
18     POL_CB_READ_NV_POLICY,
19     POL_CB_READ_OBJECT,
20     POL_CB_AUTHORIZE_OBJECT,
21     POL_CB_AUTHORIZE_KEY
22 };
23 
25 typedef struct {
26     enum  IFAPI_STATE_POL_CB_EXCECUTE cb_state;
28     char*object_path;               
29     IFAPI_OBJECT object;            
30     ESYS_TR key_handle;             
31     ESYS_TR nv_index;               
32     ESYS_TR auth_index;             
33     ESYS_TR flush_handle;           
34     IFAPI_OBJECT auth_object;       
35     IFAPI_LoadKey load_ctx_sav;
36     IFAPI_LoadKey load_ctx;
37     IFAPI_CreatePrimary create_primary_ctx_sav;
38     IFAPI_CreatePrimary create_primary_ctx;
39     IFAPI_OBJECT *key_object_ptr;
40     IFAPI_OBJECT *auth_object_ptr;
41     IFAPI_NV_Cmds nv_cmd_state;
42     IFAPI_NV_Cmds nv_cmd_state_sav; 
43     TPM2B_DIGEST policy_digest;
44     ESYS_TR session;
45     TPMS_POLICY *policy;
46 } IFAPI_POLICY_EXEC_CB_CTX;
47 
48 TSS2_RC
49 ifapi_get_key_public(
50     const char *path,
51     TPMT_PUBLIC *public,
52     void *context);
53 
54 TSS2_RC
55 ifapi_get_object_name(
56     const char *path,
57     TPM2B_NAME *name,
58     void *context);
59 
60 TSS2_RC
61 ifapi_get_nv_public(
62     const char *path,
63     TPMI_RH_NV_INDEX nv_index,
64     TPMS_NV_PUBLIC *nv_public,
65     void *context);
66 
67 TSS2_RC
68 ifapi_read_pcr(
69     TSS2_POLICY_PCR_SELECTION *pcr_selection,
70     TPML_PCR_SELECTION *out_pcr_selection,
71     TPML_DIGEST *out_pcr_digests,
72     void *ctx);
73 
74 TSS2_RC
75 ifapi_policyeval_cbauth(
76     TPM2B_NAME *name,
77     ESYS_TR *object_handle,
78     ESYS_TR *auth_handle,
79     ESYS_TR *authSession,
80     void *userdata);
81 
82 TSS2_RC
83 ifapi_policyeval_cbload_key(
84     TPM2B_NAME *name,
85     ESYS_TR *object_handle,
86     void *userdata);
87 
88 TSS2_RC
89 ifapi_branch_selection(
90     TSS2_OBJECT *auth_object,
91     const char *branch_names[8],
92     size_t branch_count,
93     size_t *branch_idx,
94     void *userdata);
95 
96 TSS2_RC
97 ifapi_sign_buffer(
98     char *key_pem,
99     char *public_key_hint,
100     TPMI_ALG_HASH key_pem_hash_alg,
101     uint8_t *buffer,
102     size_t buffer_size,
103     const uint8_t **signature,
104     size_t *signature_size,
105     void *userdata);
106 
107 TSS2_RC
108 ifapi_exec_auth_policy(
109     TPMT_PUBLIC *key_public,
110     TPMI_ALG_HASH hash_alg,
111     TPM2B_DIGEST *digest,
112     TPM2B_NONCE *policyRef,
113     TPMT_SIGNATURE *signature,
114     void *userdata);
115 
116 TSS2_RC
117 ifapi_exec_auth_nv_policy(
118     TPMS_NV_PUBLIC *nv_public,
119     TPMI_ALG_HASH hash_alg,
120     void *userdata);
121 
122 TSS2_RC
123 ifapi_get_duplicate_name(
124     TPM2B_NAME *name,
125     void *userdata);
126 
127 TSS2_RC
128 ifapi_policy_action(
129     const char *action,
130     void *userdata);
131 
132 #endif /* FAPI_POLICY_CALLBACKS_H */

ifapi_policy_execute.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef FAPI_POLICY_EXECUTE_H
7 #define FAPI_POLICY_EXECUTE_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "tss2_esys.h"
17 #include "tss2_fapi.h"
18 
19 TSS2_RC
20 ifapi_extend_authorization(
21     TPMS_POLICY *policy,
22     TPMS_POLICYAUTHORIZATION *authorization);
23 
24 typedef TSS2_RC(*Policy_Compare_Object)(
25     TPMS_POLICY *policy,
26     void *object1,
27     void *object2,
28     bool *found);
29 
34 struct POLICY_LIST {
35     const char *path;            
36     TPMS_POLICY policy;          
37     struct POLICY_LIST *next;    
38 };
39 
44 struct policy_object_node {
45     const char *path;                  
46     TPMS_POLICY policy;                
47     struct policy_object_node *next;   
48 };
49 
51 enum IFAPI_STATE_POLICY_EXCECUTE {
52     POLICY_EXECUTE_INIT = 0,
53     POLICY_EXECUTE_FINISH,
54     POLICY_EXECUTE_CALLBACK,
55     POLICY_LOAD_KEY,
56     POLICY_LOAD_KEYEDHASH,
57     POLICY_FLUSH_KEY,
58     POLICY_VERIFY,
59     POLICY_AUTH_CALLBACK,
60     POLICY_AUTH_SENT,
61     POLICY_EXEC_ESYS
62 };
63 
64 typedef struct IFAPI_POLICY_CALLBACK_CTX IFAPI_POLICY_CALLBACK_CTX;
65 
67 struct IFAPI_POLICY_EXEC_CTX {
68     enum IFAPI_STATE_POLICY_EXCECUTE state;
71     TPML_DIGEST digest_list;        
72     IFAPI_POLICY_EXEC_CTX *next;    
73     IFAPI_POLICY_EXEC_CTX *prev;    
74     ESYS_TR session;                
75     TPMS_POLICY *policy;
76     ESYS_TR policySessionSav;       
77     ESYS_TR object_handle;
78     ESYS_TR nv_index;
79     ESYS_TR auth_handle;
80     IFAPI_OBJECT auth_objectNV;       
81     IFAPI_OBJECT *auth_object;        
82     ESYS_TR auth_session;
83     TPMI_ALG_HASH hash_alg;
84     void  *app_data;                
85     NODE_OBJECT_T *policy_elements; 
86     TPM2B_DIGEST *nonceTPM;
87     uint8_t *buffer;
88     size_t buffer_size;
89     TPM2B_NAME name;
90     char *pem_key;                   
91     struct POLICY_LIST *policy_list;
93     bool flush_handle;              
94     TSS2_POLICY_EXEC_CALLBACKS callbacks;
98 };
99 
100 TSS2_RC
101 ifapi_policyeval_execute_prepare(
102     IFAPI_POLICY_EXEC_CTX *pol_ctx,
103     TPMI_ALG_HASH hash_alg,
104     TPMS_POLICY *policy);
105 
106 TSS2_RC
107 ifapi_policyeval_execute(
108     ESYS_CONTEXT *esys_ctx,
109     IFAPI_POLICY_EXEC_CTX *current_policy,
110     bool do_flush);
111 
112 #endif /* FAPI_POLICY_EXECUTE_H */

ifapi_policy_instantiate.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef FAPI_POLICY_INSTANTIATE_H
7 #define FAPI_POLICY_INSTANTIATE_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "tss2_esys.h"
17 #include "tss2_fapi.h"
18 #include "tss2_policy.h"
19 //#include "fapi_int.h"
20 //#include "fapi_policy.h"
21 //#include "ifapi_keystore.h"
22 
25 typedef struct {
26     TPMS_POLICY                         *policy; 
27     NODE_OBJECT_T              *policy_elements; 
28     TSS2_POLICY_CALC_CALLBACKS          callbacks;
29 } IFAPI_POLICY_EVAL_INST_CTX;
30 
31 TSS2_RC
32 ifapi_policyeval_instantiate_async(
33     IFAPI_POLICY_EVAL_INST_CTX *context, /* For re-entry after try_again for offsets and such */
34     TPMS_POLICY *policy);                /* in */
35 TSS2_RC
36 
37 ifapi_policyeval_instantiate_finish(
38     IFAPI_POLICY_EVAL_INST_CTX *context);
39 
40 #endif /* FAPI_POLICY_INSTANTIATE_H */

ifapi_policy_json_deserialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_POLICY_JSON_DESERIALIZE_H
7 #define IFAPI_POLICY_JSON_DESERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "fapi_int.h"
15 
16 TSS2_RC
17 ifapi_json_TPMI_POLICYTYPE_deserialize(json_object *jso, TPMI_POLICYTYPE *out);
18 
19 TSS2_RC
20 ifapi_json_TPMI_POLICYTYPE_deserialize_txt(json_object *jso,
21         TPMI_POLICYTYPE *out);
22 
23 TSS2_RC
24 ifapi_json_TPMS_POLICYSIGNED_deserialize(json_object *jso,
25         TPMS_POLICYSIGNED *out);
26 
27 TSS2_RC
28 ifapi_json_TPMS_POLICYSECRET_deserialize(json_object *jso,
29         TPMS_POLICYSECRET *out);
30 
31 TSS2_RC
32 ifapi_json_TPMS_POLICYLOCALITY_deserialize(json_object *jso,
33         TPMS_POLICYLOCALITY *out);
34 
35 TSS2_RC
36 ifapi_json_TPMS_POLICYNV_deserialize(json_object *jso, TPMS_POLICYNV *out);
37 
38 TSS2_RC
39 ifapi_json_TPMS_POLICYCOUNTERTIMER_deserialize(json_object *jso,
40         TPMS_POLICYCOUNTERTIMER *out);
41 
42 TSS2_RC
43 ifapi_json_TPMS_POLICYCOMMANDCODE_deserialize(json_object *jso,
44         TPMS_POLICYCOMMANDCODE *out);
45 
46 TSS2_RC
47 ifapi_json_TPMS_POLICYPHYSICALPRESENCE_deserialize(json_object *jso,
48         TPMS_POLICYPHYSICALPRESENCE *out);
49 
50 TSS2_RC
51 ifapi_json_TPMS_POLICYCPHASH_deserialize(json_object *jso,
52         TPMS_POLICYCPHASH *out);
53 
54 TSS2_RC
55 ifapi_json_TPMS_POLICYNAMEHASH_deserialize(json_object *jso,
56         TPMS_POLICYNAMEHASH *out);
57 
58 TSS2_RC
59 ifapi_json_TPMS_POLICYDUPLICATIONSELECT_deserialize(json_object *jso,
60         TPMS_POLICYDUPLICATIONSELECT *out);
61 
62 TSS2_RC
63 ifapi_json_TPMS_POLICYAUTHORIZE_deserialize(json_object *jso,
64         TPMS_POLICYAUTHORIZE *out);
65 
66 TSS2_RC
67 ifapi_json_TPMS_POLICYAUTHVALUE_deserialize(json_object *jso,
68         TPMS_POLICYAUTHVALUE *out);
69 
70 TSS2_RC
71 ifapi_json_TPMS_POLICYPASSWORD_deserialize(json_object *jso,
72         TPMS_POLICYPASSWORD *out);
73 
74 TSS2_RC
75 ifapi_json_TPMS_POLICYNVWRITTEN_deserialize(json_object *jso,
76         TPMS_POLICYNVWRITTEN *out);
77 
78 TSS2_RC
79 ifapi_json_TPMS_POLICYTEMPLATE_deserialize(json_object *jso,
80         TPMS_POLICYTEMPLATE *out);
81 
82 TSS2_RC
83 ifapi_json_TPMS_POLICYAUTHORIZENV_deserialize(json_object *jso,
84         TPMS_POLICYAUTHORIZENV *out);
85 
86 TSS2_RC
87 ifapi_json_TPMS_POLICYACTION_deserialize(json_object *jso,
88         TPMS_POLICYACTION *out);
89 
90 TSS2_RC
91 ifapi_json_TPMS_PCRVALUE_deserialize(json_object *jso, TPMS_PCRVALUE *out);
92 
93 TSS2_RC
94 ifapi_json_TPML_PCRVALUES_deserialize(json_object *jso, TPML_PCRVALUES **out);
95 
96 TSS2_RC
97 ifapi_json_TPMS_POLICYPCR_deserialize(json_object *jso, TPMS_POLICYPCR *out);
98 
99 TSS2_RC
100 ifapi_json_TPMS_POLICYAUTHORIZATION_deserialize(json_object *jso,
101         TPMS_POLICYAUTHORIZATION *out);
102 
103 TSS2_RC
104 ifapi_json_TPML_POLICYAUTHORIZATIONS_deserialize(json_object *jso,
105         TPML_POLICYAUTHORIZATIONS **out);
106 
107 TSS2_RC
108 ifapi_json_TPMS_POLICYBRANCH_deserialize(json_object *jso,
109         TPMS_POLICYBRANCH *out);
110 
111 TSS2_RC
112 ifapi_json_TPML_POLICYBRANCHES_deserialize(json_object *jso,
113         TPML_POLICYBRANCHES **out);
114 
115 TSS2_RC
116 ifapi_json_TPMS_POLICYOR_deserialize(json_object *jso, TPMS_POLICYOR *out);
117 
118 TSS2_RC
119 ifapi_json_TPMU_POLICYELEMENT_deserialize(UINT32 selector, json_object *jso,
120         TPMU_POLICYELEMENT *out);
121 
122 TSS2_RC
123 ifapi_json_TPMT_POLICYELEMENT_deserialize(json_object *jso,
124         TPMT_POLICYELEMENT *out);
125 
126 TSS2_RC
127 ifapi_json_TPML_POLICYELEMENTS_deserialize(json_object *jso,
128         TPML_POLICYELEMENTS **out);
129 
130 TSS2_RC
131 ifapi_json_TPMS_POLICY_deserialize(json_object *jso,
132         TPMS_POLICY *out);
133 
134 #endif /* IFAPI_POLICY_JSON_DESERIALIZE_H */

ifapi_policy_json_serialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_POLICY_JSON_SERIALIZE_H
7 #define IFAPI_POLICY_JSON_SERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "fapi_int.h"
15 
16 TSS2_RC
17 ifapi_json_TPMI_POLICYTYPE_serialize(const TPMI_POLICYTYPE in,
18                                      json_object **jso);
19 
20 TSS2_RC
21 ifapi_json_TPMI_POLICYTYPE_serialize_txt(const TPMI_POLICYTYPE in,
22         json_object **jso);
23 
24 TSS2_RC
25 ifapi_json_TPMS_POLICYSIGNED_serialize(const TPMS_POLICYSIGNED *in,
26                                        json_object **jso);
27 
28 TSS2_RC
29 ifapi_json_TPMS_POLICYSECRET_serialize(const TPMS_POLICYSECRET *in,
30                                        json_object **jso);
31 
32 TSS2_RC
33 ifapi_json_TPMS_POLICYLOCALITY_serialize(const TPMS_POLICYLOCALITY *in,
34         json_object **jso);
35 
36 TSS2_RC
37 ifapi_json_TPMS_POLICYNV_serialize(const TPMS_POLICYNV *in, json_object **jso);
38 
39 TSS2_RC
40 ifapi_json_TPMS_POLICYCOUNTERTIMER_serialize(const TPMS_POLICYCOUNTERTIMER *in,
41         json_object **jso);
42 
43 TSS2_RC
44 ifapi_json_TPMS_POLICYCOMMANDCODE_serialize(const TPMS_POLICYCOMMANDCODE *in,
45         json_object **jso);
46 
47 TSS2_RC
48 ifapi_json_TPMS_POLICYPHYSICALPRESENCE_serialize(const
49         TPMS_POLICYPHYSICALPRESENCE *in, json_object **jso);
50 
51 TSS2_RC
52 ifapi_json_TPMS_POLICYCPHASH_serialize(const TPMS_POLICYCPHASH *in,
53                                        json_object **jso);
54 
55 TSS2_RC
56 ifapi_json_TPMS_POLICYNAMEHASH_serialize(const TPMS_POLICYNAMEHASH *in,
57         json_object **jso);
58 
59 TSS2_RC
60 ifapi_json_TPMS_POLICYDUPLICATIONSELECT_serialize(const
61         TPMS_POLICYDUPLICATIONSELECT *in, json_object **jso);
62 
63 TSS2_RC
64 ifapi_json_TPMS_POLICYAUTHORIZE_serialize(const TPMS_POLICYAUTHORIZE *in,
65         json_object **jso);
66 
67 TSS2_RC
68 ifapi_json_TPMS_POLICYAUTHVALUE_serialize(const TPMS_POLICYAUTHVALUE *in,
69         json_object **jso);
70 
71 TSS2_RC
72 ifapi_json_TPMS_POLICYPASSWORD_serialize(const TPMS_POLICYPASSWORD *in,
73         json_object **jso);
74 
75 TSS2_RC
76 ifapi_json_TPMS_POLICYNVWRITTEN_serialize(const TPMS_POLICYNVWRITTEN *in,
77         json_object **jso);
78 
79 TSS2_RC
80 ifapi_json_TPMS_POLICYTEMPLATE_serialize(const TPMS_POLICYTEMPLATE *in,
81         json_object **jso);
82 
83 TSS2_RC
84 ifapi_json_TPMS_POLICYAUTHORIZENV_serialize(const TPMS_POLICYAUTHORIZENV *in,
85         json_object **jso);
86 
87 TSS2_RC
88 ifapi_json_TPMS_POLICYACTION_serialize(const TPMS_POLICYACTION *in,
89                                        json_object **jso);
90 
91 TSS2_RC
92 ifapi_json_TPMS_PCRVALUE_serialize(const TPMS_PCRVALUE *in, json_object **jso);
93 
94 TSS2_RC
95 ifapi_json_TPML_PCRVALUES_serialize(const TPML_PCRVALUES *in,
96                                     json_object **jso);
97 
98 TSS2_RC
99 ifapi_json_TPMS_POLICYPCR_serialize(const TPMS_POLICYPCR *in,
100                                     json_object **jso);
101 
102 TSS2_RC
103 ifapi_json_TPMS_POLICYAUTHORIZATION_serialize(const TPMS_POLICYAUTHORIZATION
104         *in, json_object **jso);
105 
106 TSS2_RC
107 ifapi_json_TPML_POLICYAUTHORIZATIONS_serialize(const TPML_POLICYAUTHORIZATIONS
108         *in, json_object **jso);
109 
110 TSS2_RC
111 ifapi_json_TPMS_POLICYBRANCH_serialize(const TPMS_POLICYBRANCH *in,
112                                        json_object **jso);
113 
114 TSS2_RC
115 ifapi_json_TPML_POLICYBRANCHES_serialize(const TPML_POLICYBRANCHES *in,
116         json_object **jso);
117 
118 TSS2_RC
119 ifapi_json_TPMS_POLICYOR_serialize(const TPMS_POLICYOR *in, json_object **jso);
120 
121 TSS2_RC
122 ifapi_json_TPMU_POLICYELEMENT_serialize(const TPMU_POLICYELEMENT *in,
123                                         UINT32 selector, json_object **jso);
124 
125 TSS2_RC
126 ifapi_json_TPMT_POLICYELEMENT_serialize(const TPMT_POLICYELEMENT *in,
127                                         json_object **jso);
128 
129 TSS2_RC
130 ifapi_json_TPML_POLICYELEMENTS_serialize(const TPML_POLICYELEMENTS *in,
131         json_object **jso);
132 
133 TSS2_RC
134 ifapi_json_TPMS_POLICY_serialize(const TPMS_POLICY *in,
135         json_object **jso);
136 
137 #endif /* IFAPI_POLICY_JSON_SERIALIZE_H */

ifapi_policy_store.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 
7 #ifndef IFAPI_POLICY_STORE_H
8 #define IFAPI_POLICY_STORE_H
9 
10 #include <stdlib.h>
11 
12 #include "tss2_common.h"
13 #include "tss2_tpm2_types.h"
14 #include "fapi_types.h"
15 #include "ifapi_policy_types.h"
16 
17 typedef struct IFAPI_POLICY_STORE {
18     char *policydir;
19 } IFAPI_POLICY_STORE;
20 
21 TSS2_RC
22 ifapi_policy_delete(
23      IFAPI_POLICY_STORE *pstore,
24      char *path);
25 
26 TSS2_RC
27 ifapi_policy_store_initialize(
28     IFAPI_POLICY_STORE *pstore,
29     const char *config_policydir);
30 
31 TSS2_RC
32 ifapi_policy_store_load_async(
33     IFAPI_POLICY_STORE *pstore,
34     IFAPI_IO *io,
35     const char *path);
36 
37 TSS2_RC
38 ifapi_policy_store_load_finish(
39     IFAPI_POLICY_STORE *pstore,
40     IFAPI_IO *io,
41     TPMS_POLICY *policy);
42 
43 TSS2_RC
44 ifapi_policy_store_store_async(
45     IFAPI_POLICY_STORE *pstore,
46     IFAPI_IO *io,
47     const char *path,
48     const TPMS_POLICY *policy);
49 
50 TSS2_RC
51 ifapi_policy_store_store_finish(
52     IFAPI_POLICY_STORE *pstore,
53     IFAPI_IO *io);
54 
55 TSS2_RC
56 ifapi_policystore_check_overwrite(
57     IFAPI_POLICY_STORE *pstore,
58     const char *path);
59 
60 #endif /* IFAPI_POLICY_STORE_H */

ifapi_policy_types.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef IFAPI_POLICY_TYPES_H
7 #define IFAPI_POLICY_TYPES_H
8 
9 #include "tss2_tpm2_types.h"
10 #include "fapi_types.h"
11 
12 typedef UINT32 TPMI_POLICYTYPE;
13 #define POLICYELEMENTS                 0
14 #define POLICYOR                       1    
15 #define POLICYSIGNED                   2    
16 #define POLICYSECRET                   3    
17 #define POLICYPCR                      4    
18 #define POLICYLOCALITY                 5    
19 #define POLICYNV                       6    
20 #define POLICYCOUNTERTIMER             7    
21 #define POLICYCOMMANDCODE              8    
22 #define POLICYPHYSICALPRESENCE         9    
23 #define POLICYCPHASH                   10    
24 #define POLICYNAMEHASH                 11    
25 #define POLICYDUPLICATIONSELECT        12    
26 #define POLICYAUTHORIZE                13    
27 #define POLICYAUTHVALUE                14    
28 #define POLICYPASSWORD                 15    
29 #define POLICYNVWRITTEN                16    
30 #define POLICYTEMPLATE                 17    
31 #define POLICYAUTHORIZENV              18    
32 #define POLICYACTION                   19    
36 typedef struct {
37     TPM2B_NONCE                                nonceTPM;    
38     TPM2B_DIGEST                                cpHashA;    
39     TPM2B_NONCE                               policyRef;    
40     INT32                                    expiration;    
41     TPMT_SIGNATURE                                 auth;    
42     TPM2B_NAME                                publicKey;    
43     char                                 *publicKeyHint;    
44     char                                       *keyPath;    
45     TPMT_PUBLIC                               keyPublic;    
46     char                                        *keyPEM;    
47     TPMI_ALG_HASH                         keyPEMhashAlg;    
48     TPMT_RSA_SCHEME                           rsaScheme;    
49     TPMT_SIGNATURE                        signature_tpm;
50 } TPMS_POLICYSIGNED;
51 
54 typedef struct {
55     TPM2B_NONCE                                nonceTPM;    
56     TPM2B_DIGEST                                cpHashA;    
57     TPM2B_NONCE                               policyRef;    
58     INT32                                    expiration;    
59     char                                    *objectPath;    
60     TPM2B_NAME                               objectName;    
61 } TPMS_POLICYSECRET;
62 
65 typedef struct {
66     TPMA_LOCALITY                              locality;    
67 } TPMS_POLICYLOCALITY;
68 
71 typedef struct {
72     char                                        *nvPath;    
73     TPMI_RH_NV_INDEX                            nvIndex;    
74     TPMS_NV_PUBLIC                             nvPublic;    
75     TPMI_RH_NV_AUTH                          authHandle;    
76     TPM2B_OPERAND                              operandB;    
77     UINT16                                       offset;    
78     TPM2_EO                                   operation;    
79 } TPMS_POLICYNV;
80 
83 typedef struct {
84     TPM2B_OPERAND                              operandB;    
85     UINT16                                       offset;    
86     TPM2_EO                                   operation;    
87 } TPMS_POLICYCOUNTERTIMER;
88 
91 typedef struct {
92     TPM2_CC                                        code;    
93 } TPMS_POLICYCOMMANDCODE;
94 
97 typedef struct {
98 } TPMS_POLICYPHYSICALPRESENCE;
99 
102 typedef struct {
103     TPM2B_DIGEST                                 cpHash;    
104 } TPMS_POLICYCPHASH;
105 
108 typedef struct {
109     UINT32                                          count;    
110     UINT32                                              i;    
111     TPM2B_NAME                             objectNames[3];    
112     char                                    *namePaths[3];    
113     TPM2B_DIGEST                                 nameHash;    
114 } TPMS_POLICYNAMEHASH;
115 
118 typedef struct {
119     TPM2B_NAME                               objectName;    
120     TPM2B_NAME                            newParentName;    
121     TPMI_YES_NO                           includeObject;    
122     char                                 *newParentPath;    
123     TPMT_PUBLIC                         newParentPublic;    
124 } TPMS_POLICYDUPLICATIONSELECT;
125 
128 typedef struct {
129     char                                          *type;    
130     TPMT_PUBLIC                                     key;    
131     TPM2B_NONCE                               policyRef;    
132     TPMT_SIGNATURE                            signature;    
133     TPMI_ALG_HASH                               hashAlg;
134     UINT8_ARY                              pemSignature;
135     char                                        *keyPEM;
136     TPMT_RSA_SCHEME                           rsaScheme;
137 } TPMS_POLICYAUTHORIZATION;
138 
139 typedef struct policy_object_node POLICY_OBJECT;
140 
143 typedef struct {
144     TPM2B_DIGEST                         approvedPolicy;    
145     TPM2B_NONCE                               policyRef;    
146     TPM2B_NAME                                  keyName;    
147     TPMT_TK_VERIFIED                        checkTicket;    
148     char                                       *keyPath;    
149     TPMT_PUBLIC                               keyPublic;    
150     char                                        *keyPEM;    
151     TPMI_ALG_HASH                         keyPEMhashAlg;    
152     TPMT_RSA_SCHEME                           rsaScheme;    
153     TPMT_SIGNATURE                            signature;
154 } TPMS_POLICYAUTHORIZE;
155 
158 typedef struct {
159 } TPMS_POLICYAUTHVALUE;
160 
163 typedef struct {
164 } TPMS_POLICYPASSWORD;
165 
168 typedef struct {
169     TPMI_YES_NO                              writtenSet;    
170 } TPMS_POLICYNVWRITTEN;
171 
174 typedef struct {
175     TPM2B_DIGEST                           templateHash;    
176     TPM2B_PUBLIC                         templatePublic;    
177 } TPMS_POLICYTEMPLATE;
178 
181 typedef struct {
182     char                                        *nvPath;    
183     TPMS_NV_PUBLIC                             nvPublic;    
184     TPM2B_DIGEST                                 policy;    
185     TPMT_HA                                   nv_policy;    
186     uint8_t                               *policy_buffer;
187 } TPMS_POLICYAUTHORIZENV;
188 
191 typedef struct {
192     char                                        *action;    
193 } TPMS_POLICYACTION;
194 
197 typedef struct {
198     struct TPML_PCRVALUES                         *pcrs;    
199     TPMS_PCR_SELECT                         currentPCRs;    
200     TPML_PCR_SELECTION               currentPCRandBanks;    
201 } TPMS_POLICYPCR;
202 
205 typedef struct TPML_POLICYAUTHORIZATIONS {
206     UINT32                                        count;    
207     TPMS_POLICYAUTHORIZATION             authorizations[];    
208 } TPML_POLICYAUTHORIZATIONS;
209 
210 typedef struct TPML_POLICYELEMENTS TPML_POLICYELEMENTS;
211 
214 typedef struct {
215     char                                          *name;    
216     char                                   *description;    
217     TPML_DIGEST_VALUES                    policyDigests;
218     struct TPML_POLICYELEMENTS                   *policy;    
219 } TPMS_POLICYBRANCH;
220 
223 typedef struct TPML_POLICYBRANCHES {
224     UINT32                                        count;    
225     TPMS_POLICYBRANCH                    authorizations[];    
226 } TPML_POLICYBRANCHES;
227 
230 typedef struct {
231     struct TPML_POLICYBRANCHES                 *branches;    
232 } TPMS_POLICYOR;
233 
236 typedef union {
237     TPMS_POLICYOR                              PolicyOr;    
238     TPMS_POLICYSIGNED                      PolicySigned;    
239     TPMS_POLICYSECRET                      PolicySecret;    
240     TPMS_POLICYPCR                            PolicyPCR;    
241     TPMS_POLICYLOCALITY                  PolicyLocality;    
242     TPMS_POLICYNV                              PolicyNV;    
243     TPMS_POLICYCOUNTERTIMER          PolicyCounterTimer;    
244     TPMS_POLICYCOMMANDCODE            PolicyCommandCode;    
245     TPMS_POLICYPHYSICALPRESENCE    PolicyPhysicalPresence;  
246     TPMS_POLICYCPHASH                      PolicyCpHash;    
247     TPMS_POLICYNAMEHASH                  PolicyNameHash;    
248     TPMS_POLICYDUPLICATIONSELECT   PolicyDuplicationSelect; 
249     TPMS_POLICYAUTHORIZE                PolicyAuthorize;    
250     TPMS_POLICYAUTHVALUE                PolicyAuthValue;    
251     TPMS_POLICYPASSWORD                  PolicyPassword;    
252     TPMS_POLICYNVWRITTEN                PolicyNvWritten;    
253     TPMS_POLICYTEMPLATE                  PolicyTemplate;    
254     TPMS_POLICYAUTHORIZENV            PolicyAuthorizeNv;    
255     TPMS_POLICYACTION                      PolicyAction;    
256 } TPMU_POLICYELEMENT;
257 
260 typedef struct {
261     TPMI_POLICYTYPE                                type;    
262     TPML_DIGEST_VALUES                    policyDigests;    
263     TPMU_POLICYELEMENT                          element;    
264 } TPMT_POLICYELEMENT;
265 
268 struct TPML_POLICYELEMENTS {
269     UINT32                                        count;    
270     TPMT_POLICYELEMENT                         elements[];    
271 };
272 
275 typedef struct TPMS_POLICY {
276     char                                   *description;    
277     TPML_DIGEST_VALUES                    policyDigests;    
278     struct TPML_POLICYAUTHORIZATIONS     *policyAuthorizations;    
279     struct TPML_POLICYELEMENTS                   *policy;    
280 } TPMS_POLICY;
281 
282 #endif /* IFAPI_POLICY_TYPES_H */

ifapi_policyutil_execute.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  *******************************************************************************/
6 #ifndef FAPI_POLICYUTIL_EXECUTE_H
7 #define FAPI_POLICYUTIL_EXECUTE_H
8 
9 #include <stdint.h>
10 #include <stdarg.h>
11 #include <stdbool.h>
12 #include <sys/stat.h>
13 #include <json-c/json.h>
14 #include <json-c/json_util.h>
15 
16 #include "tss2_esys.h"
17 #include "tss2_fapi.h"
18 
19 
21 enum IFAPI_STATE_POLICY_UTIL_EXEC {
22     POLICY_UTIL_INIT,
23     POLICY_UTIL_EXEC_POLICY,
24 };
25 
27 struct IFAPI_POLICYUTIL_STACK {
28     ESYS_TR policy_session;             
29     IFAPI_POLICY_EXEC_CTX *pol_exec_ctx;    
30     enum IFAPI_STATE_POLICY_UTIL_EXEC state;
31     IFAPI_POLICYUTIL_STACK *next;           
32     IFAPI_POLICYUTIL_STACK *prev;           
33 };
34 
35 TSS2_RC
36 ifapi_policyutil_execute_prepare(
37     FAPI_CONTEXT *context,
38     TPMI_ALG_HASH hash_alg,
39     TPMS_POLICY *policy);
40 
41 TSS2_RC
42 ifapi_policyutil_execute(
43     FAPI_CONTEXT *context,
44     ESYS_TR *session);
45 
46 #endif /* FAPI_POLICYUTIL_EXECUTE_H */

ifapi_profiles.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 
7 #ifndef IFAPI_PROFILES_H
8 #define IFAPI_PROFILES_H
9 
10 #include "ifapi_io.h"
11 #include "ifapi_policy_types.h"
12 
15 typedef struct IFAPI_PROFILE {
16     TPMI_ALG_PUBLIC                                type;    
17     char                                  *srk_template;    
18     char                                   *ek_template;    
19     char                               *srk_description;    
20     char                                *ek_description;    
21     TPMT_SIG_SCHEME                  ecc_signing_scheme;    
22     TPMT_SIG_SCHEME                  rsa_signing_scheme;    
23     TPMT_RSA_DECRYPT                 rsa_decrypt_scheme;    
24     TPMI_ALG_CIPHER_MODE                       sym_mode;    
25     TPMT_SYM_DEF_OBJECT                  sym_parameters;    
26     UINT16                               sym_block_size;    
27     TPML_PCR_SELECTION                    pcr_selection;    
28     TPMI_ALG_HASH                               nameAlg;
29     TPMI_RSA_KEY_BITS                           keyBits;
30     UINT32                                     exponent;
31     TPMI_ECC_CURVE                              curveID;
32     TPMT_SYM_DEF                      session_symmetric;
33     TPMS_POLICY                              *eh_policy;
34     TPMS_POLICY                              *sh_policy;
35     TPMS_POLICY                              *ek_policy;
36     TPMS_POLICY                             *srk_policy;
37     TPMS_POLICY                         *lockout_policy;
38     UINT32                                  newMaxTries;
39     UINT32                              newRecoveryTime;
40     UINT32                              lockoutRecovery;
41     TPMI_YES_NO                      ignore_ek_template;
42 } IFAPI_PROFILE;
43 
44 /* An entry for the dictionary of loaded profiles */
45 typedef struct IFAPI_PROFILE_ENTRY {
47     char *name;
49     struct IFAPI_PROFILE profile;
50 } IFAPI_PROFILE_ENTRY;
51 
52 typedef struct IFAPI_PROFILES {
53     char *default_name;
54     struct IFAPI_PROFILE default_profile;
55     /* Dictionary of loaded profiles */
56     struct IFAPI_PROFILE_ENTRY *profiles;
57     char **filenames;
58     /* Size of the loaded profiles dictionary */
59     size_t num_profiles;
60     size_t profiles_idx;
61 } IFAPI_PROFILES;
62 
63 TSS2_RC
64 ifapi_profiles_initialize_async(
65     IFAPI_PROFILES *profiles,
66     IFAPI_IO *io,
67     const char *profilesdir,
68     const char *defaultprofile);
69 
70 TSS2_RC
71 ifapi_profiles_initialize_finish(
72     IFAPI_PROFILES *profiles,
73     IFAPI_IO *io);
74 
75 TSS2_RC
76 ifapi_profiles_get(
77     const IFAPI_PROFILES *profiles,
78     const char *name,
79     const IFAPI_PROFILE **profile);
80 
81 void
82 ifapi_profiles_finalize(
83     IFAPI_PROFILES *profiles);
84 
85 #endif /* IFAPI_OBJECT_H */

tpm_json_deserialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef FAPI_TPM_JSON_DESERIALIZE_H
7 #define FAPI_TPM_JSON_DESERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "fapi_int.h"
15 #define YES 1
16 #define NO 0
17 
18 /* Deserialize according to the rules of parenttype and then filter against values
19    provided in the ... list. */
20 #define SUBTYPE_FILTER(type, parenttype, ...) \
21     TSS2_RC r; \
22     type tab[] = { __VA_ARGS__ }; \
23     type v; \
24     r = ifapi_json_ ## parenttype ## _deserialize(jso, &v); \
25     return_if_error(r, "Bad value"); \
26     for (size_t i = 0; i < sizeof(tab) / sizeof(tab[0]); i++) { \
27         if (v == tab[i]) { \
28             *out = v; \
29             return TSS2_RC_SUCCESS; \
30         } \
31     } \
32     LOG_ERROR("Bad sub-value"); \
33     return TSS2_FAPI_RC_BAD_VALUE;
34 
35 json_object*
36 ifapi_parse_json(const char *jstring) ;
37 
38 TSS2_RC
39 ifapi_hex_to_byte_ary(const char hex[], UINT32 vlen, BYTE val[]);
40 
41 TSS2_RC
42 ifapi_json_BYTE_array_deserialize(size_t max, json_object *jso, BYTE *out);
43 
44 TSS2_RC
45 ifapi_json_UINT8_ARY_deserialize(json_object *jso, UINT8_ARY *out);
46 
47 bool
48 ifapi_get_sub_object(json_object *jso, char *name, json_object **sub_jso);
49 
50 TSS2_RC
51 ifapi_json_BYTE_deserialize(json_object *jso, BYTE *out);
52 
53 TSS2_RC
54 ifapi_json_UINT16_deserialize(json_object *jso, UINT16 *out);
55 
56 TSS2_RC
57 ifapi_json_UINT32_deserialize(json_object *jso, UINT32 *out);
58 
59 TSS2_RC
60 ifapi_json_UINT64_deserialize(json_object *jso, UINT64 *out);
61 
62 TSS2_RC
63 ifapi_json_TPM2_GENERATED_deserialize(json_object *jso, TPM2_GENERATED *out);
64 
65 TSS2_RC
66 ifapi_json_TPM2_ALG_ID_deserialize(json_object *jso, TPM2_ALG_ID *out);
67 
68 TSS2_RC
69 ifapi_json_TPM2_ECC_CURVE_deserialize(json_object *jso, TPM2_ECC_CURVE *out);
70 
71 TSS2_RC
72 ifapi_json_TPM2_CC_deserialize(json_object *jso, TPM2_CC *out);
73 
74 TSS2_RC
75 ifapi_json_TPM2_EO_deserialize(json_object *jso, TPM2_EO *out);
76 
77 TSS2_RC
78 ifapi_json_TPM2_ST_deserialize(json_object *jso, TPM2_ST *out);
79 
80 TSS2_RC
81 ifapi_json_TPM2_PT_PCR_deserialize(json_object *jso, TPM2_PT_PCR *out);
82 
83 TSS2_RC
84 ifapi_json_TPM2_HANDLE_deserialize(json_object *jso, TPM2_HANDLE *out);
85 
86 TSS2_RC
87 ifapi_json_TPMA_OBJECT_deserialize(json_object *jso, TPMA_OBJECT *out);
88 
89 TSS2_RC
90 ifapi_json_TPMA_LOCALITY_deserialize(json_object *jso, TPMA_LOCALITY *out);
91 
92 TSS2_RC
93 ifapi_json_TPMA_ACT_deserialize(json_object *jso, TPMA_ACT *out);
94 
95 TSS2_RC
96 ifapi_json_TPMI_YES_NO_deserialize(json_object *jso, TPMI_YES_NO *out);
97 
98 TSS2_RC
99 ifapi_json_TPMI_RH_HIERARCHY_deserialize(json_object *jso,
100         TPMI_RH_HIERARCHY *out);
101 
102 TSS2_RC
103 ifapi_json_TPMI_RH_NV_INDEX_deserialize(json_object *jso,
104                                         TPMI_RH_NV_INDEX *out);
105 
106 TSS2_RC
107 ifapi_json_TPMI_ALG_HASH_deserialize(json_object *jso, TPMI_ALG_HASH *out);
108 
109 TSS2_RC
110 ifapi_json_TPMI_ALG_SYM_deserialize(json_object *jso, TPMI_ALG_SYM *out);
111 
112 TSS2_RC
113 ifapi_json_TPMI_ALG_SYM_OBJECT_deserialize(json_object *jso,
114         TPMI_ALG_SYM_OBJECT *out);
115 
116 TSS2_RC
117 ifapi_json_TPMI_ALG_CIPHER_MODE_deserialize(json_object *jso,
118         TPMI_ALG_CIPHER_MODE *out);
119 
120 TSS2_RC
121 ifapi_json_TPMI_ALG_SYM_MODE_deserialize(json_object *jso,
122         TPMI_ALG_SYM_MODE *out);
123 
124 TSS2_RC
125 ifapi_json_TPMI_ALG_KDF_deserialize(json_object *jso, TPMI_ALG_KDF *out);
126 
127 TSS2_RC
128 ifapi_json_TPMI_ALG_SIG_SCHEME_deserialize(json_object *jso,
129         TPMI_ALG_SIG_SCHEME *out);
130 
131 TSS2_RC
132 ifapi_json_TPMS_EMPTY_deserialize(json_object *jso, TPMS_EMPTY *out);
133 
134 TSS2_RC
135 ifapi_json_TPMU_HA_deserialize(UINT32 selector, json_object *jso, TPMU_HA *out);
136 
137 TSS2_RC
138 ifapi_json_TPMT_HA_deserialize(json_object *jso, TPMT_HA *out);
139 
140 TSS2_RC
141 ifapi_json_TPM2B_DIGEST_deserialize(json_object *jso, TPM2B_DIGEST *out);
142 
143 TSS2_RC
144 ifapi_json_TPM2B_DATA_deserialize(json_object *jso, TPM2B_DATA *out);
145 
146 TSS2_RC
147 ifapi_json_TPM2B_NONCE_deserialize(json_object *jso, TPM2B_NONCE *out);
148 
149 TSS2_RC
150 ifapi_json_TPM2B_OPERAND_deserialize(json_object *jso, TPM2B_OPERAND *out);
151 
152 TSS2_RC
153 ifapi_json_TPM2B_EVENT_deserialize(json_object *jso, TPM2B_EVENT *out);
154 
155 TSS2_RC
156 ifapi_json_TPM2B_MAX_NV_BUFFER_deserialize(json_object *jso,
157         TPM2B_MAX_NV_BUFFER *out);
158 
159 TSS2_RC
160 ifapi_json_TPM2B_NAME_deserialize(json_object *jso, TPM2B_NAME *out);
161 
162 TSS2_RC
163 ifapi_json_TPMS_PCR_SELECT_deserialize(json_object *jso, TPMS_PCR_SELECT *out);
164 
165 TSS2_RC
166 ifapi_json_TPMS_PCR_SELECTION_deserialize(json_object *jso,
167         TPMS_PCR_SELECTION *out);
168 
169 TSS2_RC
170 ifapi_json_TPMS_TAGGED_POLICY_deserialize(json_object *jso,
171         TPMS_TAGGED_POLICY *out);
172 
173 TSS2_RC
174 ifapi_json_TPMS_ACT_DATA_deserialize(json_object *jso,
175         TPMS_ACT_DATA *out);
176 
177 TSS2_RC
178 ifapi_json_TPMT_TK_CREATION_deserialize(json_object *jso,
179                                         TPMT_TK_CREATION *out);
180 
181 TSS2_RC
182 ifapi_json_TPML_DIGEST_VALUES_deserialize(json_object *jso,
183         TPML_DIGEST_VALUES *out);
184 
185 TSS2_RC
186 ifapi_json_TPML_PCR_SELECTION_deserialize(json_object *jso,
187         TPML_PCR_SELECTION *out);
188 
189 TSS2_RC
190 ifapi_json_TPMS_CLOCK_INFO_deserialize(json_object *jso, TPMS_CLOCK_INFO *out);
191 
192 TSS2_RC
193 ifapi_json_TPMS_TIME_INFO_deserialize(json_object *jso, TPMS_TIME_INFO *out);
194 
195 TSS2_RC
196 ifapi_json_TPMS_TIME_ATTEST_INFO_deserialize(json_object *jso,
197         TPMS_TIME_ATTEST_INFO *out);
198 
199 TSS2_RC
200 ifapi_json_TPMS_CERTIFY_INFO_deserialize(json_object *jso,
201         TPMS_CERTIFY_INFO *out);
202 
203 TSS2_RC
204 ifapi_json_TPMS_QUOTE_INFO_deserialize(json_object *jso, TPMS_QUOTE_INFO *out);
205 
206 TSS2_RC
207 ifapi_json_TPMS_COMMAND_AUDIT_INFO_deserialize(json_object *jso,
208         TPMS_COMMAND_AUDIT_INFO *out);
209 
210 TSS2_RC
211 ifapi_json_TPMS_SESSION_AUDIT_INFO_deserialize(json_object *jso,
212         TPMS_SESSION_AUDIT_INFO *out);
213 
214 TSS2_RC
215 ifapi_json_TPMS_CREATION_INFO_deserialize(json_object *jso,
216         TPMS_CREATION_INFO *out);
217 
218 TSS2_RC
219 ifapi_json_TPMS_NV_CERTIFY_INFO_deserialize(json_object *jso,
220         TPMS_NV_CERTIFY_INFO *out);
221 
222 TSS2_RC
223 ifapi_json_TPMI_ST_ATTEST_deserialize(json_object *jso, TPMI_ST_ATTEST *out);
224 
225 TSS2_RC
226 ifapi_json_TPMU_ATTEST_deserialize(UINT32 selector, json_object *jso,
227                                    TPMU_ATTEST *out);
228 
229 TSS2_RC
230 ifapi_json_TPMS_ATTEST_deserialize(json_object *jso, TPMS_ATTEST *out);
231 
232 TSS2_RC
233 ifapi_json_TPMI_AES_KEY_BITS_deserialize(json_object *jso,
234         TPMI_AES_KEY_BITS *out);
235 
236 TSS2_RC
237 ifapi_json_TPMU_SYM_KEY_BITS_deserialize(UINT32 selector, json_object *jso,
238         TPMU_SYM_KEY_BITS *out);
239 
240 TSS2_RC
241 ifapi_json_TPMU_SYM_MODE_deserialize(UINT32 selector, json_object *jso,
242                                      TPMU_SYM_MODE *out);
243 
244 TSS2_RC
245 ifapi_json_TPMT_SYM_DEF_deserialize(json_object *jso, TPMT_SYM_DEF *out);
246 
247 TSS2_RC
248 ifapi_json_TPMT_SYM_DEF_OBJECT_deserialize(json_object *jso,
249         TPMT_SYM_DEF_OBJECT *out);
250 
251 TSS2_RC
252 ifapi_json_TPMS_SYMCIPHER_PARMS_deserialize(json_object *jso,
253         TPMS_SYMCIPHER_PARMS *out);
254 
255 TSS2_RC
256 ifapi_json_TPMS_SCHEME_HASH_deserialize(json_object *jso,
257                                         TPMS_SCHEME_HASH *out);
258 
259 TSS2_RC
260 ifapi_json_TPMS_SCHEME_ECDAA_deserialize(json_object *jso,
261         TPMS_SCHEME_ECDAA *out);
262 
263 TSS2_RC
264 ifapi_json_TPMI_ALG_KEYEDHASH_SCHEME_deserialize(json_object *jso,
265         TPMI_ALG_KEYEDHASH_SCHEME *out);
266 
267 TSS2_RC
268 ifapi_json_TPMS_SCHEME_HMAC_deserialize(json_object *jso,
269                                         TPMS_SCHEME_HMAC *out);
270 
271 TSS2_RC
272 ifapi_json_TPMS_SCHEME_XOR_deserialize(json_object *jso, TPMS_SCHEME_XOR *out);
273 
274 TSS2_RC
275 ifapi_json_TPMU_SCHEME_KEYEDHASH_deserialize(UINT32 selector, json_object *jso,
276         TPMU_SCHEME_KEYEDHASH *out);
277 
278 TSS2_RC
279 ifapi_json_TPMT_KEYEDHASH_SCHEME_deserialize(json_object *jso,
280         TPMT_KEYEDHASH_SCHEME *out);
281 
282 TSS2_RC
283 ifapi_json_TPMS_SIG_SCHEME_RSASSA_deserialize(json_object *jso,
284         TPMS_SIG_SCHEME_RSASSA *out);
285 
286 TSS2_RC
287 ifapi_json_TPMS_SIG_SCHEME_RSAPSS_deserialize(json_object *jso,
288         TPMS_SIG_SCHEME_RSAPSS *out);
289 
290 TSS2_RC
291 ifapi_json_TPMS_SIG_SCHEME_ECDSA_deserialize(json_object *jso,
292         TPMS_SIG_SCHEME_ECDSA *out);
293 
294 TSS2_RC
295 ifapi_json_TPMS_SIG_SCHEME_SM2_deserialize(json_object *jso,
296         TPMS_SIG_SCHEME_SM2 *out);
297 
298 TSS2_RC
299 ifapi_json_TPMS_SIG_SCHEME_ECSCHNORR_deserialize(json_object *jso,
300         TPMS_SIG_SCHEME_ECSCHNORR *out);
301 
302 TSS2_RC
303 ifapi_json_TPMS_SIG_SCHEME_ECDAA_deserialize(json_object *jso,
304         TPMS_SIG_SCHEME_ECDAA *out);
305 
306 TSS2_RC
307 ifapi_json_TPMU_SIG_SCHEME_deserialize(UINT32 selector, json_object *jso,
308                                        TPMU_SIG_SCHEME *out);
309 
310 TSS2_RC
311 ifapi_json_TPMT_SIG_SCHEME_deserialize(json_object *jso, TPMT_SIG_SCHEME *out);
312 
313 TSS2_RC
314 ifapi_json_TPMS_ENC_SCHEME_OAEP_deserialize(json_object *jso,
315         TPMS_ENC_SCHEME_OAEP *out);
316 
317 TSS2_RC
318 ifapi_json_TPMS_ENC_SCHEME_RSAES_deserialize(json_object *jso,
319         TPMS_ENC_SCHEME_RSAES *out);
320 
321 TSS2_RC
322 ifapi_json_TPMS_KEY_SCHEME_ECDH_deserialize(json_object *jso,
323         TPMS_KEY_SCHEME_ECDH *out);
324 
325 TSS2_RC
326 ifapi_json_TPMS_SCHEME_MGF1_deserialize(json_object *jso,
327                                         TPMS_SCHEME_MGF1 *out);
328 
329 TSS2_RC
330 ifapi_json_TPMS_SCHEME_KDF1_SP800_56A_deserialize(json_object *jso,
331         TPMS_SCHEME_KDF1_SP800_56A *out);
332 
333 TSS2_RC
334 ifapi_json_TPMS_SCHEME_KDF1_SP800_108_deserialize(json_object *jso,
335         TPMS_SCHEME_KDF1_SP800_108 *out);
336 
337 TSS2_RC
338 ifapi_json_TPMU_KDF_SCHEME_deserialize(UINT32 selector, json_object *jso,
339                                        TPMU_KDF_SCHEME *out);
340 
341 TSS2_RC
342 ifapi_json_TPMT_KDF_SCHEME_deserialize(json_object *jso, TPMT_KDF_SCHEME *out);
343 
344 TSS2_RC
345 ifapi_json_TPMU_ASYM_SCHEME_deserialize(UINT32 selector, json_object *jso,
346                                         TPMU_ASYM_SCHEME *out);
347 
348 TSS2_RC
349 ifapi_json_TPMI_ALG_RSA_SCHEME_deserialize(json_object *jso,
350         TPMI_ALG_RSA_SCHEME *out);
351 
352 TSS2_RC
353 ifapi_json_TPMT_RSA_SCHEME_deserialize(json_object *jso, TPMT_RSA_SCHEME *out);
354 
355 TSS2_RC
356 ifapi_json_TPMI_ALG_RSA_DECRYPT_deserialize(json_object *jso,
357         TPMI_ALG_RSA_DECRYPT *out);
358 
359 TSS2_RC
360 ifapi_json_TPMT_RSA_DECRYPT_deserialize(json_object *jso,
361                                         TPMT_RSA_DECRYPT *out);
362 
363 TSS2_RC
364 ifapi_json_TPM2B_PUBLIC_KEY_RSA_deserialize(json_object *jso,
365         TPM2B_PUBLIC_KEY_RSA *out);
366 
367 TSS2_RC
368 ifapi_json_TPMI_RSA_KEY_BITS_deserialize(json_object *jso,
369         TPMI_RSA_KEY_BITS *out);
370 
371 TSS2_RC
372 ifapi_json_TPM2B_ECC_PARAMETER_deserialize(json_object *jso,
373         TPM2B_ECC_PARAMETER *out);
374 
375 TSS2_RC
376 ifapi_json_TPMS_ECC_POINT_deserialize(json_object *jso, TPMS_ECC_POINT *out);
377 
378 TSS2_RC
379 ifapi_json_TPMI_ALG_ECC_SCHEME_deserialize(json_object *jso,
380         TPMI_ALG_ECC_SCHEME *out);
381 
382 TSS2_RC
383 ifapi_json_TPMI_ECC_CURVE_deserialize(json_object *jso, TPMI_ECC_CURVE *out);
384 
385 TSS2_RC
386 ifapi_json_TPMT_ECC_SCHEME_deserialize(json_object *jso, TPMT_ECC_SCHEME *out);
387 
388 TSS2_RC
389 ifapi_json_TPMS_SIGNATURE_RSA_deserialize(json_object *jso,
390         TPMS_SIGNATURE_RSA *out);
391 
392 TSS2_RC
393 ifapi_json_TPMS_SIGNATURE_RSASSA_deserialize(json_object *jso,
394         TPMS_SIGNATURE_RSASSA *out);
395 
396 TSS2_RC
397 ifapi_json_TPMS_SIGNATURE_RSAPSS_deserialize(json_object *jso,
398         TPMS_SIGNATURE_RSAPSS *out);
399 
400 TSS2_RC
401 ifapi_json_TPMS_SIGNATURE_ECC_deserialize(json_object *jso,
402         TPMS_SIGNATURE_ECC *out);
403 
404 TSS2_RC
405 ifapi_json_TPMS_SIGNATURE_ECDSA_deserialize(json_object *jso,
406         TPMS_SIGNATURE_ECDSA *out);
407 
408 TSS2_RC
409 ifapi_json_TPMS_SIGNATURE_ECDAA_deserialize(json_object *jso,
410         TPMS_SIGNATURE_ECDAA *out);
411 
412 TSS2_RC
413 ifapi_json_TPMS_SIGNATURE_SM2_deserialize(json_object *jso,
414         TPMS_SIGNATURE_SM2 *out);
415 
416 TSS2_RC
417 ifapi_json_TPMS_SIGNATURE_ECSCHNORR_deserialize(json_object *jso,
418         TPMS_SIGNATURE_ECSCHNORR *out);
419 
420 TSS2_RC
421 ifapi_json_TPMU_SIGNATURE_deserialize(UINT32 selector, json_object *jso,
422                                       TPMU_SIGNATURE *out);
423 
424 TSS2_RC
425 ifapi_json_TPMT_SIGNATURE_deserialize(json_object *jso, TPMT_SIGNATURE *out);
426 
427 TSS2_RC
428 ifapi_json_TPM2B_ENCRYPTED_SECRET_deserialize(json_object *jso,
429         TPM2B_ENCRYPTED_SECRET *out);
430 
431 TSS2_RC
432 ifapi_json_TPMI_ALG_PUBLIC_deserialize(json_object *jso, TPMI_ALG_PUBLIC *out);
433 
434 TSS2_RC
435 ifapi_json_TPMU_PUBLIC_ID_deserialize(UINT32 selector, json_object *jso,
436                                       TPMU_PUBLIC_ID *out);
437 
438 TSS2_RC
439 ifapi_json_TPMS_KEYEDHASH_PARMS_deserialize(json_object *jso,
440         TPMS_KEYEDHASH_PARMS *out);
441 
442 TSS2_RC
443 ifapi_json_TPMS_RSA_PARMS_deserialize(json_object *jso, TPMS_RSA_PARMS *out);
444 
445 TSS2_RC
446 ifapi_json_TPMS_ECC_PARMS_deserialize(json_object *jso, TPMS_ECC_PARMS *out);
447 
448 TSS2_RC
449 ifapi_json_TPMU_PUBLIC_PARMS_deserialize(UINT32 selector, json_object *jso,
450         TPMU_PUBLIC_PARMS *out);
451 
452 TSS2_RC
453 ifapi_json_TPMT_PUBLIC_deserialize(json_object *jso, TPMT_PUBLIC *out);
454 
455 TSS2_RC
456 ifapi_json_TPM2B_PUBLIC_deserialize(json_object *jso, TPM2B_PUBLIC *out);
457 
458 TSS2_RC
459 ifapi_json_TPM2B_PRIVATE_deserialize(json_object *jso, TPM2B_PRIVATE *out);
460 
461 TSS2_RC
462 ifapi_json_TPM2_NT_deserialize(json_object *jso, TPM2_NT *out);
463 
464 TSS2_RC
465 ifapi_json_TPMA_NV_deserialize(json_object *jso, TPMA_NV *out);
466 
467 TSS2_RC
468 ifapi_json_TPMS_NV_PUBLIC_deserialize(json_object *jso, TPMS_NV_PUBLIC *out);
469 
470 TSS2_RC
471 ifapi_json_TPM2B_NV_PUBLIC_deserialize(json_object *jso, TPM2B_NV_PUBLIC *out);
472 
473 TSS2_RC
474 ifapi_json_TPMS_CREATION_DATA_deserialize(json_object *jso,
475         TPMS_CREATION_DATA *out);
476 
477 TSS2_RC
478 ifapi_json_TPM2B_CREATION_DATA_deserialize(json_object *jso,
479         TPM2B_CREATION_DATA *out);
480 
481 #endif /* FAPI_TPM_JSON_DESERIALIZE_H */

tpm_json_serialize.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 #ifndef FAPI_TPM_JSON_SERIALIZE_H
7 #define FAPI_TPM_JSON_SERIALIZE_H
8 
9 #include <stdbool.h>
10 #include <json-c/json.h>
11 #include <json-c/json_util.h>
12 
13 #include "tss2_tpm2_types.h"
14 #include "fapi_int.h"
15 
16 #define YES 1
17 #define NO 0
18 
19 #define CHECK_IN_LIST(type, needle, ...) \
20     type tab[] = { __VA_ARGS__ }; \
21     size_t i; \
22     for(i = 0; i < sizeof(tab) / sizeof(tab[0]); i++) \
23         if (needle == tab[i]) \
24             break; \
25     if (i == sizeof(tab) / sizeof(tab[0])) { \
26         LOG_ERROR("Bad value"); \
27         return TSS2_FAPI_RC_BAD_VALUE; \
28     }
29 
30 #define JSON_CLEAR(jso) \
31     if (jso) {                   \
32         json_object_put(jso); \
33     }
34 
35 #define return_if_jso_error(r,msg, jso)       \
36     if (r != TSS2_RC_SUCCESS) { \
37         LOG_ERROR("%s " TPM2_ERROR_FORMAT, msg, TPM2_ERROR_TEXT(r)); \
38         if (jso) {                                                   \
39             json_object_put(jso);                                    \
40         } \
41         return r;  \
42     }
43 
44 TSS2_RC
45 ifapi_json_TPM2_HANDLE_serialize(const TPM2_HANDLE in, json_object **jso);
46 
47 TSS2_RC
48 ifapi_json_UINT16_serialize(const UINT16 in, json_object **jso);
49 
50 TSS2_RC
51 ifapi_json_UINT32_serialize(const UINT32 in, json_object **jso);
52 
53 TSS2_RC
54 ifapi_json_INT32_serialize(const INT32 in, json_object **jso);
55 
56 TSS2_RC
57 ifapi_json_UINT64_serialize(const UINT64 in, json_object **jso);
58 
59 TSS2_RC
60 ifapi_json_TPM2_GENERATED_serialize(const TPM2_GENERATED in, json_object **jso);
61 
62 TSS2_RC
63 ifapi_json_TPM2_ALG_ID_serialize(const TPM2_ALG_ID in, json_object **jso);
64 
65 TSS2_RC
66 ifapi_json_TPM2_ECC_CURVE_serialize(const TPM2_ECC_CURVE in, json_object **jso);
67 
68 TSS2_RC
69 ifapi_json_TPM2_CC_serialize(const TPM2_CC in, json_object **jso);
70 
71 TSS2_RC
72 ifapi_json_TPM2_EO_serialize(const TPM2_EO in, json_object **jso);
73 
74 TSS2_RC
75 ifapi_json_TPM2_ST_serialize(const TPM2_ST in, json_object **jso);
76 
77 TSS2_RC
78 ifapi_json_TPM2_CAP_serialize(const TPM2_CAP in, json_object **jso);
79 
80 TSS2_RC
81 ifapi_json_TPM2_PT_serialize(const TPM2_PT in, json_object **jso);
82 
83 TSS2_RC
84 ifapi_json_TPM2_PT_PCR_serialize(const TPM2_PT_PCR in, json_object **jso);
85 
86 TSS2_RC
87 ifapi_json_TPMA_ALGORITHM_serialize(const TPMA_ALGORITHM in, json_object **jso);
88 
89 TSS2_RC
90 ifapi_json_TPMA_OBJECT_serialize(const TPMA_OBJECT in, json_object **jso);
91 
92 TSS2_RC
93 ifapi_json_TPMA_LOCALITY_serialize(const TPMA_LOCALITY in, json_object **jso);
94 
95 TSS2_RC
96 ifapi_json_TPMA_CC_serialize(const TPMA_CC in, json_object **jso);
97 
98 TSS2_RC
99 ifapi_json_TPMA_ACT_serialize(const TPMA_ACT in, json_object **jso);
100 
101 TSS2_RC
102 ifapi_json_TPMI_YES_NO_serialize(const TPMI_YES_NO in, json_object **jso);
103 
104 TSS2_RC
105 ifapi_json_TPMI_RH_HIERARCHY_serialize(const TPMI_RH_HIERARCHY in,
106                                        json_object **jso);
107 
108 TSS2_RC
109 ifapi_json_TPMI_RH_NV_INDEX_serialize(const TPMI_RH_NV_INDEX in,
110                                       json_object **jso);
111 
112 TSS2_RC
113 ifapi_json_TPMI_ALG_HASH_serialize(const TPMI_ALG_HASH in, json_object **jso);
114 
115 TSS2_RC
116 ifapi_json_TPMI_ALG_SYM_OBJECT_serialize(const TPMI_ALG_SYM_OBJECT in,
117         json_object **jso);
118 
119 TSS2_RC
120 ifapi_json_TPMI_ALG_SYM_MODE_serialize(const TPMI_ALG_SYM_MODE in,
121                                        json_object **jso);
122 
123 TSS2_RC
124 ifapi_json_TPMI_ALG_CIPHER_MODE_serialize(const TPMI_ALG_CIPHER_MODE in,
125                                           json_object **jso);
126 
127 TSS2_RC
128 ifapi_json_TPMI_ALG_KDF_serialize(const TPMI_ALG_KDF in, json_object **jso);
129 
130 TSS2_RC
131 ifapi_json_TPMI_ALG_SIG_SCHEME_serialize(const TPMI_ALG_SIG_SCHEME in,
132         json_object **jso);
133 
134 TSS2_RC
135 ifapi_json_TPMS_EMPTY_serialize(const TPMS_EMPTY *in, json_object **jso);
136 
137 TSS2_RC
138 ifapi_json_TPMU_HA_serialize(const TPMU_HA *in, UINT32 selector,
139                              json_object **jso);
140 
141 TSS2_RC
142 ifapi_json_TPMT_HA_serialize(const TPMT_HA *in, json_object **jso);
143 
144 TSS2_RC
145 ifapi_json_TPM2B_DIGEST_serialize(const TPM2B_DIGEST *in, json_object **jso);
146 
147 TSS2_RC
148 ifapi_json_TPM2B_DATA_serialize(const TPM2B_DATA *in, json_object **jso);
149 
150 TSS2_RC
151 ifapi_json_TPM2B_NONCE_serialize(const TPM2B_NONCE *in, json_object **jso);
152 
153 TSS2_RC
154 ifapi_json_TPM2B_OPERAND_serialize(const TPM2B_OPERAND *in, json_object **jso);
155 
156 TSS2_RC
157 ifapi_json_TPM2B_EVENT_serialize(const TPM2B_EVENT *in, json_object **jso);
158 
159 TSS2_RC
160 ifapi_json_TPM2B_MAX_NV_BUFFER_serialize(const TPM2B_MAX_NV_BUFFER *in,
161         json_object **jso);
162 
163 TSS2_RC
164 ifapi_json_TPM2B_NAME_serialize(const TPM2B_NAME *in, json_object **jso);
165 
166 TSS2_RC
167 ifapi_json_TPMS_PCR_SELECT_serialize(const TPMS_PCR_SELECT *in,
168                                      json_object **jso);
169 
170 TSS2_RC
171 ifapi_json_TPMS_PCR_SELECTION_serialize(const TPMS_PCR_SELECTION *in,
172                                         json_object **jso);
173 
174 TSS2_RC
175 ifapi_json_TPMT_TK_CREATION_serialize(const TPMT_TK_CREATION *in,
176                                       json_object **jso);
177 
178 TSS2_RC
179 ifapi_json_TPMS_ALG_PROPERTY_serialize(const TPMS_ALG_PROPERTY *in,
180                                        json_object **jso);
181 
182 TSS2_RC
183 ifapi_json_TPMS_TAGGED_PROPERTY_serialize(const TPMS_TAGGED_PROPERTY *in,
184         json_object **jso);
185 
186 TSS2_RC
187 ifapi_json_TPMS_TAGGED_PCR_SELECT_serialize(const TPMS_TAGGED_PCR_SELECT *in,
188         json_object **jso);
189 
190 TSS2_RC
191 ifapi_json_TPMS_TAGGED_POLICY_serialize(const TPMS_TAGGED_POLICY *in,
192                                         json_object **jso);
193 
194 TSS2_RC
195 ifapi_json_TPMS_ACT_DATA_serialize(const TPMS_ACT_DATA *in, json_object **jso);
196 
197 TSS2_RC
198 ifapi_json_TPML_CC_serialize(const TPML_CC *in, json_object **jso);
199 
200 TSS2_RC
201 ifapi_json_TPML_CCA_serialize(const TPML_CCA *in, json_object **jso);
202 
203 TSS2_RC
204 ifapi_json_TPML_HANDLE_serialize(const TPML_HANDLE *in, json_object **jso);
205 
206 TSS2_RC
207 ifapi_json_TPML_DIGEST_VALUES_serialize(const TPML_DIGEST_VALUES *in,
208                                         json_object **jso);
209 
210 TSS2_RC
211 ifapi_json_TPML_PCR_SELECTION_serialize(const TPML_PCR_SELECTION *in,
212                                         json_object **jso);
213 
214 TSS2_RC
215 ifapi_json_TPML_ALG_PROPERTY_serialize(const TPML_ALG_PROPERTY *in,
216                                        json_object **jso);
217 
218 TSS2_RC
219 ifapi_json_TPML_TAGGED_TPM_PROPERTY_serialize(const TPML_TAGGED_TPM_PROPERTY
220         *in, json_object **jso);
221 
222 TSS2_RC
223 ifapi_json_TPML_TAGGED_PCR_PROPERTY_serialize(const TPML_TAGGED_PCR_PROPERTY
224         *in, json_object **jso);
225 
226 TSS2_RC
227 ifapi_json_TPML_ECC_CURVE_serialize(const TPML_ECC_CURVE *in,
228                                     json_object **jso);
229 
230 TSS2_RC
231 ifapi_json_TPML_TAGGED_POLICY_serialize(const TPML_TAGGED_POLICY *in,
232                                         json_object **jso);
233 
234 TSS2_RC
235 ifapi_json_TPML_ACT_DATA_serialize(const TPML_ACT_DATA *in, json_object **jso);
236 
237 TSS2_RC
238 ifapi_json_TPMU_CAPABILITIES_serialize(const TPMU_CAPABILITIES *in,
239                                        UINT32 selector, json_object **jso);
240 
241 TSS2_RC
242 ifapi_json_TPMS_CAPABILITY_DATA_serialize(const TPMS_CAPABILITY_DATA *in,
243         json_object **jso);
244 
245 TSS2_RC
246 ifapi_json_TPMS_CLOCK_INFO_serialize(const TPMS_CLOCK_INFO *in,
247                                      json_object **jso);
248 
249 TSS2_RC
250 ifapi_json_TPMS_TIME_INFO_serialize(const TPMS_TIME_INFO *in,
251                                     json_object **jso);
252 
253 TSS2_RC
254 ifapi_json_TPMS_TIME_ATTEST_INFO_serialize(const TPMS_TIME_ATTEST_INFO *in,
255         json_object **jso);
256 
257 TSS2_RC
258 ifapi_json_TPMS_CERTIFY_INFO_serialize(const TPMS_CERTIFY_INFO *in,
259                                        json_object **jso);
260 
261 TSS2_RC
262 ifapi_json_TPMS_QUOTE_INFO_serialize(const TPMS_QUOTE_INFO *in,
263                                      json_object **jso);
264 
265 TSS2_RC
266 ifapi_json_TPMS_COMMAND_AUDIT_INFO_serialize(const TPMS_COMMAND_AUDIT_INFO *in,
267         json_object **jso);
268 
269 TSS2_RC
270 ifapi_json_TPMS_SESSION_AUDIT_INFO_serialize(const TPMS_SESSION_AUDIT_INFO *in,
271         json_object **jso);
272 
273 TSS2_RC
274 ifapi_json_TPMS_CREATION_INFO_serialize(const TPMS_CREATION_INFO *in,
275                                         json_object **jso);
276 
277 TSS2_RC
278 ifapi_json_TPMS_NV_CERTIFY_INFO_serialize(const TPMS_NV_CERTIFY_INFO *in,
279         json_object **jso);
280 
281 TSS2_RC
282 ifapi_json_TPMI_ST_ATTEST_serialize(const TPMI_ST_ATTEST in, json_object **jso);
283 
284 TSS2_RC
285 ifapi_json_TPMU_ATTEST_serialize(const TPMU_ATTEST *in, UINT32 selector,
286                                  json_object **jso);
287 
288 TSS2_RC
289 ifapi_json_TPMS_ATTEST_serialize(const TPMS_ATTEST *in, json_object **jso);
290 
291 TSS2_RC
292 ifapi_json_TPMI_AES_KEY_BITS_serialize(const TPMI_AES_KEY_BITS in,
293                                        json_object **jso);
294 
295 TSS2_RC
296 ifapi_json_TPMU_SYM_KEY_BITS_serialize(const TPMU_SYM_KEY_BITS *in,
297                                        UINT32 selector, json_object **jso);
298 
299 TSS2_RC
300 ifapi_json_TPMU_SYM_MODE_serialize(const TPMU_SYM_MODE *in, UINT32 selector,
301                                    json_object **jso);
302 
303 TSS2_RC
304 ifapi_json_TPMT_SYM_DEF_OBJECT_serialize(const TPMT_SYM_DEF_OBJECT *in,
305         json_object **jso);
306 
307 TSS2_RC
308 ifapi_json_TPMS_SYMCIPHER_PARMS_serialize(const TPMS_SYMCIPHER_PARMS *in,
309         json_object **jso);
310 
311 TSS2_RC
312 ifapi_json_TPMS_SCHEME_HASH_serialize(const TPMS_SCHEME_HASH *in,
313                                       json_object **jso);
314 
315 TSS2_RC
316 ifapi_json_TPMS_SCHEME_ECDAA_serialize(const TPMS_SCHEME_ECDAA *in,
317                                        json_object **jso);
318 
319 TSS2_RC
320 ifapi_json_TPMI_ALG_KEYEDHASH_SCHEME_serialize(const TPMI_ALG_KEYEDHASH_SCHEME
321         in, json_object **jso);
322 
323 TSS2_RC
324 ifapi_json_TPMS_SCHEME_HMAC_serialize(const TPMS_SCHEME_HMAC *in,
325                                       json_object **jso);
326 
327 TSS2_RC
328 ifapi_json_TPMS_SCHEME_XOR_serialize(const TPMS_SCHEME_XOR *in,
329                                      json_object **jso);
330 
331 TSS2_RC
332 ifapi_json_TPMU_SCHEME_KEYEDHASH_serialize(const TPMU_SCHEME_KEYEDHASH *in,
333         UINT32 selector, json_object **jso);
334 
335 TSS2_RC
336 ifapi_json_TPMT_KEYEDHASH_SCHEME_serialize(const TPMT_KEYEDHASH_SCHEME *in,
337         json_object **jso);
338 
339 TSS2_RC
340 ifapi_json_TPMS_SIG_SCHEME_RSASSA_serialize(const TPMS_SIG_SCHEME_RSASSA *in,
341         json_object **jso);
342 
343 TSS2_RC
344 ifapi_json_TPMS_SIG_SCHEME_RSAPSS_serialize(const TPMS_SIG_SCHEME_RSAPSS *in,
345         json_object **jso);
346 
347 TSS2_RC
348 ifapi_json_TPMS_SIG_SCHEME_ECDSA_serialize(const TPMS_SIG_SCHEME_ECDSA *in,
349         json_object **jso);
350 
351 TSS2_RC
352 ifapi_json_TPMS_SIG_SCHEME_SM2_serialize(const TPMS_SIG_SCHEME_SM2 *in,
353         json_object **jso);
354 
355 TSS2_RC
356 ifapi_json_TPMS_SIG_SCHEME_ECSCHNORR_serialize(const TPMS_SIG_SCHEME_ECSCHNORR
357         *in, json_object **jso);
358 
359 TSS2_RC
360 ifapi_json_TPMS_SIG_SCHEME_ECDAA_serialize(const TPMS_SIG_SCHEME_ECDAA *in,
361         json_object **jso);
362 
363 TSS2_RC
364 ifapi_json_TPMU_SIG_SCHEME_serialize(const TPMU_SIG_SCHEME *in, UINT32 selector,
365                                      json_object **jso);
366 
367 TSS2_RC
368 ifapi_json_TPMT_SIG_SCHEME_serialize(const TPMT_SIG_SCHEME *in,
369                                      json_object **jso);
370 
371 TSS2_RC
372 ifapi_json_TPMS_ENC_SCHEME_OAEP_serialize(const TPMS_ENC_SCHEME_OAEP *in,
373         json_object **jso);
374 
375 TSS2_RC
376 ifapi_json_TPMS_ENC_SCHEME_RSAES_serialize(const TPMS_ENC_SCHEME_RSAES *in,
377         json_object **jso);
378 
379 TSS2_RC
380 ifapi_json_TPMS_KEY_SCHEME_ECDH_serialize(const TPMS_KEY_SCHEME_ECDH *in,
381         json_object **jso);
382 
383 TSS2_RC
384 ifapi_json_TPMS_SCHEME_MGF1_serialize(const TPMS_SCHEME_MGF1 *in,
385                                       json_object **jso);
386 
387 TSS2_RC
388 ifapi_json_TPMS_SCHEME_KDF1_SP800_56A_serialize(const TPMS_SCHEME_KDF1_SP800_56A
389         *in, json_object **jso);
390 
391 TSS2_RC
392 ifapi_json_TPMS_SCHEME_KDF1_SP800_108_serialize(const TPMS_SCHEME_KDF1_SP800_108
393         *in, json_object **jso);
394 
395 TSS2_RC
396 ifapi_json_TPMU_KDF_SCHEME_serialize(const TPMU_KDF_SCHEME *in, UINT32 selector,
397                                      json_object **jso);
398 
399 TSS2_RC
400 ifapi_json_TPMT_KDF_SCHEME_serialize(const TPMT_KDF_SCHEME *in,
401                                      json_object **jso);
402 
403 TSS2_RC
404 ifapi_json_TPMI_ALG_ASYM_SCHEME_serialize(const TPMI_ALG_ASYM_SCHEME in,
405         json_object **jso);
406 
407 TSS2_RC
408 ifapi_json_TPMU_ASYM_SCHEME_serialize(const TPMU_ASYM_SCHEME *in,
409                                       UINT32 selector, json_object **jso);
410 
411 TSS2_RC
412 ifapi_json_TPMT_ASYM_SCHEME_serialize(const TPMT_ASYM_SCHEME *in,
413                                       json_object **jso);
414 
415 TSS2_RC
416 ifapi_json_TPMI_ALG_RSA_SCHEME_serialize(const TPMI_ALG_RSA_SCHEME in,
417         json_object **jso);
418 
419 TSS2_RC
420 ifapi_json_TPMT_RSA_SCHEME_serialize(const TPMT_RSA_SCHEME *in,
421                                      json_object **jso);
422 
423 TSS2_RC
424 ifapi_json_TPM2B_PUBLIC_KEY_RSA_serialize(const TPM2B_PUBLIC_KEY_RSA *in,
425         json_object **jso);
426 
427 TSS2_RC
428 ifapi_json_TPMI_RSA_KEY_BITS_serialize(const TPMI_RSA_KEY_BITS in,
429                                        json_object **jso);
430 
431 TSS2_RC
432 ifapi_json_TPM2B_ECC_PARAMETER_serialize(const TPM2B_ECC_PARAMETER *in,
433         json_object **jso);
434 
435 TSS2_RC
436 ifapi_json_TPMS_ECC_POINT_serialize(const TPMS_ECC_POINT *in,
437                                     json_object **jso);
438 
439 TSS2_RC
440 ifapi_json_TPMI_ALG_ECC_SCHEME_serialize(const TPMI_ALG_ECC_SCHEME in,
441         json_object **jso);
442 
443 TSS2_RC
444 ifapi_json_TPMI_ECC_CURVE_serialize(const TPMI_ECC_CURVE in, json_object **jso);
445 
446 TSS2_RC
447 ifapi_json_TPMT_ECC_SCHEME_serialize(const TPMT_ECC_SCHEME *in,
448                                      json_object **jso);
449 
450 TSS2_RC
451 ifapi_json_TPMS_SIGNATURE_RSA_serialize(const TPMS_SIGNATURE_RSA *in,
452                                         json_object **jso);
453 
454 TSS2_RC
455 ifapi_json_TPMS_SIGNATURE_RSASSA_serialize(const TPMS_SIGNATURE_RSASSA *in,
456         json_object **jso);
457 
458 TSS2_RC
459 ifapi_json_TPMS_SIGNATURE_RSAPSS_serialize(const TPMS_SIGNATURE_RSAPSS *in,
460         json_object **jso);
461 
462 TSS2_RC
463 ifapi_json_TPMS_SIGNATURE_ECC_serialize(const TPMS_SIGNATURE_ECC *in,
464                                         json_object **jso);
465 
466 TSS2_RC
467 ifapi_json_TPMS_SIGNATURE_ECDSA_serialize(const TPMS_SIGNATURE_ECDSA *in,
468         json_object **jso);
469 
470 TSS2_RC
471 ifapi_json_TPMS_SIGNATURE_ECDAA_serialize(const TPMS_SIGNATURE_ECDAA *in,
472         json_object **jso);
473 
474 TSS2_RC
475 ifapi_json_TPMS_SIGNATURE_SM2_serialize(const TPMS_SIGNATURE_SM2 *in,
476                                         json_object **jso);
477 
478 TSS2_RC
479 ifapi_json_TPMS_SIGNATURE_ECSCHNORR_serialize(const TPMS_SIGNATURE_ECSCHNORR
480         *in, json_object **jso);
481 
482 TSS2_RC
483 ifapi_json_TPMU_SIGNATURE_serialize(const TPMU_SIGNATURE *in, UINT32 selector,
484                                     json_object **jso);
485 
486 TSS2_RC
487 ifapi_json_TPMT_SIGNATURE_serialize(const TPMT_SIGNATURE *in,
488                                     json_object **jso);
489 
490 TSS2_RC
491 ifapi_json_TPM2B_ENCRYPTED_SECRET_serialize(const TPM2B_ENCRYPTED_SECRET *in,
492         json_object **jso);
493 
494 TSS2_RC
495 ifapi_json_TPMI_ALG_PUBLIC_serialize(const TPMI_ALG_PUBLIC in,
496                                      json_object **jso);
497 
498 TSS2_RC
499 ifapi_json_TPMU_PUBLIC_ID_serialize(const TPMU_PUBLIC_ID *in, UINT32 selector,
500                                     json_object **jso);
501 
502 TSS2_RC
503 ifapi_json_TPMS_KEYEDHASH_PARMS_serialize(const TPMS_KEYEDHASH_PARMS *in,
504         json_object **jso);
505 
506 TSS2_RC
507 ifapi_json_TPMS_RSA_PARMS_serialize(const TPMS_RSA_PARMS *in,
508                                     json_object **jso);
509 
510 TSS2_RC
511 ifapi_json_TPMS_ECC_PARMS_serialize(const TPMS_ECC_PARMS *in,
512                                     json_object **jso);
513 
514 TSS2_RC
515 ifapi_json_TPMU_PUBLIC_PARMS_serialize(const TPMU_PUBLIC_PARMS *in,
516                                        UINT32 selector, json_object **jso);
517 
518 TSS2_RC
519 ifapi_json_TPMT_PUBLIC_serialize(const TPMT_PUBLIC *in, json_object **jso);
520 
521 TSS2_RC
522 ifapi_json_TPM2B_PUBLIC_serialize(const TPM2B_PUBLIC *in, json_object **jso);
523 
524 TSS2_RC
525 ifapi_json_TPM2B_PRIVATE_serialize(const TPM2B_PRIVATE *in, json_object **jso);
526 
527 TSS2_RC
528 ifapi_json_TPM2_NT_serialize(const TPM2_NT in, json_object **jso);
529 
530 TSS2_RC
531 ifapi_json_TPMA_NV_serialize(const TPMA_NV in, json_object **jso);
532 
533 TSS2_RC
534 ifapi_json_TPMS_NV_PUBLIC_serialize(const TPMS_NV_PUBLIC *in,
535                                     json_object **jso);
536 
537 TSS2_RC
538 ifapi_json_TPM2B_NV_PUBLIC_serialize(const TPM2B_NV_PUBLIC *in,
539                                      json_object **jso);
540 
541 TSS2_RC
542 ifapi_json_TPMS_CREATION_DATA_serialize(const TPMS_CREATION_DATA *in,
543                                         json_object **jso);
544 
545 TSS2_RC
546 ifapi_json_TPM2B_CREATION_DATA_serialize(const TPM2B_CREATION_DATA *in,
547         json_object **jso);
548 
549 #endif /* FAPI_TPM_JSON_SERIALIZE_H */

Index
INDEX