quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

hash.h (2148B)


      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 "test_driver_common.h"
     15 
     16 #include <psa/crypto_driver_common.h>
     17 
     18 typedef struct {
     19     /* If not PSA_SUCCESS, return this error code instead of processing the
     20      * function call. */
     21     psa_status_t forced_status;
     22     /* Count the amount of times hash driver entry points are called. */
     23     unsigned long hits;
     24     /* Status returned by the last hash driver entry point call. */
     25     psa_status_t driver_status;
     26 } mbedtls_test_driver_hash_hooks_t;
     27 
     28 #define MBEDTLS_TEST_DRIVER_HASH_INIT { 0, 0, 0 }
     29 static inline mbedtls_test_driver_hash_hooks_t
     30 mbedtls_test_driver_hash_hooks_init(void)
     31 {
     32     const mbedtls_test_driver_hash_hooks_t v = MBEDTLS_TEST_DRIVER_HASH_INIT;
     33     return v;
     34 }
     35 
     36 extern mbedtls_test_driver_hash_hooks_t mbedtls_test_driver_hash_hooks;
     37 
     38 psa_status_t mbedtls_test_transparent_hash_compute(
     39     psa_algorithm_t alg,
     40     const uint8_t *input, size_t input_length,
     41     uint8_t *hash, size_t hash_size, size_t *hash_length);
     42 
     43 psa_status_t mbedtls_test_transparent_hash_setup(
     44     mbedtls_transparent_test_driver_hash_operation_t *operation,
     45     psa_algorithm_t alg);
     46 
     47 psa_status_t mbedtls_test_transparent_hash_clone(
     48     const mbedtls_transparent_test_driver_hash_operation_t *source_operation,
     49     mbedtls_transparent_test_driver_hash_operation_t *target_operation);
     50 
     51 psa_status_t mbedtls_test_transparent_hash_update(
     52     mbedtls_transparent_test_driver_hash_operation_t *operation,
     53     const uint8_t *input,
     54     size_t input_length);
     55 
     56 psa_status_t mbedtls_test_transparent_hash_finish(
     57     mbedtls_transparent_test_driver_hash_operation_t *operation,
     58     uint8_t *hash,
     59     size_t hash_size,
     60     size_t *hash_length);
     61 
     62 psa_status_t mbedtls_test_transparent_hash_abort(
     63     mbedtls_transparent_test_driver_hash_operation_t *operation);
     64 
     65 #endif /* PSA_CRYPTO_DRIVER_TEST */
     66 #endif /* PSA_CRYPTO_TEST_DRIVERS_HASH_H */