crypto.h
crypto_platform.h
stddef.h
crypto_types.h
crypto_values.h
crypto_sizes.h
crypto_struct.h
crypto_extra.h
mbedtls/bignum.h
mbedtls/check_config.h
mbedtls/cipher.h
mbedtls/cmac.h
mbedtls/config.h
mbedtls/config_psa.h
mbedtls/ecp.h
mbedtls/gcm.h
mbedtls/md2.h
mbedtls/md4.h
mbedtls/md5.h
mbedtls/platform_time.h
mbedtls/platform_util.h
mbedtls/ripemd160.h
mbedtls/sha1.h
mbedtls/sha256.h
mbedtls/sha512.h
crypto.h
psa/crypto_builtin_composites.h
psa/crypto_builtin_primitives.h
crypto_compat.h
psa/crypto_driver_common.h
psa/crypto_driver_contexts_composites.h
psa/crypto_driver_contexts_primitives.h
crypto_extra.h
crypto_platform.h
crypto_sizes.h
crypto_struct.h
crypto_types.h
crypto_values.h
limits.h
stddef.h
stdint.h
stdio.h
time.h
- PSA_CRYPTO_API_VERSION_MAJOR
- PSA_CRYPTO_API_VERSION_MINOR
- PSA_KEY_DERIVATION_UNLIMITED_CAPACITY
- psa_hash_operation_t
- psa_mac_operation_t
- psa_cipher_operation_t
- psa_aead_operation_t
- psa_key_derivation_operation_t
- psa_crypto_init
- psa_key_attributes_init
- psa_set_key_id
- psa_set_key_lifetime
- psa_get_key_id
- psa_get_key_lifetime
- psa_set_key_usage_flags
- psa_get_key_usage_flags
- psa_set_key_algorithm
- psa_get_key_algorithm
- psa_set_key_type
- psa_set_key_bits
- psa_get_key_type
- psa_get_key_bits
- psa_get_key_attributes
- psa_reset_key_attributes
- psa_purge_key
- psa_copy_key
- psa_destroy_key
- psa_import_key
- psa_export_key
- psa_export_public_key
- psa_hash_compute
- psa_hash_compare
- psa_hash_operation_init
- psa_hash_setup
- psa_hash_update
- psa_hash_finish
- psa_hash_verify
- psa_hash_abort
- psa_hash_clone
- psa_mac_compute
- psa_mac_verify
- psa_mac_operation_init
- psa_mac_sign_setup
- psa_mac_verify_setup
- psa_mac_update
- psa_mac_sign_finish
- psa_mac_verify_finish
- psa_mac_abort
- psa_cipher_encrypt
- psa_cipher_decrypt
- psa_cipher_operation_init
- psa_cipher_encrypt_setup
- psa_cipher_decrypt_setup
- psa_cipher_generate_iv
- psa_cipher_set_iv
- psa_cipher_update
- psa_cipher_finish
- psa_cipher_abort
- psa_aead_encrypt
- psa_aead_decrypt
- psa_aead_operation_init
- psa_aead_encrypt_setup
- psa_aead_decrypt_setup
- psa_aead_generate_nonce
- psa_aead_set_nonce
- psa_aead_set_lengths
- psa_aead_update_ad
- psa_aead_update
- psa_aead_finish
- psa_aead_verify
- psa_aead_abort
- psa_sign_message
- psa_verify_message
- psa_sign_hash
- psa_verify_hash
- psa_asymmetric_encrypt
- psa_asymmetric_decrypt
- psa_key_derivation_operation_init
- psa_key_derivation_setup
- psa_key_derivation_get_capacity
- psa_key_derivation_set_capacity
- psa_key_derivation_input_bytes
- psa_key_derivation_input_key
- psa_key_derivation_key_agreement
- psa_key_derivation_output_bytes
- psa_key_derivation_output_key
- psa_key_derivation_abort
- psa_raw_key_agreement
- psa_generate_random
- psa_generate_key

Platform Security Architecture cryptography module.

    /*
    *CopyrightTheMbedTLSContributors
    *SPDX-License-Identifier:Apache-2.0ORGPL-2.0-or-later
    */

    #ifndefPSA_CRYPTO_H
    #definePSA_CRYPTO_H

    #include"crypto_platform.h"

    #include<stddef.h>

    #ifdef__DOXYGEN_ONLY__
    /*This__DOXYGEN_ONLY__blockcontainsmockdefinitionsforthingsthat
    *mustbedefinedinthecrypto_platform.hheader.Thesemockdefinitions
    *arepresentinthisfileasaconveniencetogeneratepretty-printed
    *documentationthatincludesthosedefinitions.*/

    #endif/*__DOXYGEN_ONLY__*/

    #ifdef__cplusplus
    extern"C"{
    #endif

    /*Thefile"crypto_types.h"declarestypesthatencodeerrors,
    *algorithms,keytypes,policies,etc.*/
    #include"crypto_types.h"

    #definePSA_CRYPTO_API_VERSION_MAJOR1

    #definePSA_CRYPTO_API_VERSION_MINOR0

    /*Thefile"crypto_values.h"declaresmacrostobuildandanalyzevalues
    *ofintegraltypesdefinedin"crypto_types.h".*/
    #include"crypto_values.h"

    psa_status_tpsa_crypto_init(void);

    #ifdef__DOXYGEN_ONLY__
    /*Thisisanexampledefinitionfordocumentationpurposes.
    *Implementationsshoulddefineasuitablevaluein`crypto_struct.h`.
    */
    #definePSA_KEY_ATTRIBUTES_INIT{0}
    #endif

    staticpsa_key_attributes_tpsa_key_attributes_init(void);

    staticvoidpsa_set_key_id(psa_key_attributes_t*attributes,
    mbedtls_svc_key_id_tkey);

    #ifdefMBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
    staticvoidmbedtls_set_key_owner_id(psa_key_attributes_t*attributes,
    mbedtls_key_owner_id_towner);
    #endif

    staticvoidpsa_set_key_lifetime(psa_key_attributes_t*attributes,
    psa_key_lifetime_tlifetime);

    staticmbedtls_svc_key_id_tpsa_get_key_id(
    constpsa_key_attributes_t*attributes);

    staticpsa_key_lifetime_tpsa_get_key_lifetime(
    constpsa_key_attributes_t*attributes);

    staticvoidpsa_set_key_usage_flags(psa_key_attributes_t*attributes,
    psa_key_usage_tusage_flags);

    staticpsa_key_usage_tpsa_get_key_usage_flags(
    constpsa_key_attributes_t*attributes);

    staticvoidpsa_set_key_algorithm(psa_key_attributes_t*attributes,
    psa_algorithm_talg);

    staticpsa_algorithm_tpsa_get_key_algorithm(
    constpsa_key_attributes_t*attributes);

    staticvoidpsa_set_key_type(psa_key_attributes_t*attributes,
    psa_key_type_ttype);

    staticvoidpsa_set_key_bits(psa_key_attributes_t*attributes,
    size_tbits);

    staticpsa_key_type_tpsa_get_key_type(constpsa_key_attributes_t*attributes);

    staticsize_tpsa_get_key_bits(constpsa_key_attributes_t*attributes);

    psa_status_tpsa_get_key_attributes(mbedtls_svc_key_id_tkey,
    psa_key_attributes_t*attributes);

    voidpsa_reset_key_attributes(psa_key_attributes_t*attributes);

    psa_status_tpsa_purge_key(mbedtls_svc_key_id_tkey);

    psa_status_tpsa_copy_key(mbedtls_svc_key_id_tsource_key,
    constpsa_key_attributes_t*attributes,
    mbedtls_svc_key_id_t*target_key);

    psa_status_tpsa_destroy_key(mbedtls_svc_key_id_tkey);

    psa_status_tpsa_import_key(constpsa_key_attributes_t*attributes,
    constuint8_t*data,
    size_tdata_length,
    mbedtls_svc_key_id_t*key);

    psa_status_tpsa_export_key(mbedtls_svc_key_id_tkey,
    uint8_t*data,
    size_tdata_size,
    size_t*data_length);

    psa_status_tpsa_export_public_key(mbedtls_svc_key_id_tkey,
    uint8_t*data,
    size_tdata_size,
    size_t*data_length);

    psa_status_tpsa_hash_compute(psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    uint8_t*hash,
    size_thash_size,
    size_t*hash_length);

    psa_status_tpsa_hash_compare(psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    constuint8_t*hash,
    size_thash_length);

    typedefstructpsa_hash_operation_spsa_hash_operation_t;

    #ifdef__DOXYGEN_ONLY__
    /*Thisisanexampledefinitionfordocumentationpurposes.
    *Implementationsshoulddefineasuitablevaluein`crypto_struct.h`.
    */
    #definePSA_HASH_OPERATION_INIT{0}
    #endif

    staticpsa_hash_operation_tpsa_hash_operation_init(void);

    psa_status_tpsa_hash_setup(psa_hash_operation_t*operation,
    psa_algorithm_talg);

    psa_status_tpsa_hash_update(psa_hash_operation_t*operation,
    constuint8_t*input,
    size_tinput_length);

    psa_status_tpsa_hash_finish(psa_hash_operation_t*operation,
    uint8_t*hash,
    size_thash_size,
    size_t*hash_length);

    psa_status_tpsa_hash_verify(psa_hash_operation_t*operation,
    constuint8_t*hash,
    size_thash_length);

    psa_status_tpsa_hash_abort(psa_hash_operation_t*operation);

    psa_status_tpsa_hash_clone(constpsa_hash_operation_t*source_operation,
    psa_hash_operation_t*target_operation);

    psa_status_tpsa_mac_compute(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    uint8_t*mac,
    size_tmac_size,
    size_t*mac_length);

    psa_status_tpsa_mac_verify(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    constuint8_t*mac,
    size_tmac_length);

    typedefstructpsa_mac_operation_spsa_mac_operation_t;

    #ifdef__DOXYGEN_ONLY__
    /*Thisisanexampledefinitionfordocumentationpurposes.
    *Implementationsshoulddefineasuitablevaluein`crypto_struct.h`.
    */
    #definePSA_MAC_OPERATION_INIT{0}
    #endif

    staticpsa_mac_operation_tpsa_mac_operation_init(void);

    psa_status_tpsa_mac_sign_setup(psa_mac_operation_t*operation,
    mbedtls_svc_key_id_tkey,
    psa_algorithm_talg);

    psa_status_tpsa_mac_verify_setup(psa_mac_operation_t*operation,
    mbedtls_svc_key_id_tkey,
    psa_algorithm_talg);

    psa_status_tpsa_mac_update(psa_mac_operation_t*operation,
    constuint8_t*input,
    size_tinput_length);

    psa_status_tpsa_mac_sign_finish(psa_mac_operation_t*operation,
    uint8_t*mac,
    size_tmac_size,
    size_t*mac_length);

    psa_status_tpsa_mac_verify_finish(psa_mac_operation_t*operation,
    constuint8_t*mac,
    size_tmac_length);

    psa_status_tpsa_mac_abort(psa_mac_operation_t*operation);

    psa_status_tpsa_cipher_encrypt(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    psa_status_tpsa_cipher_decrypt(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    typedefstructpsa_cipher_operation_spsa_cipher_operation_t;

    #ifdef__DOXYGEN_ONLY__
    /*Thisisanexampledefinitionfordocumentationpurposes.
    *Implementationsshoulddefineasuitablevaluein`crypto_struct.h`.
    */
    #definePSA_CIPHER_OPERATION_INIT{0}
    #endif

    staticpsa_cipher_operation_tpsa_cipher_operation_init(void);

    psa_status_tpsa_cipher_encrypt_setup(psa_cipher_operation_t*operation,
    mbedtls_svc_key_id_tkey,
    psa_algorithm_talg);

    psa_status_tpsa_cipher_decrypt_setup(psa_cipher_operation_t*operation,
    mbedtls_svc_key_id_tkey,
    psa_algorithm_talg);

    psa_status_tpsa_cipher_generate_iv(psa_cipher_operation_t*operation,
    uint8_t*iv,
    size_tiv_size,
    size_t*iv_length);

    psa_status_tpsa_cipher_set_iv(psa_cipher_operation_t*operation,
    constuint8_t*iv,
    size_tiv_length);

    psa_status_tpsa_cipher_update(psa_cipher_operation_t*operation,
    constuint8_t*input,
    size_tinput_length,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    psa_status_tpsa_cipher_finish(psa_cipher_operation_t*operation,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    psa_status_tpsa_cipher_abort(psa_cipher_operation_t*operation);

    psa_status_tpsa_aead_encrypt(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*nonce,
    size_tnonce_length,
    constuint8_t*additional_data,
    size_tadditional_data_length,
    constuint8_t*plaintext,
    size_tplaintext_length,
    uint8_t*ciphertext,
    size_tciphertext_size,
    size_t*ciphertext_length);

    psa_status_tpsa_aead_decrypt(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*nonce,
    size_tnonce_length,
    constuint8_t*additional_data,
    size_tadditional_data_length,
    constuint8_t*ciphertext,
    size_tciphertext_length,
    uint8_t*plaintext,
    size_tplaintext_size,
    size_t*plaintext_length);

    typedefstructpsa_aead_operation_spsa_aead_operation_t;

    #ifdef__DOXYGEN_ONLY__
    /*Thisisanexampledefinitionfordocumentationpurposes.
    *Implementationsshoulddefineasuitablevaluein`crypto_struct.h`.
    */
    #definePSA_AEAD_OPERATION_INIT{0}
    #endif

    staticpsa_aead_operation_tpsa_aead_operation_init(void);

    psa_status_tpsa_aead_encrypt_setup(psa_aead_operation_t*operation,
    mbedtls_svc_key_id_tkey,
    psa_algorithm_talg);

    psa_status_tpsa_aead_decrypt_setup(psa_aead_operation_t*operation,
    mbedtls_svc_key_id_tkey,
    psa_algorithm_talg);

    psa_status_tpsa_aead_generate_nonce(psa_aead_operation_t*operation,
    uint8_t*nonce,
    size_tnonce_size,
    size_t*nonce_length);

    psa_status_tpsa_aead_set_nonce(psa_aead_operation_t*operation,
    constuint8_t*nonce,
    size_tnonce_length);

    psa_status_tpsa_aead_set_lengths(psa_aead_operation_t*operation,
    size_tad_length,
    size_tplaintext_length);

    psa_status_tpsa_aead_update_ad(psa_aead_operation_t*operation,
    constuint8_t*input,
    size_tinput_length);

    psa_status_tpsa_aead_update(psa_aead_operation_t*operation,
    constuint8_t*input,
    size_tinput_length,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    psa_status_tpsa_aead_finish(psa_aead_operation_t*operation,
    uint8_t*ciphertext,
    size_tciphertext_size,
    size_t*ciphertext_length,
    uint8_t*tag,
    size_ttag_size,
    size_t*tag_length);

    psa_status_tpsa_aead_verify(psa_aead_operation_t*operation,
    uint8_t*plaintext,
    size_tplaintext_size,
    size_t*plaintext_length,
    constuint8_t*tag,
    size_ttag_length);

    psa_status_tpsa_aead_abort(psa_aead_operation_t*operation);

    psa_status_tpsa_sign_message(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    uint8_t*signature,
    size_tsignature_size,
    size_t*signature_length);

    psa_status_tpsa_verify_message(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    constuint8_t*signature,
    size_tsignature_length);

    psa_status_tpsa_sign_hash(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*hash,
    size_thash_length,
    uint8_t*signature,
    size_tsignature_size,
    size_t*signature_length);

    psa_status_tpsa_verify_hash(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*hash,
    size_thash_length,
    constuint8_t*signature,
    size_tsignature_length);

    psa_status_tpsa_asymmetric_encrypt(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    constuint8_t*salt,
    size_tsalt_length,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    psa_status_tpsa_asymmetric_decrypt(mbedtls_svc_key_id_tkey,
    psa_algorithm_talg,
    constuint8_t*input,
    size_tinput_length,
    constuint8_t*salt,
    size_tsalt_length,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    typedefstructpsa_key_derivation_spsa_key_derivation_operation_t;

    #ifdef__DOXYGEN_ONLY__
    /*Thisisanexampledefinitionfordocumentationpurposes.
    *Implementationsshoulddefineasuitablevaluein`crypto_struct.h`.
    */
    #definePSA_KEY_DERIVATION_OPERATION_INIT{0}
    #endif

    staticpsa_key_derivation_operation_tpsa_key_derivation_operation_init(void);

    psa_status_tpsa_key_derivation_setup(
    psa_key_derivation_operation_t*operation,
    psa_algorithm_talg);

    psa_status_tpsa_key_derivation_get_capacity(
    constpsa_key_derivation_operation_t*operation,
    size_t*capacity);

    psa_status_tpsa_key_derivation_set_capacity(
    psa_key_derivation_operation_t*operation,
    size_tcapacity);

    #definePSA_KEY_DERIVATION_UNLIMITED_CAPACITY((size_t)(-1))

    psa_status_tpsa_key_derivation_input_bytes(
    psa_key_derivation_operation_t*operation,
    psa_key_derivation_step_tstep,
    constuint8_t*data,
    size_tdata_length);

    psa_status_tpsa_key_derivation_input_key(
    psa_key_derivation_operation_t*operation,
    psa_key_derivation_step_tstep,
    mbedtls_svc_key_id_tkey);

    psa_status_tpsa_key_derivation_key_agreement(
    psa_key_derivation_operation_t*operation,
    psa_key_derivation_step_tstep,
    mbedtls_svc_key_id_tprivate_key,
    constuint8_t*peer_key,
    size_tpeer_key_length);

    psa_status_tpsa_key_derivation_output_bytes(
    psa_key_derivation_operation_t*operation,
    uint8_t*output,
    size_toutput_length);

    psa_status_tpsa_key_derivation_output_key(
    constpsa_key_attributes_t*attributes,
    psa_key_derivation_operation_t*operation,
    mbedtls_svc_key_id_t*key);

    psa_status_tpsa_key_derivation_abort(
    psa_key_derivation_operation_t*operation);

    psa_status_tpsa_raw_key_agreement(psa_algorithm_talg,
    mbedtls_svc_key_id_tprivate_key,
    constuint8_t*peer_key,
    size_tpeer_key_length,
    uint8_t*output,
    size_toutput_size,
    size_t*output_length);

    psa_status_tpsa_generate_random(uint8_t*output,
    size_toutput_size);

    psa_status_tpsa_generate_key(constpsa_key_attributes_t*attributes,
    mbedtls_svc_key_id_t*key);

    #ifdef__cplusplus
    }
    #endif

    /*Thefile"crypto_sizes.h"containsdefinitionsforsizecalculation
    *macroswhosedefinitionsareimplementation-specific.*/
    #include"crypto_sizes.h"

    /*Thefile"crypto_struct.h"containsdefinitionsfor
    *implementation-specificstructsthataredeclaredabove.*/
    #include"crypto_struct.h"

    /*Thefile"crypto_extra.h"containsvendor-specificdefinitions.This
    *canincludevendor-definedalgorithms,extrafunctions,etc.*/
    #include"crypto_extra.h"

    #endif/*PSA_CRYPTO_H*/