crypto.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef PSA_CRYPTO_PSA_CRYPTO_H
23 #define PSA_CRYPTO_PSA_CRYPTO_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include <stdlib.h>
30 #include <string.h>
31 
32 #include "kernel_defines.h"
33 
34 #if IS_USED(MODULE_PSA_SECURE_ELEMENT_CONFIG)
35 #include "psa/crypto_se_config.h"
36 #endif
37 
38 #include "crypto_sizes.h"
39 #include "crypto_struct.h"
40 #include "crypto_values.h"
41 #include "crypto_types.h"
42 
46 #define PSA_CRYPTO_API_VERSION_MAJOR 1
47 
51 #define PSA_CRYPTO_API_VERSION_MINOR 1
52 
60 
85 
86 #if IS_USED(MODULE_PSA_AEAD) || defined(DOXYGEN)
143  psa_algorithm_t alg,
144  const uint8_t *nonce,
145  size_t nonce_length,
146  const uint8_t *additional_data,
147  size_t additional_data_length,
148  const uint8_t *plaintext,
149  size_t plaintext_length,
150  uint8_t *ciphertext,
151  size_t ciphertext_size,
152  size_t *ciphertext_length);
153 
210  psa_algorithm_t alg,
211  const uint8_t *nonce,
212  size_t nonce_length,
213  const uint8_t *additional_data,
214  size_t additional_data_length,
215  const uint8_t *ciphertext,
216  size_t ciphertext_length,
217  uint8_t *plaintext,
218  size_t plaintext_size,
219  size_t *plaintext_length);
220 
279  psa_key_id_t key,
280  psa_algorithm_t alg);
281 
340  psa_key_id_t key,
341  psa_algorithm_t alg);
342 
379  size_t ad_length,
380  size_t plaintext_length);
381 
428  uint8_t *nonce,
429  size_t nonce_size,
430  size_t *nonce_length);
431 
476  const uint8_t *nonce,
477  size_t nonce_length);
478 
522  const uint8_t *input,
523  size_t input_length);
524 
591  const uint8_t *input,
592  size_t input_length,
593  uint8_t *output,
594  size_t output_size,
595  size_t *output_length);
596 
665  uint8_t *ciphertext,
666  size_t ciphertext_size,
667  size_t *ciphertext_length,
668  uint8_t *tag,
669  size_t tag_size,
670  size_t *tag_length);
671 
739  uint8_t *plaintext,
740  size_t plaintext_size,
741  size_t *plaintext_length,
742  const uint8_t *tag,
743  size_t tag_length);
744 
771 #endif /* MODULE_PSA_AEAD */
772 
773 #if IS_USED(MODULE_PSA_ASYMMETRIC) || defined(DOXYGEN)
826  psa_algorithm_t alg,
827  const uint8_t *input,
828  size_t input_length,
829  const uint8_t *salt,
830  size_t salt_length,
831  uint8_t *output,
832  size_t output_size,
833  size_t *output_length);
834 
888  psa_algorithm_t alg,
889  const uint8_t *input,
890  size_t input_length,
891  const uint8_t *salt,
892  size_t salt_length,
893  uint8_t *output,
894  size_t output_size,
895  size_t *output_length);
896 #endif /* MODULE_PSA_ASYMMETRIC */
897 
898 
899 #if IS_USED(MODULE_PSA_CIPHER) || defined(DOXYGEN)
924 
989  psa_algorithm_t alg,
990  const uint8_t *input,
991  size_t input_length,
992  uint8_t *output,
993  size_t output_size,
994  size_t *output_length);
995 
1052  psa_key_id_t key,
1053  psa_algorithm_t alg);
1054 
1113  psa_algorithm_t alg,
1114  const uint8_t *input,
1115  size_t input_length,
1116  uint8_t *output,
1117  size_t output_size,
1118  size_t *output_length);
1119 
1178  psa_key_id_t key,
1179  psa_algorithm_t alg);
1180 
1234  uint8_t *output,
1235  size_t output_size,
1236  size_t *output_length);
1237 
1288  uint8_t *iv,
1289  size_t iv_size,
1290  size_t *iv_length);
1291 
1335  const uint8_t *iv,
1336  size_t iv_length);
1337 
1389  const uint8_t *input,
1390  size_t input_length,
1391  uint8_t *output,
1392  size_t output_size,
1393  size_t *output_length);
1394 #endif /* MODULE_PSA_CIPHER */
1395 
1396 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT) || defined(DOXYGEN)
1489  const psa_key_attributes_t *attributes,
1490  psa_key_id_t *target_key);
1491 
1544 
1653  uint8_t *data,
1654  size_t data_size,
1655  size_t *data_length);
1656 
1738  uint8_t *data,
1739  size_t data_size,
1740  size_t *data_length);
1741 
1754 psa_status_t psa_builtin_generate_key(const psa_key_attributes_t *attributes, uint8_t *key_buffer,
1755  size_t key_buffer_size, size_t *key_buffer_length);
1756 
1813  psa_key_id_t *key);
1814 #endif /* MODULE_PSA_KEY_MANAGEMENT */
1815 
1829  size_t output_size);
1830 
1854  size_t output_size);
1855 
1856 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT) || defined(DOXYGEN)
1867 static inline void psa_set_key_algorithm(psa_key_attributes_t *attributes,
1868  psa_algorithm_t alg)
1869 {
1870  attributes->policy.alg = alg;
1871 }
1872 
1881 {
1882  return attributes->policy.alg;
1883 }
1884 
1895 static inline void psa_set_key_bits(psa_key_attributes_t *attributes,
1896  size_t bits)
1897 {
1898  attributes->bits = bits;
1899 }
1900 
1908 static inline size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
1909 {
1910  return attributes->bits;
1911 }
1912 
1929 static inline void psa_set_key_id(psa_key_attributes_t *attributes, psa_key_id_t id)
1930 {
1931  attributes->id = id;
1932 }
1933 
1943 static inline psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
1944 {
1945  return attributes->id;
1946 }
1947 
1966 static inline void psa_set_key_lifetime(psa_key_attributes_t *attributes,
1967  psa_key_lifetime_t lifetime)
1968 {
1969  attributes->lifetime = lifetime;
1970 }
1971 
1980 {
1981  return attributes->lifetime;
1982 }
1983 
1993 static inline void psa_set_key_type(psa_key_attributes_t *attributes,
1994  psa_key_type_t type)
1995 {
1996  attributes->type = type;
1997 }
1998 
2006 static inline psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
2007 {
2008  return attributes->type;
2009 }
2010 
2022 static inline void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
2023  psa_key_usage_t usage_flags)
2024 {
2025  attributes->policy.usage = usage_flags;
2026 }
2027 
2036 {
2037  return attributes->policy.usage;
2038 }
2039 
2051 static inline void psa_reset_key_attributes(psa_key_attributes_t *attributes)
2052 {
2053  *attributes = psa_key_attributes_init();
2054 }
2055 
2086  psa_key_attributes_t *attributes);
2087 #endif /* MODULE_PSA_KEY_MANAGEMENT */
2088 
2089 #if IS_USED(MODULE_PSA_HASH) || defined(DOXYGEN)
2116 
2146  psa_hash_operation_t *target_operation);
2147 
2177  const uint8_t *input,
2178  size_t input_length,
2179  const uint8_t *hash,
2180  size_t hash_length);
2181 
2216  const uint8_t *input,
2217  size_t input_length,
2218  uint8_t *hash,
2219  size_t hash_size,
2220  size_t *hash_length);
2221 
2264  uint8_t *hash,
2265  size_t hash_size,
2266  size_t *hash_length);
2267 
2305  const uint8_t *hash_state,
2306  size_t hash_state_length);
2307 
2350  psa_algorithm_t alg);
2351 
2428  uint8_t *hash_state,
2429  size_t hash_state_size,
2430  size_t *hash_state_length);
2431 
2457  const uint8_t *input,
2458  size_t input_length);
2459 
2493  const uint8_t *hash,
2494  size_t hash_length);
2495 #endif /* MODULE_PSA_HASH */
2496 
2497 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT) || defined(DOXYGEN)
2546  const uint8_t *data, size_t data_length,
2547  uint8_t *key_buffer, size_t key_buffer_size,
2548  size_t *key_buffer_length, size_t *bits);
2549 
2637  const uint8_t *data,
2638  size_t data_length,
2639  psa_key_id_t *key);
2640 #endif /* MODULE_PSA_KEY_MANAGEMENT */
2641 
2642 #if IS_USED(MODULE_PSA_KEY_DERIVATION) || defined(DOXYGEN)
2666 
2693  size_t *capacity);
2694 
2743  const uint8_t *data,
2744  size_t data_length);
2745 
2791  uint64_t value);
2792 
2860  psa_key_id_t key);
2861 
2923  psa_key_id_t private_key,
2924  const uint8_t *peer_key,
2925  size_t peer_key_length);
2926 
2967  uint8_t *output,
2968  size_t output_length);
2969 
3125  psa_key_derivation_operation_t *operation,
3126  psa_key_id_t *key);
3127 
3149  size_t capacity);
3150 
3209  psa_algorithm_t alg);
3210 
3268  const uint8_t *expected_output,
3269  size_t output_length);
3270 
3331  psa_key_id_t expected);
3332 #endif /* PSA_CRYPTO_KEY_DERIVATION */
3333 
3334 #if IS_USED(MODULE_PSA_MAC) || defined(DOXYGEN)
3358 
3411  psa_algorithm_t alg,
3412  const uint8_t *input,
3413  size_t input_length,
3414  uint8_t *mac,
3415  size_t mac_size,
3416  size_t *mac_length);
3417 
3467  uint8_t *mac,
3468  size_t mac_size,
3469  size_t *mac_length);
3470 
3528  psa_key_id_t key,
3529  psa_algorithm_t alg);
3530 
3560  const uint8_t *input,
3561  size_t input_length);
3562 
3601  psa_algorithm_t alg,
3602  const uint8_t *input,
3603  size_t input_length,
3604  const uint8_t *mac,
3605  size_t mac_length);
3606 
3643  const uint8_t *mac,
3644  size_t mac_length);
3645 
3702  psa_key_id_t key,
3703  psa_algorithm_t alg);
3704 #endif /* MODULE_PSA_MAC */
3705 
3706 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT) || defined(DOXYGEN)
3734 #endif /* MODULE_PSA_KEY_MANAGEMENT */
3735 
3736 #if IS_USED(MODULE_PSA_KEY_AGREEMENT) || defined(DOXYGEN)
3801  psa_key_id_t private_key,
3802  const uint8_t *peer_key,
3803  size_t peer_key_length,
3804  uint8_t *output,
3805  size_t output_size,
3806  size_t *output_length);
3807 #endif /* MODULE_PSA_KEY_AGREEMENT */
3808 
3809 #if IS_USED(MODULE_PSA_ASYMMETRIC) || defined(DOXYGEN)
3879  psa_algorithm_t alg,
3880  const uint8_t *hash,
3881  size_t hash_length,
3882  uint8_t *signature,
3883  size_t signature_size,
3884  size_t *signature_length);
3885 
3944  psa_algorithm_t alg,
3945  const uint8_t *input,
3946  size_t input_length,
3947  uint8_t *signature,
3948  size_t signature_size,
3949  size_t *signature_length);
3950 
4014  psa_algorithm_t alg,
4015  const uint8_t *hash,
4016  size_t hash_length,
4017  const uint8_t *signature,
4018  size_t signature_length);
4019 
4070  psa_algorithm_t alg,
4071  const uint8_t *input,
4072  size_t input_length,
4073  const uint8_t *signature,
4074  size_t signature_length);
4075 #endif /* MODULE_PSA_ASYMMETRIC */
4076 
4077 #ifdef __cplusplus
4078 }
4079 #endif
4080 
4081 #endif /* PSA_CRYPTO_PSA_CRYPTO_H */
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: algorithm.h:39
static psa_key_attributes_t psa_key_attributes_init(void)
Return an initial value for a key attribute object.
Definition: attributes.h:174
psa_status_t psa_verify_hash(psa_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.
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.
psa_status_t psa_purge_key(psa_key_id_t key)
Remove non-essential copies of key material from memory.
psa_status_t psa_cipher_encrypt(psa_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.
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.
psa_status_t psa_raw_key_agreement(psa_algorithm_t alg, psa_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.
psa_status_t psa_aead_encrypt(psa_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.
psa_status_t psa_generate_random(uint8_t *output, size_t output_size)
Generate random bytes.
psa_status_t psa_asymmetric_decrypt(psa_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.
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.
psa_status_t psa_sign_message(psa_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.
psa_status_t psa_asymmetric_encrypt(psa_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.
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 initialization vector (IV) for a symmetric encryption operation.
psa_status_t psa_crypto_init(void)
Library initialization.
psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
Set the key for a multi-part authenticated decryption operation.
psa_status_t psa_cipher_decrypt(psa_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.
psa_status_t psa_hash_suspend(psa_hash_operation_t *operation, uint8_t *hash_state, size_t hash_state_size, size_t *hash_state_length)
Halt the hash operation and extract the intermediate state of the hash computation.
psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation)
Clone a hash operation.
psa_status_t psa_sign_hash(psa_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 an already-calculated hash with a private key.
static void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
Declare usage flags for a key.
Definition: crypto.h:2022
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.
psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, psa_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.
const char * psa_status_to_humanly_readable(psa_status_t status)
Helper function to convert PSA status values humanly readable.
psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
Set the key for a multi-part authenticated encryption operation.
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 multi-part MAC operation.
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.
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.
psa_status_t psa_builtin_generate_key(const psa_key_attributes_t *attributes, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length)
Built-in key generation function.
static size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
Retrieve the key size from key attributes.
Definition: crypto.h:1908
psa_status_t psa_export_key(psa_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length)
Export a key in binary format.
psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
Set up a multi-part MAC calculation operation.
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 multi-part hash operation.
static void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type)
Declare the type of a key.
Definition: crypto.h:1993
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.
psa_status_t psa_hash_resume(psa_hash_operation_t *operation, const uint8_t *hash_state, size_t hash_state_length)
Set up a multi-part hash operation using the hash suspend state from a previously suspended hash oper...
psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
Set up a multi-part MAC verification operation.
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.
psa_status_t psa_export_public_key(psa_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.
psa_status_t psa_copy_key(psa_key_id_t source_key, const psa_key_attributes_t *attributes, psa_key_id_t *target_key)
Make a copy of a key.
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.
psa_status_t psa_verify_message(psa_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.
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.
psa_status_t psa_hash_setup(psa_hash_operation_t *operation, psa_algorithm_t alg)
Set up a multipart hash operation.
psa_status_t psa_get_key_attributes(psa_key_id_t key, psa_key_attributes_t *attributes)
Retrieve the attributes of a key.
psa_status_t psa_builtin_generate_random(uint8_t *output, size_t output_size)
Built-in function for random number generation.
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.
psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
Abort a key derivation operation.
psa_status_t psa_generate_key(const psa_key_attributes_t *attributes, psa_key_id_t *key)
Generate a key or key pair.
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.
psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, const uint8_t *iv, size_t iv_length)
Set the initialization vector (IV) for a symmetric encryption or decryption operation.
psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
Set the key for a multi-part symmetric decryption operation.
static psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes)
Retrieve the lifetime from key attributes.
Definition: crypto.h:1979
static psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes)
Retrieve the usage flags from key attributes.
Definition: crypto.h:2035
psa_status_t psa_mac_verify(psa_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.
psa_status_t psa_key_derivation_input_key(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, psa_key_id_t key)
Provide an input for key derivation in the form of a key.
psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation)
Abort a cipher operation.
psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
Abort a hash operation.
psa_status_t psa_aead_decrypt(psa_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.
static void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
Set the location of a persistent key.
Definition: crypto.h:1966
psa_status_t psa_key_derivation_verify_key(psa_key_derivation_operation_t *operation, psa_key_id_t expected)
Compare output data from a key derivation operation to an expected value stored in a key.
psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
Set up a key derivation operation.
psa_status_t psa_builtin_import_key(const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, uint8_t *key_buffer, size_t key_buffer_size, size_t *key_buffer_length, size_t *bits)
Built-in key import function.
psa_status_t psa_key_derivation_input_integer(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, uint64_t value)
Provide a numeric input for key derivation or key agreement.
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.
static psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes)
Retrieve the permitted algorithm policy from key attributes.
Definition: crypto.h:1880
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.
psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
Set the key for a multi-part symmetric encryption operation.
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.
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.
psa_status_t psa_mac_abort(psa_mac_operation_t *operation)
Abort a MAC operation.
psa_status_t psa_import_key(const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, psa_key_id_t *key)
Import a key in binary format.
psa_status_t psa_key_derivation_output_key(const psa_key_attributes_t *attributes, psa_key_derivation_operation_t *operation, psa_key_id_t *key)
Derive a key from an ongoing key derivation operation.
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.
static void psa_set_key_id(psa_key_attributes_t *attributes, psa_key_id_t id)
Declare a key as persistent and set its key identifier.
Definition: crypto.h:1929
static psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
Retrieve the key identifier from key attributes.
Definition: crypto.h:1943
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.
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
Retrieve the key type from key attributes.
Definition: crypto.h:2006
psa_status_t psa_aead_abort(psa_aead_operation_t *operation)
Abort an AEAD operation.
static void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg)
Declare the permitted algorithm policy for a key.
Definition: crypto.h:1867
psa_status_t psa_key_derivation_verify_bytes(psa_key_derivation_operation_t *operation, const uint8_t *expected_output, size_t output_length)
Compare output data from a key derivation operation to an expected value.
psa_status_t psa_destroy_key(psa_key_id_t key)
Destroy a key.
static void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits)
Declare the size of a key.
Definition: crypto.h:1895
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.
static void psa_reset_key_attributes(psa_key_attributes_t *attributes)
Reset a key attribute object to a freshly initialized state.
Definition: crypto.h:2051
psa_status_t psa_mac_compute(psa_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 message authentication code (MAC) of a message.
Define structures für SE slot configurations.
Size definitions for PSA Crypto.
Structure definitions for PSA Crypto.
Type definitions for PSA Crypto.
uint16_t psa_key_derivation_step_t
Encoding of the step of a key derivation.
Definition: crypto_types.h:78
Value definitions for PSA Crypto.
uint32_t psa_key_id_t
Key identifier.
Definition: id.h:37
Common macros and compiler attributes/pragmas configuration.
uint32_t psa_key_lifetime_t
Encoding of key lifetimes.
Definition: lifetime.h:67
int32_t psa_status_t
Status code type used for all PSA Certified APIs.
Definition: error.h:41
uint16_t psa_key_type_t
Encoding of a key type.
Definition: type.h:45
Structure storing an AEAD operation context.
Definition: crypto_struct.h:37
Structure storing a cipher operation context.
Definition: crypto_struct.h:64
Structure containing a hash context and algorithm.
Structure storing key attributes.
Definition: attributes.h:52
psa_key_id_t id
Key identifier.
Definition: attributes.h:56
psa_key_bits_t bits
Size of key in bits.
Definition: attributes.h:54
psa_key_policy_t policy
Key usage policy.
Definition: attributes.h:57
psa_key_type_t type
Type of key.
Definition: attributes.h:53
psa_key_lifetime_t lifetime
Lifetime of key.
Definition: attributes.h:55
Structure storing a key derivation context.
psa_key_usage_t usage
Key usage policy.
Definition: attributes.h:40
psa_algorithm_t alg
Algorithm for key usage.
Definition: attributes.h:41
Structure storing a MAC operation context.
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
Definition: usage.h:34