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
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __CRYPTO_TESTS_COMMON_H__
9 #define __CRYPTO_TESTS_COMMON_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include "psa/crypto.h"
16 #include "test_framework_helpers.h"
17 
22 #define BIT_SIZE_TEST_KEY (128)
23 
28 #define BIT_SIZE_TEST_LONG_KEY (256)
29 
34 #define BYTE_SIZE_TEST_KEY (BIT_SIZE_TEST_KEY/8)
35 
40 #define BYTE_SIZE_CHUNK (16)
41 
46 #define ENC_DEC_BUFFER_SIZE (32)
47 
53 #define ASSOCIATED_DATA_SIZE (24)
54 
59 #define TEST_MAX_KEY_LENGTH (64)
60 
64 #define TRUNCATED_AUTH_TAG_LEN (8)
65 
73 void psa_key_interface_test(const psa_key_type_t key_type,
74  struct test_result_t *ret);
83 void psa_cipher_test(const psa_key_type_t key_type,
84  const psa_algorithm_t alg,
85  struct test_result_t *ret);
95 void psa_invalid_cipher_test(const psa_key_type_t key_type,
96  const psa_algorithm_t alg,
97  const size_t key_size,
98  struct test_result_t *ret);
107  struct test_result_t *ret);
115 void psa_hash_test(const psa_algorithm_t alg,
116  struct test_result_t *ret);
125 void psa_unsupported_mac_test(const psa_key_type_t key_type,
126  const psa_algorithm_t alg,
127  struct test_result_t *ret);
136 void psa_mac_test(const psa_algorithm_t alg,
137  uint8_t use_long_key,
138  struct test_result_t *ret);
147 void psa_aead_test(const psa_key_type_t key_type,
148  const psa_algorithm_t alg,
149  struct test_result_t *ret);
157 
165 
173 
180 void psa_persistent_key_test(psa_key_id_t key_id, struct test_result_t *ret);
181 
189  struct test_result_t *ret);
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif /* __CRYPTO_TESTS_COMMON__ */
void psa_unsupported_hash_test(const psa_algorithm_t alg, struct test_result_t *ret)
Tests setup of an unsupported hash algorithm.
Platform Security Architecture cryptography module.
uint32_t psa_key_id_t
Definition: crypto_types.h:223
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.
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.
void psa_mac_test(const psa_algorithm_t alg, uint8_t use_long_key, struct test_result_t *ret)
Tests different MAC algorithms.
void psa_invalid_key_length_test(struct test_result_t *ret)
Tests invalid key length.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:90
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.
void psa_hash_test(const psa_algorithm_t alg, struct test_result_t *ret)
Tests different hashing algorithms.
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:58
void psa_key_derivation_test(psa_algorithm_t deriv_alg, struct test_result_t *ret)
Key derivation test.
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.
void psa_policy_invalid_policy_usage_test(struct test_result_t *ret)
Tests invalid policy usage.
void psa_policy_key_interface_test(struct test_result_t *ret)
Tests the policy key interface.
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.
void psa_persistent_key_test(psa_key_id_t key_id, struct test_result_t *ret)
Tests persistent keys.