1 /*
2 * Test driver for hash driver entry points.
3 */
4 /* Copyright The Mbed TLS Contributors
5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6 */
7
8 #ifndef PSA_CRYPTO_TEST_DRIVERS_HASH_H
9 #define PSA_CRYPTO_TEST_DRIVERS_HASH_H
10
11 #include "mbedtls/build_info.h"
12
13 #if defined(PSA_CRYPTO_DRIVER_TEST)
14 #include <psa/crypto_driver_common.h>
15
16 typedef struct {
17 /* If not PSA_SUCCESS, return this error code instead of processing the
18 * function call. */
19 psa_status_t forced_status;
20 /* Count the amount of times hash driver entry points are called. */
21 unsigned long hits;
22 /* Status returned by the last hash driver entry point call. */
23 psa_status_t driver_status;
24 } mbedtls_test_driver_hash_hooks_t;
25
26 #define MBEDTLS_TEST_DRIVER_HASH_INIT { 0, 0, 0 }
27 static inline mbedtls_test_driver_hash_hooks_t
mbedtls_test_driver_hash_hooks_init(void)28 mbedtls_test_driver_hash_hooks_init(void)
29 {
30 const mbedtls_test_driver_hash_hooks_t v = MBEDTLS_TEST_DRIVER_HASH_INIT;
31 return v;
32 }
33
34 extern mbedtls_test_driver_hash_hooks_t mbedtls_test_driver_hash_hooks;
35
36 psa_status_t mbedtls_test_transparent_hash_compute(
37 psa_algorithm_t alg,
38 const uint8_t *input, size_t input_length,
39 uint8_t *hash, size_t hash_size, size_t *hash_length);
40
41 psa_status_t mbedtls_test_transparent_hash_setup(
42 mbedtls_transparent_test_driver_hash_operation_t *operation,
43 psa_algorithm_t alg);
44
45 psa_status_t mbedtls_test_transparent_hash_clone(
46 const mbedtls_transparent_test_driver_hash_operation_t *source_operation,
47 mbedtls_transparent_test_driver_hash_operation_t *target_operation);
48
49 psa_status_t mbedtls_test_transparent_hash_update(
50 mbedtls_transparent_test_driver_hash_operation_t *operation,
51 const uint8_t *input,
52 size_t input_length);
53
54 psa_status_t mbedtls_test_transparent_hash_finish(
55 mbedtls_transparent_test_driver_hash_operation_t *operation,
56 uint8_t *hash,
57 size_t hash_size,
58 size_t *hash_length);
59
60 psa_status_t mbedtls_test_transparent_hash_abort(
61 mbedtls_transparent_test_driver_hash_operation_t *operation);
62
63 #endif /* PSA_CRYPTO_DRIVER_TEST */
64 #endif /* PSA_CRYPTO_TEST_DRIVERS_HASH_H */
65