Mbed OS Reference
Loading...
Searching...
No Matches
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"

Go to the source code of this file.

Macros

#define PSA_CRYPTO_API_VERSION_MAJOR   1
 The major version of this implementation of the PSA Crypto API. More...
 
#define PSA_CRYPTO_API_VERSION_MINOR   0
 The minor version of this implementation of the PSA Crypto API. More...
 
#define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY   ((size_t)(-1))
 Use the maximum possible capacity for a key derivation operation. More...
 

Typedefs

typedef struct psa_hash_operation_s psa_hash_operation_t
 The type of the state data structure for multipart hash operations. More...
 
typedef struct psa_mac_operation_s psa_mac_operation_t
 The type of the state data structure for multipart MAC operations. More...
 
typedef struct psa_cipher_operation_s psa_cipher_operation_t
 The type of the state data structure for multipart cipher operations. More...
 
typedef struct psa_aead_operation_s psa_aead_operation_t
 The type of the state data structure for multipart AEAD operations. More...
 
typedef struct psa_key_derivation_s psa_key_derivation_operation_t
 The type of the state data structure for key derivation operations. More...
 

Functions

psa_status_t psa_crypto_init (void)
 Library initialization. More...
 
psa_status_t psa_get_key_attributes (mbedtls_svc_key_id_t key, psa_key_attributes_t *attributes)
 Retrieve the attributes of a key. More...
 
void psa_reset_key_attributes (psa_key_attributes_t *attributes)
 Reset a key attribute structure to a freshly initialized state. More...
 
psa_status_t psa_purge_key (mbedtls_svc_key_id_t key)
 Remove non-essential copies of key material from memory. More...
 
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)
 Make a copy of a key. More...
 
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)
 Calculate the hash (digest) of a message. More...
 
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)
 Calculate the hash (digest) of a message and compare it with a reference value. More...
 
psa_status_t psa_hash_setup (psa_hash_operation_t *operation, psa_algorithm_t alg)
 Set up a multipart hash operation. More...
 
psa_status_t psa_hash_update (psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)
 Add a message fragment to a multipart hash operation. More...
 
psa_status_t psa_hash_finish (psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)
 Finish the calculation of the hash of a message. More...
 
psa_status_t psa_hash_verify (psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_length)
 Finish the calculation of the hash of a message and compare it with an expected value. More...
 
psa_status_t psa_hash_abort (psa_hash_operation_t *operation)
 Abort a hash operation. More...
 
psa_status_t psa_hash_clone (const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation)
 Clone a hash operation. More...
 
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)
 Calculate the MAC (message authentication code) of a message. More...
 
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)
 Calculate the MAC of a message and compare it with a reference value. More...
 
psa_status_t psa_mac_sign_setup (psa_mac_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 Set up a multipart MAC calculation operation. More...
 
psa_status_t psa_mac_verify_setup (psa_mac_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 Set up a multipart MAC verification operation. More...
 
psa_status_t psa_mac_update (psa_mac_operation_t *operation, const uint8_t *input, size_t input_length)
 Add a message fragment to a multipart MAC operation. More...
 
psa_status_t psa_mac_sign_finish (psa_mac_operation_t *operation, uint8_t *mac, size_t mac_size, size_t *mac_length)
 Finish the calculation of the MAC of a message. More...
 
psa_status_t psa_mac_verify_finish (psa_mac_operation_t *operation, const uint8_t *mac, size_t mac_length)
 Finish the calculation of the MAC of a message and compare it with an expected value. More...
 
psa_status_t psa_mac_abort (psa_mac_operation_t *operation)
 Abort a MAC operation. More...
 
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)
 Encrypt a message using a symmetric cipher. More...
 
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)
 Decrypt a message using a symmetric cipher. More...
 
psa_status_t psa_cipher_encrypt_setup (psa_cipher_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 Set the key for a multipart symmetric encryption operation. More...
 
psa_status_t psa_cipher_decrypt_setup (psa_cipher_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 Set the key for a multipart symmetric decryption operation. More...
 
psa_status_t psa_cipher_generate_iv (psa_cipher_operation_t *operation, uint8_t *iv, size_t iv_size, size_t *iv_length)
 Generate an IV for a symmetric encryption operation. More...
 
psa_status_t psa_cipher_set_iv (psa_cipher_operation_t *operation, const uint8_t *iv, size_t iv_length)
 Set the IV for a symmetric encryption or decryption operation. More...
 
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)
 Encrypt or decrypt a message fragment in an active cipher operation. More...
 
psa_status_t psa_cipher_finish (psa_cipher_operation_t *operation, uint8_t *output, size_t output_size, size_t *output_length)
 Finish encrypting or decrypting a message in a cipher operation. More...
 
psa_status_t psa_cipher_abort (psa_cipher_operation_t *operation)
 Abort a cipher operation. More...
 
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)
 Process an authenticated encryption operation. More...
 
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)
 Process an authenticated decryption operation. More...
 
psa_status_t psa_aead_encrypt_setup (psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 Set the key for a multipart authenticated encryption operation. More...
 
psa_status_t psa_aead_decrypt_setup (psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
 Set the key for a multipart authenticated decryption operation. More...
 
psa_status_t psa_aead_generate_nonce (psa_aead_operation_t *operation, uint8_t *nonce, size_t nonce_size, size_t *nonce_length)
 Generate a random nonce for an authenticated encryption operation. More...
 
psa_status_t psa_aead_set_nonce (psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length)
 Set the nonce for an authenticated encryption or decryption operation. More...
 
psa_status_t psa_aead_set_lengths (psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length)
 Declare the lengths of the message and additional data for AEAD. More...
 
psa_status_t psa_aead_update_ad (psa_aead_operation_t *operation, const uint8_t *input, size_t input_length)
 Pass additional data to an active AEAD operation. More...
 
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)
 Encrypt or decrypt a message fragment in an active AEAD operation. More...
 
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)
 Finish encrypting a message in an AEAD operation. More...
 
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)
 Finish authenticating and decrypting a message in an AEAD operation. More...
 
psa_status_t psa_aead_abort (psa_aead_operation_t *operation)
 Abort an AEAD operation. 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 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...
 
psa_status_t psa_key_derivation_setup (psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
 Set up a key derivation operation. More...
 
psa_status_t psa_key_derivation_get_capacity (const psa_key_derivation_operation_t *operation, size_t *capacity)
 Retrieve the current capacity of a key derivation operation. More...
 
psa_status_t psa_key_derivation_set_capacity (psa_key_derivation_operation_t *operation, size_t capacity)
 Set the maximum capacity of a key derivation operation. More...
 
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)
 Provide an input for key derivation or key agreement. More...
 
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)
 Provide an input for key derivation in the form of a key. More...
 
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)
 Perform a key agreement and use the shared secret as input to a key derivation. More...
 
psa_status_t psa_key_derivation_output_bytes (psa_key_derivation_operation_t *operation, uint8_t *output, size_t output_length)
 Read some data from a key derivation operation. More...
 
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)
 Derive a key from an ongoing key derivation operation. More...
 
psa_status_t psa_key_derivation_abort (psa_key_derivation_operation_t *operation)
 Abort a key derivation operation. More...
 
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)
 Perform a key agreement and return the raw shared secret. More...
 
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.