crypto_se_driver.h
mbedtls/private_access.h
crypto_driver_common.h
mbedtls/build_info.h
mbedtls/check_config.h
mbedtls/config_adjust_legacy_crypto.h
mbedtls/config_adjust_psa_from_legacy.h
mbedtls/config_adjust_psa_superset_legacy.h
mbedtls/config_adjust_ssl.h
mbedtls/config_adjust_x509.h
mbedtls/config_psa.h
mbedtls/mbedtls_config.h
mbedtls/private_access.h
psa/build_info.h
psa/crypto_adjust_auto_enabled.h
psa/crypto_adjust_config_dependencies.h
psa/crypto_adjust_config_key_pair_types.h
psa/crypto_adjust_config_synonyms.h
crypto_driver_common.h
psa/crypto_legacy.h
crypto_platform.h
crypto_se_driver.h
psa/crypto_sizes.h
crypto_types.h
crypto_values.h
limits.h
stddef.h
stdint.h
psa_drv_se_context_t
psa_drv_se_mac_t
psa_drv_se_cipher_t
psa_drv_se_asymmetric_t
psa_drv_se_aead_t
psa_drv_se_key_management_t
psa_drv_se_key_derivation_t
psa_drv_se_t
- PSA_DRV_SE_HAL_VERSION
- psa_key_creation_method_t
- psa_drv_se_init_t
- psa_key_slot_number_t
- psa_drv_se_mac_setup_t
- psa_drv_se_mac_update_t
- psa_drv_se_mac_finish_t
- psa_drv_se_mac_finish_verify_t
- psa_drv_se_mac_abort_t
- psa_drv_se_mac_generate_t
- psa_drv_se_mac_verify_t
- psa_drv_se_cipher_setup_t
- psa_drv_se_cipher_set_iv_t
- psa_drv_se_cipher_update_t
- psa_drv_se_cipher_finish_t
- psa_drv_se_cipher_abort_t
- psa_drv_se_cipher_ecb_t
- psa_drv_se_asymmetric_sign_t
- psa_drv_se_asymmetric_verify_t
- psa_drv_se_asymmetric_encrypt_t
- psa_drv_se_asymmetric_decrypt_t
- psa_drv_se_aead_encrypt_t
- psa_drv_se_aead_decrypt_t
- psa_drv_se_allocate_key_t
- psa_drv_se_validate_slot_number_t
- psa_drv_se_import_key_t
- psa_drv_se_destroy_key_t
- psa_drv_se_export_key_t
- psa_drv_se_generate_key_t
- psa_drv_se_key_derivation_setup_t
- psa_drv_se_key_derivation_collateral_t
- psa_drv_se_key_derivation_derive_t
- psa_drv_se_key_derivation_export_t
- psa_register_se_driver

PSA external cryptoprocessor driver module.

This header declares types and function signatures for cryptography drivers that access key material via opaque references. This is meant for cryptoprocessors that have a separate key storage from the space in which the PSA Crypto implementation runs, typically secure elements (SEs).

This file is part of the PSA Crypto Driver HAL (hardware abstraction layer), containing functions for driver developers to implement to enable hardware to be called in a standardized way by a PSA Cryptography API implementation. The functions comprising the driver HAL, which driver authors implement, are not intended to be called by application developers.

    /*
    *CopyrightTheMbedTLSContributors
    *SPDX-License-Identifier:Apache-2.0ORGPL-2.0-or-later
    */
    #ifndefPSA_CRYPTO_SE_DRIVER_H
    #definePSA_CRYPTO_SE_DRIVER_H
    #include"mbedtls/private_access.h"

    #include"crypto_driver_common.h"

    #ifdef__cplusplus
    extern"C"{
    #endif

    typedefstruct{
    constvoid*constMBEDTLS_PRIVATE(persistent_data);

    constsize_tMBEDTLS_PRIVATE(persistent_data_size);

    uintptr_tMBEDTLS_PRIVATE(transient_data);
    }psa_drv_se_context_t;

    typedefpsa_status_t(*psa_drv_se_init_t)(psa_drv_se_context_t*drv_context,
    void*persistent_data,
    psa_key_location_tlocation);

    #ifdefined(__DOXYGEN_ONLY__)||!defined(MBEDTLS_PSA_CRYPTO_SE_C)
    /*MbedTLSwithsecureelementsupportenableddefinesthistypein
    *crypto_types.hbecauseitisalsovisibletoapplicationsthroughan
    *implementation-specificextension.
    *ForthePSACryptographyspecification,thistypeisonlyvisible
    *viacrypto_se_driver.h.*/
    typedefuint64_tpsa_key_slot_number_t;
    #endif/*__DOXYGEN_ONLY__||!MBEDTLS_PSA_CRYPTO_SE_C*/

    typedefpsa_status_t(*psa_drv_se_mac_setup_t)(psa_drv_se_context_t*drv_context,
    void*op_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talgorithm);

    typedefpsa_status_t(*psa_drv_se_mac_update_t)(void*op_context,
    constuint8_t*p_input,
    size_tinput_length);

    typedefpsa_status_t(*psa_drv_se_mac_finish_t)(void*op_context,
    uint8_t*p_mac,
    size_tmac_size,
    size_t*p_mac_length);

    typedefpsa_status_t(*psa_drv_se_mac_finish_verify_t)(void*op_context,
    constuint8_t*p_mac,
    size_tmac_length);

    typedefpsa_status_t(*psa_drv_se_mac_abort_t)(void*op_context);

    typedefpsa_status_t(*psa_drv_se_mac_generate_t)(psa_drv_se_context_t*drv_context,
    constuint8_t*p_input,
    size_tinput_length,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talg,
    uint8_t*p_mac,
    size_tmac_size,
    size_t*p_mac_length);

    typedefpsa_status_t(*psa_drv_se_mac_verify_t)(psa_drv_se_context_t*drv_context,
    constuint8_t*p_input,
    size_tinput_length,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talg,
    constuint8_t*p_mac,
    size_tmac_length);

    typedefstruct{
    size_tMBEDTLS_PRIVATE(context_size);
    psa_drv_se_mac_setup_tMBEDTLS_PRIVATE(p_setup);
    psa_drv_se_mac_update_tMBEDTLS_PRIVATE(p_update);
    psa_drv_se_mac_finish_tMBEDTLS_PRIVATE(p_finish);
    psa_drv_se_mac_finish_verify_tMBEDTLS_PRIVATE(p_finish_verify);
    psa_drv_se_mac_abort_tMBEDTLS_PRIVATE(p_abort);
    psa_drv_se_mac_generate_tMBEDTLS_PRIVATE(p_mac);
    psa_drv_se_mac_verify_tMBEDTLS_PRIVATE(p_mac_verify);
    }psa_drv_se_mac_t;
    typedefpsa_status_t(*psa_drv_se_cipher_setup_t)(psa_drv_se_context_t*drv_context,
    void*op_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talgorithm,
    psa_encrypt_or_decrypt_tdirection);

    typedefpsa_status_t(*psa_drv_se_cipher_set_iv_t)(void*op_context,
    constuint8_t*p_iv,
    size_tiv_length);

    typedefpsa_status_t(*psa_drv_se_cipher_update_t)(void*op_context,
    constuint8_t*p_input,
    size_tinput_size,
    uint8_t*p_output,
    size_toutput_size,
    size_t*p_output_length);

    typedefpsa_status_t(*psa_drv_se_cipher_finish_t)(void*op_context,
    uint8_t*p_output,
    size_toutput_size,
    size_t*p_output_length);

    typedefpsa_status_t(*psa_drv_se_cipher_abort_t)(void*op_context);

    typedefpsa_status_t(*psa_drv_se_cipher_ecb_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talgorithm,
    psa_encrypt_or_decrypt_tdirection,
    constuint8_t*p_input,
    size_tinput_size,
    uint8_t*p_output,
    size_toutput_size);

    typedefstruct{
    size_tMBEDTLS_PRIVATE(context_size);
    psa_drv_se_cipher_setup_tMBEDTLS_PRIVATE(p_setup);
    psa_drv_se_cipher_set_iv_tMBEDTLS_PRIVATE(p_set_iv);
    psa_drv_se_cipher_update_tMBEDTLS_PRIVATE(p_update);
    psa_drv_se_cipher_finish_tMBEDTLS_PRIVATE(p_finish);
    psa_drv_se_cipher_abort_tMBEDTLS_PRIVATE(p_abort);
    psa_drv_se_cipher_ecb_tMBEDTLS_PRIVATE(p_ecb);
    }psa_drv_se_cipher_t;

    typedefpsa_status_t(*psa_drv_se_asymmetric_sign_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talg,
    constuint8_t*p_hash,
    size_thash_length,
    uint8_t*p_signature,
    size_tsignature_size,
    size_t*p_signature_length);

    typedefpsa_status_t(*psa_drv_se_asymmetric_verify_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talg,
    constuint8_t*p_hash,
    size_thash_length,
    constuint8_t*p_signature,
    size_tsignature_length);

    typedefpsa_status_t(*psa_drv_se_asymmetric_encrypt_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talg,
    constuint8_t*p_input,
    size_tinput_length,
    constuint8_t*p_salt,
    size_tsalt_length,
    uint8_t*p_output,
    size_toutput_size,
    size_t*p_output_length);

    typedefpsa_status_t(*psa_drv_se_asymmetric_decrypt_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talg,
    constuint8_t*p_input,
    size_tinput_length,
    constuint8_t*p_salt,
    size_tsalt_length,
    uint8_t*p_output,
    size_toutput_size,
    size_t*p_output_length);

    typedefstruct{
    psa_drv_se_asymmetric_sign_tMBEDTLS_PRIVATE(p_sign);
    psa_drv_se_asymmetric_verify_tMBEDTLS_PRIVATE(p_verify);
    psa_drv_se_asymmetric_encrypt_tMBEDTLS_PRIVATE(p_encrypt);
    psa_drv_se_asymmetric_decrypt_tMBEDTLS_PRIVATE(p_decrypt);
    }psa_drv_se_asymmetric_t;

    typedefpsa_status_t(*psa_drv_se_aead_encrypt_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talgorithm,
    constuint8_t*p_nonce,
    size_tnonce_length,
    constuint8_t*p_additional_data,
    size_tadditional_data_length,
    constuint8_t*p_plaintext,
    size_tplaintext_length,
    uint8_t*p_ciphertext,
    size_tciphertext_size,
    size_t*p_ciphertext_length);

    typedefpsa_status_t(*psa_drv_se_aead_decrypt_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    psa_algorithm_talgorithm,
    constuint8_t*p_nonce,
    size_tnonce_length,
    constuint8_t*p_additional_data,
    size_tadditional_data_length,
    constuint8_t*p_ciphertext,
    size_tciphertext_length,
    uint8_t*p_plaintext,
    size_tplaintext_size,
    size_t*p_plaintext_length);

    typedefstruct{
    psa_drv_se_aead_encrypt_tMBEDTLS_PRIVATE(p_encrypt);
    psa_drv_se_aead_decrypt_tMBEDTLS_PRIVATE(p_decrypt);
    }psa_drv_se_aead_t;
    typedefenum{
    PSA_KEY_CREATION_IMPORT,
    PSA_KEY_CREATION_GENERATE,
    PSA_KEY_CREATION_DERIVE,
    PSA_KEY_CREATION_COPY,
    #ifndef__DOXYGEN_ONLY__
    PSA_KEY_CREATION_REGISTER,
    #endif
    }psa_key_creation_method_t;

    typedefpsa_status_t(*psa_drv_se_allocate_key_t)(
    psa_drv_se_context_t*drv_context,
    void*persistent_data,
    constpsa_key_attributes_t*attributes,
    psa_key_creation_method_tmethod,
    psa_key_slot_number_t*key_slot);

    typedefpsa_status_t(*psa_drv_se_validate_slot_number_t)(
    psa_drv_se_context_t*drv_context,
    void*persistent_data,
    constpsa_key_attributes_t*attributes,
    psa_key_creation_method_tmethod,
    psa_key_slot_number_tkey_slot);

    typedefpsa_status_t(*psa_drv_se_import_key_t)(
    psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    constpsa_key_attributes_t*attributes,
    constuint8_t*data,
    size_tdata_length,
    size_t*bits);

    typedefpsa_status_t(*psa_drv_se_destroy_key_t)(
    psa_drv_se_context_t*drv_context,
    void*persistent_data,
    psa_key_slot_number_tkey_slot);

    typedefpsa_status_t(*psa_drv_se_export_key_t)(psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey,
    uint8_t*p_data,
    size_tdata_size,
    size_t*p_data_length);

    typedefpsa_status_t(*psa_drv_se_generate_key_t)(
    psa_drv_se_context_t*drv_context,
    psa_key_slot_number_tkey_slot,
    constpsa_key_attributes_t*attributes,
    uint8_t*pubkey,size_tpubkey_size,size_t*pubkey_length);

    typedefstruct{
    psa_drv_se_allocate_key_tMBEDTLS_PRIVATE(p_allocate);
    psa_drv_se_validate_slot_number_tMBEDTLS_PRIVATE(p_validate_slot_number);
    psa_drv_se_import_key_tMBEDTLS_PRIVATE(p_import);
    psa_drv_se_generate_key_tMBEDTLS_PRIVATE(p_generate);
    psa_drv_se_destroy_key_tMBEDTLS_PRIVATE(p_destroy);
    psa_drv_se_export_key_tMBEDTLS_PRIVATE(p_export);
    psa_drv_se_export_key_tMBEDTLS_PRIVATE(p_export_public);
    }psa_drv_se_key_management_t;

    typedefpsa_status_t(*psa_drv_se_key_derivation_setup_t)(psa_drv_se_context_t*drv_context,
    void*op_context,
    psa_algorithm_tkdf_alg,
    psa_key_slot_number_tsource_key);

    typedefpsa_status_t(*psa_drv_se_key_derivation_collateral_t)(void*op_context,
    uint32_tcollateral_id,
    constuint8_t*p_collateral,
    size_tcollateral_size);

    typedefpsa_status_t(*psa_drv_se_key_derivation_derive_t)(void*op_context,
    psa_key_slot_number_tdest_key);

    typedefpsa_status_t(*psa_drv_se_key_derivation_export_t)(void*op_context,
    uint8_t*p_output,
    size_toutput_size,
    size_t*p_output_length);

    typedefstruct{
    size_tMBEDTLS_PRIVATE(context_size);
    psa_drv_se_key_derivation_setup_tMBEDTLS_PRIVATE(p_setup);
    psa_drv_se_key_derivation_collateral_tMBEDTLS_PRIVATE(p_collateral);
    psa_drv_se_key_derivation_derive_tMBEDTLS_PRIVATE(p_derive);
    psa_drv_se_key_derivation_export_tMBEDTLS_PRIVATE(p_export);
    }psa_drv_se_key_derivation_t;

    typedefstruct{
    uint32_tMBEDTLS_PRIVATE(hal_version);

    size_tMBEDTLS_PRIVATE(persistent_data_size);

    psa_drv_se_init_tMBEDTLS_PRIVATE(p_init);

    constpsa_drv_se_key_management_t*MBEDTLS_PRIVATE(key_management);
    constpsa_drv_se_mac_t*MBEDTLS_PRIVATE(mac);
    constpsa_drv_se_cipher_t*MBEDTLS_PRIVATE(cipher);
    constpsa_drv_se_aead_t*MBEDTLS_PRIVATE(aead);
    constpsa_drv_se_asymmetric_t*MBEDTLS_PRIVATE(asymmetric);
    constpsa_drv_se_key_derivation_t*MBEDTLS_PRIVATE(derivation);
    }psa_drv_se_t;

    /*0.0.0patchlevel5*/
    #definePSA_DRV_SE_HAL_VERSION0x00000005

    psa_status_tpsa_register_se_driver(
    psa_key_location_tlocation,
    constpsa_drv_se_t*methods);

    #ifdef__cplusplus
    }
    #endif

    #endif/*PSA_CRYPTO_SE_DRIVER_H*/