quickjs-tart

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

aead.h (4248B)


      1 /*
      2  * Test driver for AEAD 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_AEAD_H
      9 #define PSA_CRYPTO_TEST_DRIVERS_AEAD_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 AEAD driver functions are called. */
     23     unsigned long hits_encrypt;
     24     unsigned long hits_decrypt;
     25     unsigned long hits_encrypt_setup;
     26     unsigned long hits_decrypt_setup;
     27     unsigned long hits_set_nonce;
     28     unsigned long hits_set_lengths;
     29     unsigned long hits_update_ad;
     30     unsigned long hits_update;
     31     unsigned long hits_finish;
     32     unsigned long hits_verify;
     33     unsigned long hits_abort;
     34 
     35     /* Status returned by the last AEAD driver function call. */
     36     psa_status_t driver_status;
     37 } mbedtls_test_driver_aead_hooks_t;
     38 
     39 #define MBEDTLS_TEST_DRIVER_AEAD_INIT { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
     40 static inline mbedtls_test_driver_aead_hooks_t
     41 mbedtls_test_driver_aead_hooks_init(void)
     42 {
     43     const mbedtls_test_driver_aead_hooks_t v = MBEDTLS_TEST_DRIVER_AEAD_INIT;
     44     return v;
     45 }
     46 
     47 extern mbedtls_test_driver_aead_hooks_t mbedtls_test_driver_aead_hooks;
     48 
     49 psa_status_t mbedtls_test_transparent_aead_encrypt(
     50     const psa_key_attributes_t *attributes,
     51     const uint8_t *key_buffer, size_t key_buffer_size,
     52     psa_algorithm_t alg,
     53     const uint8_t *nonce, size_t nonce_length,
     54     const uint8_t *additional_data, size_t additional_data_length,
     55     const uint8_t *plaintext, size_t plaintext_length,
     56     uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length);
     57 
     58 psa_status_t mbedtls_test_transparent_aead_decrypt(
     59     const psa_key_attributes_t *attributes,
     60     const uint8_t *key_buffer, size_t key_buffer_size,
     61     psa_algorithm_t alg,
     62     const uint8_t *nonce, size_t nonce_length,
     63     const uint8_t *additional_data, size_t additional_data_length,
     64     const uint8_t *ciphertext, size_t ciphertext_length,
     65     uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length);
     66 
     67 psa_status_t mbedtls_test_transparent_aead_encrypt_setup(
     68     mbedtls_transparent_test_driver_aead_operation_t *operation,
     69     const psa_key_attributes_t *attributes,
     70     const uint8_t *key_buffer, size_t key_buffer_size,
     71     psa_algorithm_t alg);
     72 
     73 psa_status_t mbedtls_test_transparent_aead_decrypt_setup(
     74     mbedtls_transparent_test_driver_aead_operation_t *operation,
     75     const psa_key_attributes_t *attributes,
     76     const uint8_t *key_buffer, size_t key_buffer_size,
     77     psa_algorithm_t alg);
     78 
     79 psa_status_t mbedtls_test_transparent_aead_set_nonce(
     80     mbedtls_transparent_test_driver_aead_operation_t *operation,
     81     const uint8_t *nonce,
     82     size_t nonce_length);
     83 
     84 psa_status_t mbedtls_test_transparent_aead_set_lengths(
     85     mbedtls_transparent_test_driver_aead_operation_t *operation,
     86     size_t ad_length,
     87     size_t plaintext_length);
     88 
     89 psa_status_t mbedtls_test_transparent_aead_update_ad(
     90     mbedtls_transparent_test_driver_aead_operation_t *operation,
     91     const uint8_t *input,
     92     size_t input_length);
     93 
     94 psa_status_t mbedtls_test_transparent_aead_update(
     95     mbedtls_transparent_test_driver_aead_operation_t *operation,
     96     const uint8_t *input,
     97     size_t input_length,
     98     uint8_t *output,
     99     size_t output_size,
    100     size_t *output_length);
    101 
    102 psa_status_t mbedtls_test_transparent_aead_finish(
    103     mbedtls_transparent_test_driver_aead_operation_t *operation,
    104     uint8_t *ciphertext,
    105     size_t ciphertext_size,
    106     size_t *ciphertext_length,
    107     uint8_t *tag,
    108     size_t tag_size,
    109     size_t *tag_length);
    110 
    111 psa_status_t mbedtls_test_transparent_aead_verify(
    112     mbedtls_transparent_test_driver_aead_operation_t *operation,
    113     uint8_t *plaintext,
    114     size_t plaintext_size,
    115     size_t *plaintext_length,
    116     const uint8_t *tag,
    117     size_t tag_length);
    118 
    119 psa_status_t mbedtls_test_transparent_aead_abort(
    120     mbedtls_transparent_test_driver_aead_operation_t *operation);
    121 
    122 #endif /* PSA_CRYPTO_DRIVER_TEST */
    123 #endif /* PSA_CRYPTO_TEST_DRIVERS_AEAD_H */