mbed TLS v3.1.0
Macros | Typedefs | Functions
crypto.h File Reference

Platform Security Architecture cryptography module. More...

#include "crypto_platform.h"
#include <stddef.h>
#include "crypto_types.h"
#include "crypto_values.h"
#include "crypto_sizes.h"
#include "crypto_struct.h"
#include "crypto_extra.h"
Include dependency graph for crypto.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PSA_CRYPTO_API_VERSION_MAJOR   1
 
#define PSA_CRYPTO_API_VERSION_MINOR   0
 
#define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY   ((size_t)(-1))
 

Typedefs

typedef struct psa_hash_operation_s psa_hash_operation_t
 
typedef struct psa_mac_operation_s psa_mac_operation_t
 
typedef struct
psa_cipher_operation_s 
psa_cipher_operation_t
 
typedef struct psa_aead_operation_s psa_aead_operation_t
 
typedef struct psa_key_derivation_s psa_key_derivation_operation_t
 

Functions

psa_status_t psa_crypto_init (void)
 Library initialization. More...
 
static psa_key_attributes_t psa_key_attributes_init (void)
 
static void psa_set_key_id (psa_key_attributes_t *attributes, mbedtls_svc_key_id_t key)
 
static void mbedtls_set_key_owner_id (psa_key_attributes_t *attributes, mbedtls_key_owner_id_t owner)
 
static void psa_set_key_lifetime (psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
 
static mbedtls_svc_key_id_t psa_get_key_id (const psa_key_attributes_t *attributes)
 
static psa_key_lifetime_t psa_get_key_lifetime (const psa_key_attributes_t *attributes)
 
static void psa_set_key_usage_flags (psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
 
static psa_key_usage_t psa_get_key_usage_flags (const psa_key_attributes_t *attributes)
 
static void psa_set_key_algorithm (psa_key_attributes_t *attributes, psa_algorithm_t alg)
 
static psa_algorithm_t psa_get_key_algorithm (const psa_key_attributes_t *attributes)
 
static void psa_set_key_type (psa_key_attributes_t *attributes, psa_key_type_t type)
 
static void psa_set_key_bits (psa_key_attributes_t *attributes, size_t bits)
 
static psa_key_type_t psa_get_key_type (const psa_key_attributes_t *attributes)
 
static size_t psa_get_key_bits (const psa_key_attributes_t *attributes)
 
psa_status_t psa_get_key_attributes (mbedtls_svc_key_id_t key, psa_key_attributes_t *attributes)
 
void psa_reset_key_attributes (psa_key_attributes_t *attributes)
 
psa_status_t psa_purge_key (mbedtls_svc_key_id_t key)
 
psa_status_t psa_copy_key (mbedtls_svc_key_id_t source_key, const psa_key_attributes_t *attributes, mbedtls_svc_key_id_t *target_key)
 
psa_status_t psa_destroy_key (mbedtls_svc_key_id_t key)
 Destroy a key. More...
 
psa_status_t psa_import_key (const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, mbedtls_svc_key_id_t *key)
 Import a key in binary format. More...
 
psa_status_t psa_export_key (mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length)
 Export a key in binary format. More...
 
psa_status_t psa_export_public_key (mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length)
 Export a public key or the public part of a key pair in binary format. More...
 
psa_status_t psa_hash_compute (psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *hash, size_t hash_size, size_t *hash_length)
 
psa_status_t psa_hash_compare (psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *hash, size_t hash_length)
 
static psa_hash_operation_t psa_hash_operation_init (void)
 
psa_status_t psa_hash_setup (psa_hash_operation_t *operation, psa_algorithm_t alg)
 
psa_status_t psa_hash_update (psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)
 
psa_status_t psa_hash_finish (psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)
 
psa_status_t psa_hash_verify (psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_length)
 
psa_status_t psa_hash_abort (psa_hash_operation_t *operation)
 
psa_status_t psa_hash_clone (const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation)
 
psa_status_t psa_mac_compute (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *mac, size_t mac_size, size_t *mac_length)
 
psa_status_t psa_mac_verify (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *mac, size_t mac_length)
 
static psa_mac_operation_t psa_mac_operation_init (void)
 
psa_status_t psa_mac_sign_setup (psa_mac_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 
psa_status_t psa_mac_verify_setup (psa_mac_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 
psa_status_t psa_mac_update (psa_mac_operation_t *operation, const uint8_t *input, size_t input_length)
 
psa_status_t psa_mac_sign_finish (psa_mac_operation_t *operation, uint8_t *mac, size_t mac_size, size_t *mac_length)
 
psa_status_t psa_mac_verify_finish (psa_mac_operation_t *operation, const uint8_t *mac, size_t mac_length)
 
psa_status_t psa_mac_abort (psa_mac_operation_t *operation)
 
psa_status_t psa_cipher_encrypt (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t psa_cipher_decrypt (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
 
static psa_cipher_operation_t psa_cipher_operation_init (void)
 
psa_status_t psa_cipher_encrypt_setup (psa_cipher_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 
psa_status_t psa_cipher_decrypt_setup (psa_cipher_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 
psa_status_t psa_cipher_generate_iv (psa_cipher_operation_t *operation, uint8_t *iv, size_t iv_size, size_t *iv_length)
 
psa_status_t psa_cipher_set_iv (psa_cipher_operation_t *operation, const uint8_t *iv, size_t iv_length)
 
psa_status_t psa_cipher_update (psa_cipher_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t psa_cipher_finish (psa_cipher_operation_t *operation, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t psa_cipher_abort (psa_cipher_operation_t *operation)
 
psa_status_t psa_aead_encrypt (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *nonce, size_t nonce_length, const uint8_t *additional_data, size_t additional_data_length, const uint8_t *plaintext, size_t plaintext_length, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length)
 
psa_status_t psa_aead_decrypt (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *nonce, size_t nonce_length, const uint8_t *additional_data, size_t additional_data_length, const uint8_t *ciphertext, size_t ciphertext_length, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length)
 
static psa_aead_operation_t psa_aead_operation_init (void)
 
psa_status_t psa_aead_encrypt_setup (psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 
psa_status_t psa_aead_decrypt_setup (psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 
psa_status_t psa_aead_generate_nonce (psa_aead_operation_t *operation, uint8_t *nonce, size_t nonce_size, size_t *nonce_length)
 
psa_status_t psa_aead_set_nonce (psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length)
 
psa_status_t psa_aead_set_lengths (psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length)
 
psa_status_t psa_aead_update_ad (psa_aead_operation_t *operation, const uint8_t *input, size_t input_length)
 
psa_status_t psa_aead_update (psa_aead_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t psa_aead_finish (psa_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length, uint8_t *tag, size_t tag_size, size_t *tag_length)
 
psa_status_t psa_aead_verify (psa_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length, const uint8_t *tag, size_t tag_length)
 
psa_status_t psa_aead_abort (psa_aead_operation_t *operation)
 
psa_status_t psa_sign_message (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
 Sign a message with a private key. For hash-and-sign algorithms, this includes the hashing step. More...
 
psa_status_t psa_verify_message (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *signature, size_t signature_length)
 Verify the signature of a message with a public key, using a hash-and-sign verification algorithm. More...
 
psa_status_t psa_sign_hash (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
 Sign a hash or short message with a private key. More...
 
psa_status_t psa_verify_hash (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length)
 Verify the signature of a hash or short message using a public key. More...
 
psa_status_t psa_asymmetric_encrypt (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
 Encrypt a short message with a public key. More...
 
psa_status_t psa_asymmetric_decrypt (mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
 Decrypt a short message with a private key. More...
 
static
psa_key_derivation_operation_t 
psa_key_derivation_operation_init (void)
 
psa_status_t psa_key_derivation_setup (psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
 
psa_status_t psa_key_derivation_get_capacity (const psa_key_derivation_operation_t *operation, size_t *capacity)
 
psa_status_t psa_key_derivation_set_capacity (psa_key_derivation_operation_t *operation, size_t capacity)
 
psa_status_t psa_key_derivation_input_bytes (psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, const uint8_t *data, size_t data_length)
 
psa_status_t psa_key_derivation_input_integer (psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, uint64_t value)
 
psa_status_t psa_key_derivation_input_key (psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, mbedtls_svc_key_id_t key)
 
psa_status_t psa_key_derivation_key_agreement (psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, mbedtls_svc_key_id_t private_key, const uint8_t *peer_key, size_t peer_key_length)
 
psa_status_t psa_key_derivation_output_bytes (psa_key_derivation_operation_t *operation, uint8_t *output, size_t output_length)
 
psa_status_t psa_key_derivation_output_key (const psa_key_attributes_t *attributes, psa_key_derivation_operation_t *operation, mbedtls_svc_key_id_t *key)
 
psa_status_t psa_key_derivation_verify_bytes (psa_key_derivation_operation_t *operation, const uint8_t *expected_output, size_t output_length)
 
psa_status_t psa_key_derivation_verify_key (psa_key_derivation_operation_t *operation, psa_key_id_t expected)
 
psa_status_t psa_key_derivation_abort (psa_key_derivation_operation_t *operation)
 
psa_status_t psa_raw_key_agreement (psa_algorithm_t alg, mbedtls_svc_key_id_t private_key, const uint8_t *peer_key, size_t peer_key_length, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t psa_generate_random (uint8_t *output, size_t output_size)
 Generate random bytes. More...
 
psa_status_t psa_generate_key (const psa_key_attributes_t *attributes, mbedtls_svc_key_id_t *key)
 Generate a key or key pair. More...
 

Detailed Description

Platform Security Architecture cryptography module.

Definition in file crypto.h.