Esys-Testing
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. More...

int | test_esys_evict_control_serialization (ESYS_CONTEXT *esys_context)
int | test_esys_lock (ESYS_CONTEXT *esys_context)
int | test_esys_get_capability (ESYS_CONTEXT *esys_context)
int | test_esys_zgen_2phase (ESYS_CONTEXT *esys_context)
int | test_esys_verify_signature (ESYS_CONTEXT *esys_context)
int | test_esys_import (ESYS_CONTEXT *esys_context)
int | test_esys_policy_regression (ESYS_CONTEXT *esys_context)
int | test_esys_policy_authorize_nv_opt (ESYS_CONTEXT *esys_context)
int | test_esys_policy_physical_presence_opt (ESYS_CONTEXT *esys_context)
int | test_esys_policy_template_opt (ESYS_CONTEXT *esys_context)
int | test_esys_policy_ticket (ESYS_CONTEXT *esys_context)
int | test_esys_change_eps (ESYS_CONTEXT *esys_context)
int | test_esys_policy_nv_undefine_special (ESYS_CONTEXT *esys_context)
int | test_esys_create_fail (ESYS_CONTEXT *esys_context)
int | test_esys_testparms (ESYS_CONTEXT *esys_context)
int | test_esys_create_password_auth (ESYS_CONTEXT *esys_context)
int | test_esys_stir_random (ESYS_CONTEXT *esys_context)
int | test_esys_clockset (ESYS_CONTEXT *esys_context)
int | test_esys_clear_control (ESYS_CONTEXT *esys_context)
int | test_esys_nv_ram_extend_index (ESYS_CONTEXT *esys_context)
int | test_esys_save_and_load_context (ESYS_CONTEXT *esys_context)
int | test_esys_encrypt_decrypt (ESYS_CONTEXT *esys_context)
int | test_esys_createloaded (ESYS_CONTEXT *esys_context)
int | test_esys_audit (ESYS_CONTEXT *esys_context)
int | test_esys_policy_password (ESYS_CONTEXT *esys_context)
int | test_esys_tpm_tests (ESYS_CONTEXT *esys_context)
int | test_esys_certify (ESYS_CONTEXT *esys_context)
int | test_esys_pcr_basic (ESYS_CONTEXT *esys_context)
int | test_esys_quote (ESYS_CONTEXT *esys_context)
int | test_esys_tr_getName_hierarchy (ESYS_CONTEXT *ectx)
int | test_esys_field_upgrade (ESYS_CONTEXT *esys_context)
int | test_esys_unseal_password_auth (ESYS_CONTEXT *esys_context)
int | test_esys_nv_ram_set_bits (ESYS_CONTEXT *esys_context)
int | test_esys_nv_certify (ESYS_CONTEXT *esys_context)
int | test_esys_ecdh_keygen (ESYS_CONTEXT *esys_context)
int | test_esys_tr_fromTpmPublic_key (ESYS_CONTEXT *ectx)
int | test_esys_ecdh_zgen (ESYS_CONTEXT *esys_context)
int | test_esys_certify_creation (ESYS_CONTEXT *esys_context)
int | test_esys_nv_ram_counter (ESYS_CONTEXT *esys_context)
int | test_esys_event_sequence_complete (ESYS_CONTEXT *esys_context)
int | test_esys_create_session_auth (ESYS_CONTEXT *esys_context)
int | test_esys_tr_fromTpmPublic_nv (ESYS_CONTEXT *ectx)
int | test_esys_create_primary_hmac (ESYS_CONTEXT *esys_context)
int | test_esys_firmware_read (ESYS_CONTEXT *esys_context)
int | test_esys_hmacsequencestart (ESYS_CONTEXT *esys_context)
int | test_esys_hmac (ESYS_CONTEXT *esys_context)
int | test_esys_ecc_parameters (ESYS_CONTEXT *esys_context)
int | test_esys_hierarchychangeauth (ESYS_CONTEXT *esys_context)
int | test_esys_pcr_auth_value (ESYS_CONTEXT *esys_context)
int | test_esys_nv_ram_ordinary_index (ESYS_CONTEXT *esys_context)
int | test_esys_duplicate (ESYS_CONTEXT *esys_context)
int | test_esys_rsa_encrypt_decrypt (ESYS_CONTEXT *esys_context)
int | test_esys_set_algorithm_set (ESYS_CONTEXT *esys_context)
int | test_esys_object_changeauth (ESYS_CONTEXT *esys_context)
int | test_esys_pp_commands (ESYS_CONTEXT *esys_context)
int | test_esys_clear (ESYS_CONTEXT *esys_context)
int | test_esys_policy_authorize (ESYS_CONTEXT *esys_context)
int | test_esys_get_time (ESYS_CONTEXT *esys_context)
int | test_esys_make_credential (ESYS_CONTEXT *esys_context)
int | test_esys_commit (ESYS_CONTEXT *esys_context)
int | test_esys_policy_nv_changeauth (ESYS_CONTEXT *esys_context)

## Detailed Description

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.

## Function Documentation

## test_esys_audit()

int test_esys_audit | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS audit commands.

First a key for signing the audit digest is computed. A audit session is started, and for the command GetCapability the command audit digest and the session audit digest is computed. (Esys_GetCommandAuditDigest, Esys_GetSessionAuditDigest). In the last test the audit hash alg is changed with Esys_SetCommandCodeAuditStatus.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_GetCapability() (M)
- Esys_GetCommandAuditDigest() (O)
- Esys_GetSessionAuditDigest() (M)
- Esys_SetCommandCodeAuditStatus() (O)
- Esys_StartAuthSession() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_certify()

int test_esys_certify | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the command Esys_Certify.

We create a RSA primary signing key which will be used as signing key and as object for the certify command.

Tested ESYS commands:

- Esys_Certify() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_certify_creation()

int test_esys_certify_creation | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the command Esys_CertifyCreation.

We create a RSA primary signing key which will be used as signing key and as object for the certify creation.

Tested ESYS commands:

- Esys_CertifyCreation() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_change_eps()

int test_esys_change_eps | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_ChangeEPS.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_ChangeEPS() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_clear()

int test_esys_clear | ( | ESYS_CONTEXT * | esys_context | ) |

Test of the ESYS function Esys_Clear.

Tested ESYS commands:

- Esys_Clear() (M)
- Esys_FlushContext() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_clear_control()

int test_esys_clear_control | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_ClearControl.

The clear command will be disabled and with Esys_Clear it will be checked whether clear is disabled.

Tested ESYS commands:

- Esys_Clear() (M)
- Esys_ClearControl() (M)

*Note: platform authorization needed.

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_clockset()

int test_esys_clockset | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_ClockSet and Esys_ReadClock.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_ClockRateAdjust() (M)
- Esys_ClockSet() (M)
- Esys_ReadClock() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_commit()

int test_esys_commit | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test Esys_Commit. based on an ECC key created with Esys_CreatePrimary Esys_Commit is called with a point from the primary key.

Tested ESYS commands:

- Esys_Commit() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_create_fail()

int test_esys_create_fail | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test password authentication.

We start by creating a primary key (Esys_CreatePrimary). Based in the primary several calls with NULL parameters, which should not be allowed, will be tested.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)

Used compiler defines: TEST_ECC

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_create_password_auth()

int test_esys_create_password_auth | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test password authentication for the ESYS command Create.

We start by creating a primary key (Esys_CreatePrimary). Based in the primary a second key with an password define in the sensitive area will be created. This key will be loaded and will be used as parent to create a third key. Password authentication will be used to create this key.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_Load() (M)

Used compiler defines: TEST_ECC

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_create_primary_hmac()

int test_esys_create_primary_hmac | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test Esys_CreatePrimary with hmac verification.

The test can be executed with RSA or ECC keys. ECC will be used if ECC is defined.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_ECC

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_create_session_auth()

int test_esys_create_session_auth | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test parameter encryption/decryption, session management, hmac computation, and session key generation.

We start by creating a primary key (Esys_CreatePrimary). The primary key will be used as tpmKey for Esys_StartAuthSession. Parameter encryption and decryption will be activated for the session. The session will be used to Create a second key by Eys_Create (with password) This key will be Loaded to and a third key will be created with the second key as parent key (Esys_Create). The type of encryptin can be selected by the compiler variables (-D option): TEST_XOR_OBFUSCATION or TEST_AES_ENCRYPTION. Secret exchange with a ECC key can be activated with the compiler variable -D TEST_ECC.

Tested ESYS commands:

- Esys_ContextLoad() (M)
- Esys_ContextSave() (M)
- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_Load() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_ECC, TEST_AES_ENCRYPTION, TEST_BOUND_SESSION TEST_XOR_OBFUSCATION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_createloaded()

int test_esys_createloaded | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS command CreateLoaded.

We start by creating a primary key (Esys_CreatePrimary). This primary key will be used as parent key for CreateLoaded.

Tested ESYS commands:

- Esys_CreateLoaded() (F)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_StartAuthSession() (M)
- Esys_TR_GetName() (M)
- Esys_TR_ReadPublic() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_duplicate()

int test_esys_duplicate | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS commands Duplicate and Rewrap.

We start by creating a primary key (Esys_CreatePrimary). This primary key will be used as parent key for the Duplicate command. A second primary key will be the parent key of the duplicated key. In the last step the key is rewrapped with the first primary key as parent key.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_Duplicate() (M)
- Esys_FlushContext() (M)
- Esys_Load() (M)
- Esys_PolicyAuthValue() (M)
- Esys_PolicyCommandCode() (M)
- Esys_PolicyGetDigest() (M)
- Esys_ReadPublic() (M)
- Esys_Rewrap() (O)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_ecc_parameters()

int test_esys_ecc_parameters | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_ECC_Parameters.

Tested ESYS commands:

- Esys_ECC_Parameters() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_ecdh_keygen()

int test_esys_ecdh_keygen | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test Esys_ECDH_KeyGen based on an ECC key created with Esys_CreatePrimary.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_ECDH_KeyGen() (M)
- Esys_FlushContext() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_ecdh_zgen()

int test_esys_ecdh_zgen | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test Esys_ECDH_ZGen. based on an ECC key created with Esys_CreatePrimary and a dummy ECC point.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_ECDH_ZGen() (M)
- Esys_FlushContext() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_encrypt_decrypt()

int test_esys_encrypt_decrypt | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS function Esys_EncryptDecrypt.

First a primary key is generated. This key will be uses as parent fo a symmetric key, which will be used to encrypt and decrypt a tpm2b. The result will be compared.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_EncryptDecrypt() (O)
- Esys_FlushContext() (M)
- Esys_Load() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_event_sequence_complete()

int test_esys_event_sequence_complete | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS commands HashSequenceStart, SequenceUpdate, and EventSequenceComplete.

Tested ESYS commands:

- Esys_EventSequenceComplete() (M)
- Esys_HashSequenceStart() (M)
- Esys_SequenceUpdate() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

< enforce event Sequence

## test_esys_evict_control_serialization()

int test_esys_evict_control_serialization | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test EvictControl and ESYS Serialization.

We start by creating a primary key (Esys_CreatePrimary). Based on this key a persistent object is created (Esys_EvictControl). The resource of this object will be serialized and deserialized with the corresponding ESYS functions (Esys_TR_Serialize, Esys_TR_Deserialize). To check whether the deserialization was successful a new object will be created with the handle returned by the deserialize function.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_EvictControl() (M)
- Esys_FlushContext() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_field_upgrade()

int test_esys_field_upgrade | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_FieldUpgradeStart and Esys_FieldUpgradeData.

Tested ESYS commands:

- Esys_FieldUpgradeData() (O)
- Esys_FieldUpgradeStart() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_firmware_read()

int test_esys_firmware_read | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_FirmwareRead.

Tested ESYS commands:

- Esys_FirmwareRead() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_get_capability()

int test_esys_get_capability | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS get capability command.

Tested ESYS commands:

- Esys_GetCapability() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_get_time()

int test_esys_get_time | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the GetTime command with password authentication.

We create a RSA primary signing key which will be used for signing.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_GetTime() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_hierarchychangeauth()

int test_esys_hierarchychangeauth | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the change of an authorization value of a hierarchy.

To check whether the change was successful a primary key is created with the handle of this hierarchy and the new authorization. Also second primary is created after a call of Esys_TR_SetAuth with the new auth value.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_HierarchyChangeAuth() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_hmac()

int test_esys_hmac | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS command Esys_HMAC with password authentication.

We create a symmetric HMAC key signing key which will be used for signing. This key will be used to create the HMAC for a test buffer.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_HMAC() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_hmacsequencestart()

int test_esys_hmacsequencestart | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS commands: HMAC_Start, SequenceUpdate, and SequenceComplete.

The HMAC key is created by using Esys_CreatePrimary.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_HMAC_Start() (M)
- Esys_SequenceComplete() (M)
- Esys_SequenceUpdate() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_import()

int test_esys_import | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS commands Duplicate and Import.

We start by creating a primary key (Esys_CreatePrimary). This primary key will be used as parent key for the Duplicate command. A second primary key will be the parent key of the duplicated key. In the last step the key is imported with the first primary key as parent key (Esys_Import).

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_Duplicate() (M)
- Esys_FlushContext() (M)
- Esys_Import() (M)
- Esys_Load() (M)
- Esys_PolicyAuthValue() (M)
- Esys_PolicyCommandCode() (M)
- Esys_PolicyGetDigest() (M)
- Esys_ReadPublic() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_lock()

int test_esys_lock | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS functions related to TPM locks.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_DictionaryAttackLockReset() (M)
- Esys_DictionaryAttackParameters() (M)
- Esys_NV_GlobalWriteLock() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_make_credential()

int test_esys_make_credential | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the function Esys_MakeCredential We start by creating a primary key (Esys_CreatePrimary).

Based in the primary a second key will be created. The public part of the key will be loaded by the function Esys_LoadExternal. A credential will be encrypted with this key with the command Esys_MakeCredential. The credential will be activated with Esys_ActivateCredential.

Tested ESYS commands:

- Esys_ActivateCredential() (M)
- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_Load() (M)
- Esys_LoadExternal() (M)
- Esys_MakeCredential() (M)
- Esys_ReadPublic() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_nv_certify()

int test_esys_nv_certify | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the command Esys_NV_Certify.

We create a RSA primary signing key which will be used as signing key for the NV data.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_NV_Certify() (O)
- Esys_NV_DefineSpace() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_NV_Write() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_nv_ram_counter()

int test_esys_nv_ram_counter | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the definition of a counter in NV ram and to test the ESYS NV_Increment function.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_DefineSpace() (M)
- Esys_NV_Increment() (M)
- Esys_NV_Read() (M)
- Esys_NV_ReadPublic() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_nv_ram_extend_index()

int test_esys_nv_ram_extend_index | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS nv define space, nv extend, and nv read command. The names stored in the ESYS resource are compared with the names delivered from the TPM by the command ReadPublic.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_DefineSpace() (M)
- Esys_NV_Extend() (M)
- Esys_NV_Read() (M)
- Esys_NV_ReadPublic() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_nv_ram_ordinary_index()

int test_esys_nv_ram_ordinary_index | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS commands nv define space, nv write, nv read command, nv lock write and nv lock read, and nv undefine.

The names stored in the ESYS resource are compared with the names delivered from the TPM by the command ReadPublic. only one of the tests NV_ReadLock and NV_WriteLock can be activated by the defines TEST_READ_LOCK and TEST_WRITE_LOCK (-D option)

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_DefineSpace() (M)
- Esys_NV_Read() (M)
- Esys_NV_ReadLock() (M)
- Esys_NV_ReadPublic() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_NV_Write() (M)
- Esys_NV_WriteLock() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_READ_LOCK TEST_SESSION TEST_WRITE_LOCK

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_nv_ram_set_bits()

int test_esys_nv_ram_set_bits | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the definition of a bit field in NV ram and to test the ESYS NV_SetBits function.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_DefineSpace() (M)
- Esys_NV_Read() (M)
- Esys_NV_ReadPublic() (M)
- Esys_NV_SetBits() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_StartAuthSession() (M)

Used compiler defines: TEST_SESSION

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_object_changeauth()

int test_esys_object_changeauth | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS command ObjectChangeAuth.

We start by creating a primary key (Esys_CreatePrimary). The auth value for this primary will be changed.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_Load() (M)
- Esys_ObjectChangeAuth() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_pcr_auth_value()

int test_esys_pcr_auth_value | ( | ESYS_CONTEXT * | esys_context | ) |

Test the commands Esys_PCR_SetAuthValue and Esys_PCR_SetAuthPolicy.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_PCR_SetAuthPolicy() (O)
- Esys_PCR_SetAuthValue() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_pcr_basic()

int test_esys_pcr_basic | ( | ESYS_CONTEXT * | esys_context | ) |

Test the basic commands for PCR processing.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_PCR_Allocate() (M)
- Esys_PCR_Event() (M)
- Esys_PCR_Extend() (M)
- Esys_PCR_Read() (M)
- Esys_PCR_Reset() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_policy_authorize()

int test_esys_policy_authorize | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS policy authorization.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_PolicyAuthorize() (M)
- Esys_PolicyGetDigest() (M)
- Esys_ReadPublic() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_policy_authorize_nv_opt()

int test_esys_policy_authorize_nv_opt | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS policy commands, not tested in other test cases. When possoble the commands are tested with a trial session and the policy digest is compared with the expected digest.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_DefineSpace() (M)
- Esys_PolicyAuthorizeNV() (F)
- Esys_PolicyNV() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_policy_nv_changeauth()

int test_esys_policy_nv_changeauth | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS commands PolicyAuthValue, PolicyCommandCode, Esys_PolicyGetDigest, and NV_ChangeAuth.

First in a trial session the policy value to ensure that the auth value is included in the policy session used for NV_ChangeAuth is computed. A NV ram space with this policy is defined afterwards. With a real policy session the auth value of this NV ram space will be changed.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_ChangeAuth() (M)
- Esys_NV_DefineSpace() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_PolicyAuthValue() (M)
- Esys_PolicyCommandCode() (M)
- Esys_PolicyGetDigest() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_policy_nv_undefine_special()

int test_esys_policy_nv_undefine_special | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS command Esys_NV_UndefineSpaceSpecial, The NV space attributes TPMA_NV_PLATFORMCREATE and TPMA_NV_POLICY_DELETE have to be set.

A policy has to be defined for the command UndefineSpaceSpecial. The special handling whether the auth value is not used in the HMAC response verification will be checked.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_DefineSpace() (M)
- Esys_NV_UndefineSpaceSpecial() (M)
- Esys_PolicyAuthValue() (M)
- Esys_PolicyCommandCode() (M)
- Esys_PolicyGetDigest() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

< Undefine will only possible with policy

## test_esys_policy_password()

int test_esys_policy_password | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS command PolicyPassword.

First in a trial session the policy value to ensure that auth value is included in the policy session used for authorization is computed. We start by creating a primary key (Esys_CreatePrimary) with this policy value and a certain authorization. Than a second key it created with a PoliyPassword policy session.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_PolicyGetDigest() (M)
- Esys_PolicyPassword() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_policy_physical_presence_opt()

int test_esys_policy_physical_presence_opt | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS policy commands, not tested in other test cases. When possoble the commands are tested with a trial session and the policy digest is compared with the expected digest.

Tested ESYS commands:

- Esys_PolicyPhysicalPresence() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_policy_regression()

int test_esys_policy_regression | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS policy commands, not tested in other test cases. When possoble the commands are tested with a trial session and the policy digest is compared with the expected digest.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_NV_DefineSpace() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_PolicyCounterTimer() (M)
- Esys_PolicyDuplicationSelect() (M)
- Esys_PolicyGetDigest() (M)
- Esys_PolicyNV() (M)
- Esys_PolicyNameHash() (M)
- Esys_PolicyNvWritten() (M)
- Esys_PolicyOR() (M)
- Esys_PolicyPCR() (M)
- Esys_PolicyPhysicalPresence() (O)
- Esys_PolicyRestart() (M)
- Esys_SetPrimaryPolicy() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_policy_template_opt()

int test_esys_policy_template_opt | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS policy commands, not tested in other test cases. When possoble the commands are tested with a trial session and the policy digest is compared with the expected digest.

Tested ESYS commands:

- Esys_FlushContext() (M)
- Esys_PolicyTemplate() (F)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_policy_ticket()

int test_esys_policy_ticket | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS policy commands related to signed authorization actions.

Esys_PolicySigned, Esys_PolicyTicket, and Esys_PolicySecret.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_HashSequenceStart() (M)
- Esys_PolicySecret() (M)
- Esys_PolicySigned() (M)
- Esys_PolicyTicket() (O)
- Esys_ReadPublic() (M)
- Esys_SequenceComplete() (M)
- Esys_SequenceUpdate() (M)
- Esys_Sign() (M)
- Esys_StartAuthSession() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_pp_commands()

int test_esys_pp_commands | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_PP_Commands.

If the test requires physical presence, the test is skipped.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_PP_Commands() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_quote()

int test_esys_quote | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the quote command with password authentication.

We create a RSA primary signing key which will be used for signing.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_Quote() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_rsa_encrypt_decrypt()

int test_esys_rsa_encrypt_decrypt | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test RSA encryption / decryption. with password authentication. We create a RSA primary key (Esys_CreatePrimary) for every crypto action This key will be used for encryption/decryption in with the schemes: TPM2_ALG_NULL, TPM2_ALG_RSAES, and TPM2_ALG_OAEP

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_RSA_Decrypt() (M)
- Esys_RSA_Encrypt() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_save_and_load_context()

int test_esys_save_and_load_context | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test context save and load.

We start by creating a primary key (Esys_CreatePrimary). Based in the primary a second key with an password define in the sensitive area will be created. This key will be loaded and saved with the ContextSave command. After the key is flushed the key will be loaded again with ContextLoad and will be used to create a third key

Tested ESYS commands:

- Esys_ContextLoad() (M)
- Esys_ContextSave() (M)
- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_Load() (M)

Used compiler defines: TEST_ECC

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_set_algorithm_set()

int test_esys_set_algorithm_set | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_SetAlgorithmSet.

Note: platform authorization needed.

Tested ESYS commands:

- Esys_SetAlgorithmSet() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |

## test_esys_stir_random()

int test_esys_stir_random | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_StirRandom.

Tested ESYS commands:

- Esys_StirRandom() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_testparms()

int test_esys_testparms | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS function Esys_TestParms.

Tested ESYS commands:

- Esys_TestParms() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_tpm_tests()

int test_esys_tpm_tests | ( | ESYS_CONTEXT * | esys_context | ) |

Test the ESYS functions for TPM tests.

Tested ESYS commands:

- Esys_GetTestResult() (M)
- Esys_IncrementalSelfTest() (M)
- Esys_SelfTest() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_tr_fromTpmPublic_key()

int test_esys_tr_fromTpmPublic_key | ( | ESYS_CONTEXT * | ectx | ) |

This tests the Esys_TR_FromTPMPublic and Esys_TR_GetName functions by creating an NV Index and then attempting to retrieve an ESYS_TR object for it. Then we call Esys_TR_GetName to see if the correct public name has been retrieved.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_EvictControl() (M)
- Esys_FlushContext() (M)
- Esys_ReadPublic() (M)

Parameters

  [in,out] | ectx | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_tr_fromTpmPublic_nv()

int test_esys_tr_fromTpmPublic_nv | ( | ESYS_CONTEXT * | ectx | ) |

This tests the Esys_TR_FromTPMPublic and Esys_TR_GetName functions by creating an NV Index and then attempting to retrieve an ESYS_TR object for it. Then we call Esys_TR_GetName to see if the correct public name has been retrieved.

Tested ESYS commands:

- Esys_NV_DefineSpace() (M)
- Esys_NV_ReadPublic() (M)
- Esys_NV_UndefineSpace() (M)
- Esys_TR_FromTPMPublic() (M)

Parameters

  [in,out] | ectx | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_tr_getName_hierarchy()

int test_esys_tr_getName_hierarchy | ( | ESYS_CONTEXT * | ectx | ) |

This tests the Esys_TR_FromTPMPublic and Esys_TR_GetName functions by creating an NV Index and then attempting to retrieve an ESYS_TR object for it. Then we call Esys_TR_GetName to see if the correct public name has been retrieved.

Tested ESYS commands:

Parameters

  [in,out] | ectx | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_unseal_password_auth()

int test_esys_unseal_password_auth | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the unseal operation for the ESYS command Unseal.

We start by creating a primary key (Esys_CreatePrimary). Based on the primary key a second key with a password and the to be sealed data defined in the sensitive area will be created (Esys_Create). This key will be loaded and the unseal command (Esys_Unseal) will be used to retrieve the sealed data.

Tested ESYS commands:

- Esys_Create() (M)
- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_Load() (M)
- Esys_Unseal() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_verify_signature()

int test_esys_verify_signature | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test the ESYS signing and signature verification.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_FlushContext() (M)
- Esys_ReadPublic() (M)
- Esys_Sign() (M)
- Esys_VerifySignature() (M)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_esys_zgen_2phase()

int test_esys_zgen_2phase | ( | ESYS_CONTEXT * | esys_context | ) |

This test is intended to test Esys_ECDH_ZGen.

The test is based on an ECC key created with Esys_CreatePrimary and data produced by the command Esys_EC_Ephemeral.

Tested ESYS commands:

- Esys_CreatePrimary() (M)
- Esys_ECDH_ZGen() (M)
- Esys_EC_Ephemeral() (F)
- Esys_FlushContext() (M)
- Esys_StartAuthSession() (M)
- Esys_ZGen_2Phase() (O)

Parameters

  [in,out] | esys_context | The ESYS_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SKIP |
  EXIT_SUCCESS |