Fapi-Testing
Testing

## Functions

int | test_fapi_data_crypt (FAPI_CONTEXT *context)
int | test_fapi_duplicate (FAPI_CONTEXT *context)
int | test_fapi_ext_public_key (FAPI_CONTEXT *context)
int | test_fapi_get_random (FAPI_CONTEXT *context)
int | test_fapi_info (FAPI_CONTEXT *context)
int | test_fapi_key_change_auth (FAPI_CONTEXT *context)
int | test_fapi_key_create_ckda_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_policies_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_policy_authorize_nv (FAPI_CONTEXT *context)
int | test_fapi_key_create_policy_authorize_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_policy_nv_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_policy_or_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_policy_pcr_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_policy_secret_nv_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_policy_signed (FAPI_CONTEXT *context)
int | test_fapi_key_create_sign (FAPI_CONTEXT *context)
int | test_fapi_key_create_sign_password_provision (FAPI_CONTEXT *context)
int | test_fapi_key_create_sign_policy_provision (FAPI_CONTEXT *context)
int | test_fapi_nv_extend (FAPI_CONTEXT *context)
int | test_fapi_nv_increment (FAPI_CONTEXT *context)
int | test_fapi_nv_ordinary (FAPI_CONTEXT *context)
int | test_fapi_nv_set_bits (FAPI_CONTEXT *context)
int | test_fapi_nv_written_policy (FAPI_CONTEXT *context)
int | test_fapi_pcr_test (FAPI_CONTEXT *context)
int | test_fapi_platform_certificates (FAPI_CONTEXT *context)
int | test_fapi_quote (FAPI_CONTEXT *context)
int | test_fapi_unseal (FAPI_CONTEXT *context)

## Detailed Description

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

## Function Documentation

## test_fapi_data_crypt()

int test_fapi_data_crypt | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for encryption and decryption.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateKey()
- Fapi_SetSignCB()
- Fapi_Encrypt()
- Fapi_Decrypt()
- Fapi_Free()

Tested Policies:

- PolicySigned

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_duplicate()

int test_fapi_duplicate | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for key duplication.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateKey()
- Fapi_ExportKey()
- Fapi_Delete()

Tested Policies:

- PolicyDuplicationSelect

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_ext_public_key()

int test_fapi_ext_public_key | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions use an external public key for signature and quote verify without TPM.

Tested FAPI commands:

- Fapi_Import()
- Fapi_VerifySignature()
- Fapi_SetCertificate()
- Fapi_GetCertificate()
- Fapi_List()
- Fapi_VerifyQuote()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_get_random()

int test_fapi_get_random | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI function FAPI_GetRandom and async invocations.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_GetRandom_Async()
- Fapi_GetRandom_Finish()
- Fapi_GetPollHandles()
- Fapi_GetRandom()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_info()

int test_fapi_info | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for GetInfo.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_GetInfo()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_change_auth()

int test_fapi_key_change_auth | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI function for changing key authorizations.

The setting of the authorization callback and usage of the key with Fapi_Sign afterwards is also tested.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateKey()
- Fapi_ChangeAuth()
- Fapi_SetAuthCB()
- Fapi_Sign()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_ckda_sign()

int test_fapi_key_create_ckda_sign | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for key creation and usage with noda and da flag.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateKey()
- Fapi_SetAuthCB()
- Fapi_Sign()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_policies_sign()

int test_fapi_key_create_policies_sign | ( | FAPI_CONTEXT * | context | ) |

Test several FAPI policies by usage of signing key.

Which test case will be executed is determined by the compiler switches: TEST_POLICY_PASSWORD, TEST_POLICY_AUTH_VALUE, TEST_POLICY_LOCALITY TEST_POLICY_PHYSICAL_PRESENCE, TEST_POLICY_COMMAND_CODE, TEST_POLICY_COUNTERTIMER.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateKey()
- Fapi_SetAuthCB()
- Fapi_Sign()
- Fapi_Delete()

Tested Policies:

- PolicyPassword
- PolicyAuthValue
- PolicyLocality
- PolicyPhysicalPresence
- PolicyCommandCode
- PolicyCounterTimer

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_policy_authorize_sign()

int test_fapi_key_create_policy_authorize_sign | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for PolicyAuthoirze with signing.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_SetBranchCB()
- Fapi_Import()
- Fapi_CreateKey()
- Fapi_AuthorizePolicy()
- Fapi_Sign()
- Fapi_List()
- Fapi_Delete()

Tested Policies:

- PolicyNameHash
- PolicyAuthorize
- PolicyCpHash (Not entered, only as alternative branch)

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_policy_nv_sign()

int test_fapi_key_create_policy_nv_sign | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for NV writing and key usage.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateKey()
- Fapi_NvWrite()
- Fapi_Import()
- Fapi_Sign()
- Fapi_Delete()

Tested Policies:

- PolicyNv

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_policy_or_sign()

int test_fapi_key_create_policy_or_sign | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI for PolicyOr using signing.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateKey()
- Fapi_SetBranchCB()
- Fapi_Sign()
- Fapi_Delete()

Tested Policies:

- PolicyOr
- PolicyPcr

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_policy_pcr_sign()

int test_fapi_key_create_policy_pcr_sign | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for PolicyPCR with key creation and usage.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateKey()
- Fapi_Sign()
- Fapi_ExportPolicy()
- Fapi_Delete()
- Fapi_Import()
- Fapi_List()

Tested Policies:

- PolicyPcr (with currentPCRs set)

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_policy_secret_nv_sign()

int test_fapi_key_create_policy_secret_nv_sign | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI PolicySecret and PolicyAuthValue handling.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateNv()
- Fapi_CreateKey()
- Fapi_Sign()
- Fapi_SetAuthCB()
- Fapi_Delete()

Tested Policies:

- PolicySecret
- PolicyAuthValue

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_policy_signed()

int test_fapi_key_create_policy_signed | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for key creation and usage with a PolicySigned.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateKey()
- Fapi_SetSignCB()
- Fapi_Sign()
- Fapi_Delete()
- Fapi_List()

Tested Policies:

- PolicySigned

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_sign()

int test_fapi_key_create_sign | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for TpmBlobs and certificates.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_SetAuthCB()
- Fapi_CreateKey()
- Fapi_GetTpmBlobs()
- Fapi_Sign()
- Fapi_VerifySignature()
- Fapi_SetCertificate()
- Fapi_List()
- Fapi_ChangeAuth()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_sign_password_provision()

int test_fapi_key_create_sign_password_provision | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for key creation and usage with an SH password.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_SetAuthCB()
- Fapi_CreateKey()
- Fapi_GetTpmBlobs()
- Fapi_Sign()
- Fapi_SetCertificate()
- Fapi_List()
- Fapi_ChangeAuth()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_key_create_sign_policy_provision()

int test_fapi_key_create_sign_policy_provision | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for key creation and usage.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_SetAuthCB()
- Fapi_CreateKey()
- Fapi_GetTpmBlobs()
- Fapi_Sign()
- Fapi_SetCertificate()
- Fapi_List()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_nv_extend()

int test_fapi_nv_extend | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI function FAPI_NvExtend.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateNv()
- Fapi_NvExtend()
- Fapi_Delete()
- Fapi_SetAuthCB()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_nv_increment()

int test_fapi_nv_increment | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI function FAPI_NvIncrement.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_CreateNv()
- Fapi_SetAuthCB()
- Fapi_ChangeAuth()
- Fapi_Delete()
- Fapi_NvIncrement()

Tested Policies:

- PolicyAuthValue
- PolicyCommandCode

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_nv_ordinary()

int test_fapi_nv_ordinary | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI NV functions.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_Import()
- Fapi_SetPolicyActionCB()
- Fapi_CreateNv()
- Fapi_NvWrite()
- Fapi_NvRead()
- Fapi_Delete()
- Fapi_SetDescription()
- Fapi_GetDescription()
- Fapi_SetAuthCB()

Tested Policies:

- PolicyAction

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_nv_set_bits()

int test_fapi_nv_set_bits | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI function Fapi_NvSetBits.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateNv()
- Fapi_NvSetBits()
- Fapi_Delete()
- Fapi_SetAuthCB()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_nv_written_policy()

int test_fapi_nv_written_policy | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI policy PolicyNvWritten.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateNv()
- Fapi_SetAppData()
- Fapi_GetAppData()
- Fapi_NvWrite()
- Fapi_Delete()

Tested Policies:

- PolicyNvWritten

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_pcr_test()

int test_fapi_pcr_test | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI function FAPI_PcrExtend and Read.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_PcrExtend()
- Fapi_PcrRead()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_platform_certificates()

int test_fapi_platform_certificates | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for platform certificates.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_GetPlatformCertificates()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_quote()

int test_fapi_quote | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for quote commands.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateKey()
- Fapi_PcrExtend()
- Fapi_Quote()
- Fapi_ExportKey()
- Fapi_Import()
- Fapi_PcrRead()
- Fapi_VerifyQuote()
- Fapi_List()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |

## test_fapi_unseal()

int test_fapi_unseal | ( | FAPI_CONTEXT * | context | ) |

Test the FAPI functions for sealing.

Tested FAPI commands:

- Fapi_Provision()
- Fapi_CreateSeal()
- Fapi_Unseal()
- Fapi_Delete()

Parameters

  [in,out] | context | The FAPI_CONTEXT.

Return values

  EXIT_FAILURE |
  EXIT_SUCCESS |