quickjs-tart

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

pake.h (2613B)


      1 /*
      2  * Test driver for PAKE 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_PAKE_H
      9 #define PSA_CRYPTO_TEST_DRIVERS_PAKE_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     /* PAKE driver setup is executed on the first call to
     23        pake_output/pake_input (added to distinguish forced statuses). */
     24     psa_status_t forced_setup_status;
     25     /* Count the amount of times PAKE driver functions are called. */
     26     struct {
     27         unsigned long total;
     28         unsigned long setup;
     29         unsigned long input;
     30         unsigned long output;
     31         unsigned long implicit_key;
     32         unsigned long abort;
     33     } hits;
     34     /* Status returned by the last PAKE driver function call. */
     35     psa_status_t driver_status;
     36     /* Output returned by pake_output */
     37     void *forced_output;
     38     size_t forced_output_length;
     39 } mbedtls_test_driver_pake_hooks_t;
     40 
     41 #define MBEDTLS_TEST_DRIVER_PAKE_INIT { PSA_SUCCESS, PSA_SUCCESS, { 0, 0, 0, 0, 0, 0 }, PSA_SUCCESS, \
     42                                         NULL, 0 }
     43 static inline mbedtls_test_driver_pake_hooks_t
     44 mbedtls_test_driver_pake_hooks_init(void)
     45 {
     46     const mbedtls_test_driver_pake_hooks_t v = MBEDTLS_TEST_DRIVER_PAKE_INIT;
     47     return v;
     48 }
     49 
     50 extern mbedtls_test_driver_pake_hooks_t mbedtls_test_driver_pake_hooks;
     51 
     52 psa_status_t mbedtls_test_transparent_pake_setup(
     53     mbedtls_transparent_test_driver_pake_operation_t *operation,
     54     const psa_crypto_driver_pake_inputs_t *inputs);
     55 
     56 psa_status_t mbedtls_test_transparent_pake_output(
     57     mbedtls_transparent_test_driver_pake_operation_t *operation,
     58     psa_crypto_driver_pake_step_t step,
     59     uint8_t *output,
     60     size_t output_size,
     61     size_t *output_length);
     62 
     63 psa_status_t mbedtls_test_transparent_pake_input(
     64     mbedtls_transparent_test_driver_pake_operation_t *operation,
     65     psa_crypto_driver_pake_step_t step,
     66     const uint8_t *input,
     67     size_t input_length);
     68 
     69 psa_status_t mbedtls_test_transparent_pake_get_implicit_key(
     70     mbedtls_transparent_test_driver_pake_operation_t *operation,
     71     uint8_t *output, size_t output_size, size_t *output_length);
     72 
     73 psa_status_t mbedtls_test_transparent_pake_abort(
     74     mbedtls_transparent_test_driver_pake_operation_t *operation);
     75 
     76 #endif /* PSA_CRYPTO_DRIVER_TEST */
     77 #endif /* PSA_CRYPTO_TEST_DRIVERS_PAKE_H */