TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
attest_token_test_values.h File Reference

Expected values for test suite. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TOKEN_TEST_NONCE_BYTES
 
#define TOKEN_TEST_VALUE_NONCE
 
#define TOKEN_TEST_REQUIRE_NONCE   true /* Mandatory claim */
 
#define TOKEN_TEST_VALUE_UEID   NULL_Q_USEFUL_BUF_C
 
#define TOKEN_TEST_REQUIRE_UEID   true /* Mandatory claim */
 
#define TOKEN_TEST_VALUE_BOOT_SEED   NULL_Q_USEFUL_BUF_C
 
#define TOKEN_TEST_VALUE_HW_VERSION   NULL
 
#define TOKEN_TEST_VALUE_IMPLEMENTATION_ID   NULL_Q_USEFUL_BUF_C
 
#define TOKEN_TEST_VALUE_PROFILE_DEFINITION   NULL
 
#define TOKEN_TEST_VALUE_ORIGINATION   NULL
 
#define TOKEN_TEST_VALUE_SECURITY_LIFECYCLE   INT32_MAX
 
#define TOKEN_TEST_REQUIRE_BOOT_SEED   true /* Mandatory claim */
 
#define TOKEN_TEST_REQUIRE_HW_VERSION   false /* Optional claim */
 
#define TOKEN_TEST_REQUIRE_IMPLEMENTATION_ID   true /* Mandatory claim */
 
#define TOKEN_TEST_REQUIRE_PROFILE_DEFINITION   false /* Optional field */
 
#define TOKEN_TEST_REQUIRE_ORIGINATION   false /* Optional field */
 
#define TOKEN_TEST_REQUIRE_SECURITY_LIFECYCLE   true /* Mandatory claim */
 
#define TOKEN_TEST_VALUE_CLIENT_ID   0 /* Invalid value to trigger check */
 
#define TOKEN_TEST_REQUIRE_CLIENT_ID   true /* Mandatory claim */
 
#define TOKEN_TEST_REQUIRED_NUM_SWC   0
 
#define TOKEN_TEST_VALUE_SWC1_MEASUREMENT_TYPE   NULL /* Value not checked */
 
#define TOKEN_TEST_REQUIRE_SWC1_MEASUREMENT_TYPE   false /* Optional field */
 
#define TOKEN_TEST_VALUE_SWC1_MEASUREMENT_VAL   NULL_Q_USEFUL_BUF_C
 
#define TOKEN_TEST_REQUIRE_SWC1_MEASUREMENT_VAL   true /* Mandatory field */
 
#define TOKEN_TEST_VALUE_SWC1_VERSION   NULL /* Value not checked */
 
#define TOKEN_TEST_REQUIRE_SWC1_VERSION   true /* Mandatory field */
 
#define TOKEN_TEST_VALUE_SWC1_SIGNER_ID   NULL_Q_USEFUL_BUF_C
 
#define TOKEN_TEST_REQUIRE_SWC1_SIGNER_ID   true /* Mandatory field */
 
#define TOKEN_TEST_VALUE_SWC1_MEASUREMENT_DESC   "SHA256" /* Hard-coded value */
 
#define TOKEN_TEST_REQUIRE_SWC1_MEASUREMENT_DESC   false /* Optional field */
 
#define TOKEN_TEST_VALUE_SWC2_MEASUREMENT_TYPE   NULL /* Value not checked */
 
#define TOKEN_TEST_REQUIRE_SWC2_MEASUREMENT_TYPE   false /* Optional field */
 
#define TOKEN_TEST_VALUE_SWC2_MEASUREMENT_VAL   NULL_Q_USEFUL_BUF_C
 
#define TOKEN_TEST_REQUIRE_SWC2_MEASUREMENT_VAL   true /* Mandatory field */
 
#define TOKEN_TEST_VALUE_SWC2_VERSION   NULL /* Value not checked */
 
#define TOKEN_TEST_REQUIRE_SWC2_VERSION   true /* Mandatory field */
 
#define TOKEN_TEST_VALUE_SWC2_SIGNER_ID   NULL_Q_USEFUL_BUF_C
 
#define TOKEN_TEST_REQUIRE_SWC2_SIGNER_ID   true /* Mandatory field */
 
#define TOKEN_TEST_VALUE_SWC2_MEASUREMENT_DESC   "SHA256" /* Hard-coded value */
 
#define TOKEN_TEST_REQUIRE_SWC2_MEASUREMENT_DESC   false /* Optional field */
 
#define ATTEST_TOKEN_MAX_SIZE   0x250
 

Detailed Description

Expected values for test suite.

This is a bunch of made up values for hard-coded test cases for attestation tokens.

There are four possible test configurations for testing each claim:

  1. No checking at all. TOKEN_TEST_REQUIRE_XXX is false and TOKEN_TEST_VALUE_XXX is not given.
  2. Check for presence only. TOKEN_TEST_REQUIRE_XXX is true and TOKEN_TEST_VALUE_XXX is not given.
  3. Check value if it is present, but it is not required to be present. TOKEN_TEST_REQUIRE_XXX is false and TOKEN_TEST_VALUE_XXX is given.
  4. Must be present and of specific value. TOKEN_TEST_REQUIRE_XXX is true and TOKEN_TEST_VALUE_XXX is given.

TOKEN_TEST_VALUE_XXX is not given as follows:

  • #define text strings as NULL
  • #define binary strings as NULL_Q_USEFUL_BUF_C
  • #define the integer value as INT32_MAX

It is assumed that the expected value for any test will never be any of these.

Individual test can also be made to return values that are not fixed at compile time by defining them to be a function and implementing the funciton. Here are examples for the three types:

 struct q_useful_buf_c get_expected_nonce(void);
 #define TOKEN_TEST_VALUE_NONCE get_expected_nonce()

 const char *get_expected_hw_version(void);
 #define TOKEN_TEST_VALUE_HW_VERSION get_expected_hw_version()

 uint32_t get_expected_client_id(void);
 #define TOKEN_TEST_VALUE_CLIENT_ID get_expected_client_id()

The initialization value for byte strings uses a compound literal to create the ptr and len for a struct q_useful_buf_c. They are a bit ugly, but they work and setting up this way allows the literal value to be replaced by a function call for dynamic expected values.

The first part of the compound literal is the value of the bytes. The second is an integer that is the length, the number of bytes. They length must be the number of bytes in the first.

Definition in file attest_token_test_values.h.

Macro Definition Documentation

#define ATTEST_TOKEN_MAX_SIZE   0x250

Definition at line 315 of file attest_token_test_values.h.

#define TOKEN_TEST_NONCE_BYTES
Value:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

Definition at line 73 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_BOOT_SEED   true /* Mandatory claim */

Definition at line 176 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_CLIENT_ID   true /* Mandatory claim */

Definition at line 185 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_HW_VERSION   false /* Optional claim */

Definition at line 177 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_IMPLEMENTATION_ID   true /* Mandatory claim */

Definition at line 178 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_NONCE   true /* Mandatory claim */

Definition at line 87 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_ORIGINATION   false /* Optional field */

Definition at line 180 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_PROFILE_DEFINITION   false /* Optional field */

Definition at line 179 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SECURITY_LIFECYCLE   true /* Mandatory claim */

Definition at line 181 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC1_MEASUREMENT_DESC   false /* Optional field */

Definition at line 260 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC1_MEASUREMENT_TYPE   false /* Optional field */

Definition at line 213 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC1_MEASUREMENT_VAL   true /* Mandatory field */

Definition at line 229 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC1_SIGNER_ID   true /* Mandatory field */

Definition at line 256 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC1_VERSION   true /* Mandatory field */

Definition at line 237 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC2_MEASUREMENT_DESC   false /* Optional field */

Definition at line 310 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC2_MEASUREMENT_TYPE   false /* Optional field */

Definition at line 264 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC2_MEASUREMENT_VAL   true /* Mandatory field */

Definition at line 280 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC2_SIGNER_ID   true /* Mandatory field */

Definition at line 306 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_SWC2_VERSION   true /* Mandatory field */

Definition at line 287 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRE_UEID   true /* Mandatory claim */

Definition at line 108 of file attest_token_test_values.h.

#define TOKEN_TEST_REQUIRED_NUM_SWC   0

TOKEN_TEST_REQUIRED_NUM_SWC can be either 0, 1, 2 or INT32_MAX

0 – No SW components are required, but if there is 1, its values must compare to SWC1 correctly and if there are 2, the first must compare to SWC1 and the second to SWC2.

1 – At least one SW component is required and it must compare correctly to SWC1. If a second one is present its values will also be checked.

2 – Two SW components are required and their values must compare correctly.

INT32_MAX – No checking of the SW components of any sort is performed.

Note that attest_token_decode() checks for the presence of the the EAT_CBOR_ARM_LABEL_NO_SW_COMPONENTS CBOR data item for the case of no SW components and gives an error if it is absent.

Definition at line 209 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_BOOT_SEED   NULL_Q_USEFUL_BUF_C

Definition at line 167 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_CLIENT_ID   0 /* Invalid value to trigger check */

Definition at line 184 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_HW_VERSION   NULL

Definition at line 168 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_IMPLEMENTATION_ID   NULL_Q_USEFUL_BUF_C

Definition at line 169 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_NONCE
Value:
(struct q_useful_buf_c) {\
(uint8_t[]){TOKEN_TEST_NONCE_BYTES},\
64\
}
#define TOKEN_TEST_NONCE_BYTES

Definition at line 82 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_ORIGINATION   NULL

Definition at line 171 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_PROFILE_DEFINITION   NULL

Definition at line 170 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SECURITY_LIFECYCLE   INT32_MAX

Definition at line 172 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC1_MEASUREMENT_DESC   "SHA256" /* Hard-coded value */

Definition at line 259 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC1_MEASUREMENT_TYPE   NULL /* Value not checked */

Definition at line 212 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC1_MEASUREMENT_VAL   NULL_Q_USEFUL_BUF_C

Definition at line 216 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC1_SIGNER_ID   NULL_Q_USEFUL_BUF_C

Definition at line 240 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC1_VERSION   NULL /* Value not checked */

Definition at line 233 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC2_MEASUREMENT_DESC   "SHA256" /* Hard-coded value */

Definition at line 309 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC2_MEASUREMENT_TYPE   NULL /* Value not checked */

Definition at line 263 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC2_MEASUREMENT_VAL   NULL_Q_USEFUL_BUF_C

Definition at line 267 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC2_SIGNER_ID   NULL_Q_USEFUL_BUF_C

Definition at line 290 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_SWC2_VERSION   NULL /* Value not checked */

Definition at line 283 of file attest_token_test_values.h.

#define TOKEN_TEST_VALUE_UEID   NULL_Q_USEFUL_BUF_C

Definition at line 90 of file attest_token_test_values.h.