TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
crypto_tests_common.h File Reference
#include "psa/crypto.h"
#include "test_framework_helpers.h"
Include dependency graph for crypto_tests_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BIT_SIZE_TEST_KEY   (128)
 Size of the key to use in tests in bits. More...
 
#define BIT_SIZE_TEST_LONG_KEY   (256)
 Size of the long key to use in tests in bits. More...
 
#define BYTE_SIZE_TEST_KEY   (BIT_SIZE_TEST_KEY/8)
 Macro to extract the size of the key in bytes. More...
 
#define BYTE_SIZE_CHUNK   (16)
 Size in bytes of a chunk of data to process. More...
 
#define ENC_DEC_BUFFER_SIZE   (32)
 Size in bytes of the encryption/decryption buffers. More...
 
#define ASSOCIATED_DATA_SIZE   (24)
 Size in bytes of the associated data to authenticate in AEAD tests. More...
 
#define TEST_MAX_KEY_LENGTH   (64)
 The maximum allowed key length in bytes used in the tests. More...
 
#define TRUNCATED_AUTH_TAG_LEN   (8)
 The length of truncated authentication tag for AEAD algorithm. More...
 

Functions

void psa_key_interface_test (const psa_key_type_t key_type, struct test_result_t *ret)
 Tests the key interfaces with different key types. More...
 
void psa_cipher_test (const psa_key_type_t key_type, const psa_algorithm_t alg, struct test_result_t *ret)
 Run block ciphering tests with different algorithms and key types. More...
 
void psa_invalid_cipher_test (const psa_key_type_t key_type, const psa_algorithm_t alg, const size_t key_size, struct test_result_t *ret)
 Tests invalid key type and algorithm combinations for block ciphers. More...
 
void psa_unsupported_hash_test (const psa_algorithm_t alg, struct test_result_t *ret)
 Tests setup of an unsupported hash algorithm. More...
 
void psa_hash_test (const psa_algorithm_t alg, struct test_result_t *ret)
 Tests different hashing algorithms. More...
 
void psa_unsupported_mac_test (const psa_key_type_t key_type, const psa_algorithm_t alg, struct test_result_t *ret)
 Tests setup of an unsupported MAC algorithm. More...
 
void psa_mac_test (const psa_algorithm_t alg, uint8_t use_long_key, struct test_result_t *ret)
 Tests different MAC algorithms. More...
 
void psa_aead_test (const psa_key_type_t key_type, const psa_algorithm_t alg, struct test_result_t *ret)
 Run AEAD tests with different algorithms and key types. More...
 
void psa_invalid_key_length_test (struct test_result_t *ret)
 Tests invalid key length. More...
 
void psa_policy_key_interface_test (struct test_result_t *ret)
 Tests the policy key interface. More...
 
void psa_policy_invalid_policy_usage_test (struct test_result_t *ret)
 Tests invalid policy usage. More...
 
void psa_persistent_key_test (psa_key_id_t key_id, struct test_result_t *ret)
 Tests persistent keys. More...
 
void psa_key_derivation_test (psa_algorithm_t deriv_alg, struct test_result_t *ret)
 Key derivation test. More...
 

Macro Definition Documentation

#define ASSOCIATED_DATA_SIZE   (24)

Size in bytes of the associated data to authenticate in AEAD tests.

Definition at line 53 of file crypto_tests_common.h.

#define BIT_SIZE_TEST_KEY   (128)

Size of the key to use in tests in bits.

Definition at line 22 of file crypto_tests_common.h.

#define BIT_SIZE_TEST_LONG_KEY   (256)

Size of the long key to use in tests in bits.

Definition at line 28 of file crypto_tests_common.h.

#define BYTE_SIZE_CHUNK   (16)

Size in bytes of a chunk of data to process.

Definition at line 40 of file crypto_tests_common.h.

#define BYTE_SIZE_TEST_KEY   (BIT_SIZE_TEST_KEY/8)

Macro to extract the size of the key in bytes.

Definition at line 34 of file crypto_tests_common.h.

#define ENC_DEC_BUFFER_SIZE   (32)

Size in bytes of the encryption/decryption buffers.

Definition at line 46 of file crypto_tests_common.h.

#define TEST_MAX_KEY_LENGTH   (64)

The maximum allowed key length in bytes used in the tests.

Definition at line 59 of file crypto_tests_common.h.

#define TRUNCATED_AUTH_TAG_LEN   (8)

The length of truncated authentication tag for AEAD algorithm.

Definition at line 64 of file crypto_tests_common.h.

Function Documentation

void psa_aead_test ( const psa_key_type_t  key_type,
const psa_algorithm_t  alg,
struct test_result_t ret 
)

Run AEAD tests with different algorithms and key types.

Parameters
[in]key_typePSA key type
[in]algPSA algorithm
[out]retTest result

Definition at line 650 of file crypto_tests_common.c.

Here is the call graph for this function:

void psa_cipher_test ( const psa_key_type_t  key_type,
const psa_algorithm_t  alg,
struct test_result_t ret 
)

Run block ciphering tests with different algorithms and key types.

Parameters
[in]key_typePSA key type
[in]algPSA algorithm
[out]retTest result

Definition at line 96 of file crypto_tests_common.c.

Here is the call graph for this function:

void psa_hash_test ( const psa_algorithm_t  alg,
struct test_result_t ret 
)

Tests different hashing algorithms.

Parameters
[in]algPSA algorithm
[out]retTest result

Definition at line 415 of file crypto_tests_common.c.

void psa_invalid_cipher_test ( const psa_key_type_t  key_type,
const psa_algorithm_t  alg,
const size_t  key_size,
struct test_result_t ret 
)

Tests invalid key type and algorithm combinations for block ciphers.

Parameters
[in]key_typePSA key type
[in]algPSA algorithm
[in]key_sizeKey size
[out]retTest result

Definition at line 312 of file crypto_tests_common.c.

Here is the call graph for this function:

void psa_invalid_key_length_test ( struct test_result_t ret)

Tests invalid key length.

Parameters
[out]retTest result

Definition at line 800 of file crypto_tests_common.c.

void psa_key_derivation_test ( psa_algorithm_t  deriv_alg,
struct test_result_t ret 
)

Key derivation test.

Parameters
[in]deriv_algKey derivation algorithm
[out]retTest result

Definition at line 1059 of file crypto_tests_common.c.

Here is the call graph for this function:

void psa_key_interface_test ( const psa_key_type_t  key_type,
struct test_result_t ret 
)

Tests the key interfaces with different key types.

Parameters
[in]key_typePSA key type
[out]retTest result

Definition at line 15 of file crypto_tests_common.c.

void psa_mac_test ( const psa_algorithm_t  alg,
uint8_t  use_long_key,
struct test_result_t ret 
)

Tests different MAC algorithms.

Parameters
[in]algPSA algorithm
[in]use_long_keyFlag used to indicate to use the long test key
[out]retTest result

Definition at line 534 of file crypto_tests_common.c.

void psa_persistent_key_test ( psa_key_id_t  key_id,
struct test_result_t ret 
)

Tests persistent keys.

Parameters
[out]retTest result

Definition at line 973 of file crypto_tests_common.c.

Here is the call graph for this function:

void psa_policy_invalid_policy_usage_test ( struct test_result_t ret)

Tests invalid policy usage.

Parameters
[out]retTest result

Definition at line 884 of file crypto_tests_common.c.

void psa_policy_key_interface_test ( struct test_result_t ret)

Tests the policy key interface.

Parameters
[out]retTest result

Definition at line 827 of file crypto_tests_common.c.

void psa_unsupported_hash_test ( const psa_algorithm_t  alg,
struct test_result_t ret 
)

Tests setup of an unsupported hash algorithm.

Parameters
[in]algPSA algorithm
[out]retTest result

Definition at line 361 of file crypto_tests_common.c.

void psa_unsupported_mac_test ( const psa_key_type_t  key_type,
const psa_algorithm_t  alg,
struct test_result_t ret 
)

Tests setup of an unsupported MAC algorithm.

Parameters
[in]key_typePSA key type
[in]algPSA algorithm
[out]retTest result

Definition at line 464 of file crypto_tests_common.c.