TI OAD API Documentation  9.14.00
crypto.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * Copyright 2022-2024, Texas Instruments Incorporated
9  * SPDX-License-Identifier: Apache-2.0
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License"); you may
12  * not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
19  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * Modified by Texas Instruments to:
24  * - Replace interruptable hash signing operations with psa_hash_suspend()
25  * and psa_hash_resume().
26  * - Replace 'mbedtls_svc_key_id_t' with 'psa_key_id_t'.
27  * - Remove conditional compile for MBEDTLS_PSA_CRYPTO_STRUCT_FILE.
28  */
29 
30 #ifndef PSA_CRYPTO_H
31 #define PSA_CRYPTO_H
32 
33 /* clang-format off */
34 
35 #include <stddef.h>
36 
37 #ifdef __DOXYGEN_ONLY__
38 /* This __DOXYGEN_ONLY__ block contains mock definitions for things that
39  * must be defined in the crypto_platform.h header. These mock definitions
40  * are present in this file as a convenience to generate pretty-printed
41  * documentation that includes those definitions. */
42 
48 #endif /* __DOXYGEN_ONLY__ */
49 
50 /* The file "crypto_types.h" declares types that encode errors,
51  * algorithms, key types, policies, etc. */
52 #include "crypto_types.h"
53 
61 #define PSA_CRYPTO_API_VERSION_MAJOR 1
62 
66 #define PSA_CRYPTO_API_VERSION_MINOR 0
67 
70 /* The file "crypto_values.h" declares macros to build and analyze values
71  * of integral types defined in "crypto_types.h". */
72 #include "crypto_values.h"
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
110 psa_status_t psa_crypto_init(void);
111 
123 #ifdef __DOXYGEN_ONLY__
124  /* This is an example definition for documentation purposes.
125  * Implementations should define a suitable value in `crypto_struct.h`.
126  */
127  #define PSA_KEY_ATTRIBUTES_INIT \
128  { \
129  0 \
130  }
131 #endif
132 
135 static psa_key_attributes_t psa_key_attributes_init(void);
136 
157 static void psa_set_key_id(psa_key_attributes_t *attributes, psa_key_id_t key);
158 
159 #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
160 
174 static void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes,
175  mbedtls_key_owner_id_t owner);
176 #endif
177 
203 static void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime);
204 
217 static psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes);
218 
229 static psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes);
230 
247 static void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags);
248 
259 static psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes);
260 
291 static void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg);
292 
303 static psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes);
304 
319 static void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type);
320 
335 static void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits);
336 
347 static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes);
348 
359 static size_t psa_get_key_bits(const psa_key_attributes_t *attributes);
360 
389 psa_status_t psa_get_key_attributes(psa_key_id_t key, psa_key_attributes_t *attributes);
390 
403 void psa_reset_key_attributes(psa_key_attributes_t *attributes);
404 
432 psa_status_t psa_purge_key(psa_key_id_t key);
433 
522 psa_status_t psa_copy_key(psa_key_id_t source_key, const psa_key_attributes_t *attributes, psa_key_id_t *target_key);
523 
569 psa_status_t psa_destroy_key(psa_key_id_t key);
570 
648 psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
649  const uint8_t *data,
650  size_t data_length,
651  psa_key_id_t *key);
652 
653 
742 psa_status_t psa_export_key(psa_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length);
743 
814 psa_status_t psa_export_public_key(psa_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length);
815 
853 psa_status_t psa_hash_compute(psa_algorithm_t alg,
854  const uint8_t *input,
855  size_t input_length,
856  uint8_t *hash,
857  size_t hash_size,
858  size_t *hash_length);
859 
888 psa_status_t psa_hash_compare(psa_algorithm_t alg,
889  const uint8_t *input,
890  size_t input_length,
891  const uint8_t *hash,
892  size_t hash_length);
893 
922 typedef struct psa_hash_operation_s psa_hash_operation_t;
923 
929 #ifdef __DOXYGEN_ONLY__
930  /* This is an example definition for documentation purposes.
931  * Implementations should define a suitable value in `crypto_struct.h`.
932  */
933  #define PSA_HASH_OPERATION_INIT \
934  { \
935  0 \
936  }
937 #endif
938 
941 static psa_hash_operation_t psa_hash_operation_init(void);
942 
991 psa_status_t psa_hash_setup(psa_hash_operation_t *operation,
992  psa_algorithm_t alg);
993 
1017 psa_status_t psa_hash_update(psa_hash_operation_t *operation,
1018  const uint8_t *input,
1019  size_t input_length);
1020 
1063 psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
1064  uint8_t *hash,
1065  size_t hash_size,
1066  size_t *hash_length);
1067 
1104 psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
1105  const uint8_t *hash,
1106  size_t hash_length);
1107 
1133 psa_status_t psa_hash_abort(psa_hash_operation_t *operation);
1134 
1162 psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
1163  psa_hash_operation_t *target_operation);
1164 
1213 psa_status_t psa_mac_compute(psa_key_id_t key,
1214  psa_algorithm_t alg,
1215  const uint8_t *input,
1216  size_t input_length,
1217  uint8_t *mac,
1218  size_t mac_size,
1219  size_t *mac_length);
1220 
1254 psa_status_t psa_mac_verify(psa_key_id_t key,
1255  psa_algorithm_t alg,
1256  const uint8_t *input,
1257  size_t input_length,
1258  const uint8_t *mac,
1259  size_t mac_length);
1260 
1290 typedef struct psa_mac_operation_s psa_mac_operation_t;
1291 
1297 #ifdef __DOXYGEN_ONLY__
1298  /* This is an example definition for documentation purposes.
1299  * Implementations should define a suitable value in `crypto_struct.h`.
1300  */
1301  #define PSA_MAC_OPERATION_INIT \
1302  { \
1303  0 \
1304  }
1305 #endif
1306 
1309 static psa_mac_operation_t psa_mac_operation_init(void);
1310 
1369 psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg);
1370 
1430 psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg);
1431 
1458 psa_status_t psa_mac_update(psa_mac_operation_t *operation,
1459  const uint8_t *input,
1460  size_t input_length);
1461 
1507 psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
1508  uint8_t *mac,
1509  size_t mac_size,
1510  size_t *mac_length);
1511 
1550 psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
1551  const uint8_t *mac,
1552  size_t mac_length);
1553 
1579 psa_status_t psa_mac_abort(psa_mac_operation_t *operation);
1580 
1626 psa_status_t psa_cipher_encrypt(psa_key_id_t key,
1627  psa_algorithm_t alg,
1628  const uint8_t *input,
1629  size_t input_length,
1630  uint8_t *output,
1631  size_t output_size,
1632  size_t *output_length);
1633 
1673 psa_status_t psa_cipher_decrypt(psa_key_id_t key,
1674  psa_algorithm_t alg,
1675  const uint8_t *input,
1676  size_t input_length,
1677  uint8_t *output,
1678  size_t output_size,
1679  size_t *output_length);
1680 
1709 typedef struct psa_cipher_operation_s psa_cipher_operation_t;
1710 
1716 #ifdef __DOXYGEN_ONLY__
1717  /* This is an example definition for documentation purposes.
1718  * Implementations should define a suitable value in `crypto_struct.h`.
1719  */
1720  #define PSA_CIPHER_OPERATION_INIT \
1721  { \
1722  0 \
1723  }
1724 #endif
1725 
1728 static psa_cipher_operation_t psa_cipher_operation_init(void);
1729 
1789 psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg);
1790 
1850 psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg);
1851 
1886 psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
1887  uint8_t *iv,
1888  size_t iv_size,
1889  size_t *iv_length);
1890 
1927 psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
1928  const uint8_t *iv,
1929  size_t iv_length);
1930 
1968 psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
1969  const uint8_t *input,
1970  size_t input_length,
1971  uint8_t *output,
1972  size_t output_size,
1973  size_t *output_length);
1974 
2020 psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
2021  uint8_t *output,
2022  size_t output_size,
2023  size_t *output_length);
2024 
2050 psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation);
2051 
2119 psa_status_t psa_aead_encrypt(psa_key_id_t key,
2120  psa_algorithm_t alg,
2121  const uint8_t *nonce,
2122  size_t nonce_length,
2123  const uint8_t *additional_data,
2124  size_t additional_data_length,
2125  const uint8_t *plaintext,
2126  size_t plaintext_length,
2127  uint8_t *ciphertext,
2128  size_t ciphertext_size,
2129  size_t *ciphertext_length);
2130 
2192 psa_status_t psa_aead_decrypt(psa_key_id_t key,
2193  psa_algorithm_t alg,
2194  const uint8_t *nonce,
2195  size_t nonce_length,
2196  const uint8_t *additional_data,
2197  size_t additional_data_length,
2198  const uint8_t *ciphertext,
2199  size_t ciphertext_length,
2200  uint8_t *plaintext,
2201  size_t plaintext_size,
2202  size_t *plaintext_length);
2203 
2232 typedef struct psa_aead_operation_s psa_aead_operation_t;
2233 
2239 #ifdef __DOXYGEN_ONLY__
2240  /* This is an example definition for documentation purposes.
2241  * Implementations should define a suitable value in `crypto_struct.h`.
2242  */
2243  #define PSA_AEAD_OPERATION_INIT \
2244  { \
2245  0 \
2246  }
2247 #endif
2248 
2251 static psa_aead_operation_t psa_aead_operation_init(void);
2252 
2319 psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg);
2320 
2383 psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg);
2384 
2420 psa_status_t psa_aead_generate_nonce(psa_aead_operation_t *operation,
2421  uint8_t *nonce,
2422  size_t nonce_size,
2423  size_t *nonce_length);
2424 
2460 psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation,
2461  const uint8_t *nonce,
2462  size_t nonce_length);
2463 
2505 psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation,
2506  size_t ad_length,
2507  size_t plaintext_length);
2508 
2553 psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation,
2554  const uint8_t *input,
2555  size_t input_length);
2556 
2637 psa_status_t psa_aead_update(psa_aead_operation_t *operation,
2638  const uint8_t *input,
2639  size_t input_length,
2640  uint8_t *output,
2641  size_t output_size,
2642  size_t *output_length);
2643 
2723 psa_status_t psa_aead_finish(psa_aead_operation_t *operation,
2724  uint8_t *ciphertext,
2725  size_t ciphertext_size,
2726  size_t *ciphertext_length,
2727  uint8_t *tag,
2728  size_t tag_size,
2729  size_t *tag_length);
2730 
2806 psa_status_t psa_aead_verify(psa_aead_operation_t *operation,
2807  uint8_t *plaintext,
2808  size_t plaintext_size,
2809  size_t *plaintext_length,
2810  const uint8_t *tag,
2811  size_t tag_length);
2812 
2838 psa_status_t psa_aead_abort(psa_aead_operation_t *operation);
2839 
2907 psa_status_t psa_sign_message(psa_key_id_t key,
2908  psa_algorithm_t alg,
2909  const uint8_t *input,
2910  size_t input_length,
2911  uint8_t *signature,
2912  size_t signature_size,
2913  size_t *signature_length);
2914 
2962 psa_status_t psa_verify_message(psa_key_id_t key,
2963  psa_algorithm_t alg,
2964  const uint8_t *input,
2965  size_t input_length,
2966  const uint8_t *signature,
2967  size_t signature_length);
2968 
3018 psa_status_t psa_sign_hash(psa_key_id_t key,
3019  psa_algorithm_t alg,
3020  const uint8_t *hash,
3021  size_t hash_length,
3022  uint8_t *signature,
3023  size_t signature_size,
3024  size_t *signature_length);
3025 
3072 psa_status_t psa_verify_hash(psa_key_id_t key,
3073  psa_algorithm_t alg,
3074  const uint8_t *hash,
3075  size_t hash_length,
3076  const uint8_t *signature,
3077  size_t signature_length);
3078 
3130 psa_status_t psa_asymmetric_encrypt(psa_key_id_t key,
3131  psa_algorithm_t alg,
3132  const uint8_t *input,
3133  size_t input_length,
3134  const uint8_t *salt,
3135  size_t salt_length,
3136  uint8_t *output,
3137  size_t output_size,
3138  size_t *output_length);
3139 
3191 psa_status_t psa_asymmetric_decrypt(psa_key_id_t key,
3192  psa_algorithm_t alg,
3193  const uint8_t *input,
3194  size_t input_length,
3195  const uint8_t *salt,
3196  size_t salt_length,
3197  uint8_t *output,
3198  size_t output_size,
3199  size_t *output_length);
3200 
3236 typedef struct psa_key_derivation_s psa_key_derivation_operation_t;
3237 
3243 #ifdef __DOXYGEN_ONLY__
3244  /* This is an example definition for documentation purposes.
3245  * Implementations should define a suitable value in `crypto_struct.h`.
3246  */
3247  #define PSA_KEY_DERIVATION_OPERATION_INIT \
3248  { \
3249  0 \
3250  }
3251 #endif
3252 
3255 static psa_key_derivation_operation_t psa_key_derivation_operation_init(void);
3256 
3315 psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg);
3316 
3336 psa_status_t psa_key_derivation_get_capacity(const psa_key_derivation_operation_t *operation, size_t *capacity);
3337 
3362 psa_status_t psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, size_t capacity);
3363 
3371 #define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY ((size_t) (-1))
3372 
3414  psa_key_derivation_step_t step,
3415  const uint8_t *data,
3416  size_t data_length);
3417 
3456  psa_key_derivation_operation_t *operation,
3457  psa_key_derivation_step_t step,
3458  uint64_t value);
3459 
3523  psa_key_derivation_step_t step,
3524  psa_key_id_t key);
3525 
3590  psa_key_derivation_step_t step,
3591  psa_key_id_t private_key,
3592  const uint8_t *peer_key,
3593  size_t peer_key_length);
3594 
3636  uint8_t *output,
3637  size_t output_length);
3638 
3784 psa_status_t psa_key_derivation_output_key(
3785  const psa_key_attributes_t *attributes,
3786  psa_key_derivation_operation_t *operation,
3787  psa_key_id_t *key);
3788 
3842 psa_status_t psa_key_derivation_verify_bytes(
3843  psa_key_derivation_operation_t *operation,
3844  const uint8_t *expected_output,
3845  size_t output_length);
3846 
3906 psa_status_t psa_key_derivation_verify_key(
3907  psa_key_derivation_operation_t *operation,
3908  psa_key_id_t expected);
3909 
3934 
3985 psa_status_t psa_raw_key_agreement(psa_algorithm_t alg,
3986  psa_key_id_t private_key,
3987  const uint8_t *peer_key,
3988  size_t peer_key_length,
3989  uint8_t *output,
3990  size_t output_size,
3991  size_t *output_length);
3992 
4023 psa_status_t psa_generate_random(uint8_t *output, size_t output_size);
4024 
4069 psa_status_t psa_generate_key(const psa_key_attributes_t *attributes, psa_key_id_t *key);
4070 
4077 #if 1 /* Texas Instruments modification */
4078 
4100 psa_status_t psa_hash_resume(psa_hash_operation_t *operation, const uint8_t *hash_state, size_t hash_state_length);
4101 
4132 psa_status_t psa_hash_suspend(psa_hash_operation_t *operation,
4133  uint8_t *hash_state,
4134  size_t hash_state_size,
4135  size_t *hash_state_length);
4136 
4137 #else
4138 
4170 typedef struct psa_sign_hash_interruptible_operation_s psa_sign_hash_interruptible_operation_t;
4171 
4203 typedef struct psa_verify_hash_interruptible_operation_s psa_verify_hash_interruptible_operation_t;
4204 
4277 void psa_interruptible_set_max_ops(uint32_t max_ops);
4278 
4296 uint32_t psa_interruptible_get_max_ops(void);
4297 
4324 uint32_t psa_sign_hash_get_num_ops(
4325  const psa_sign_hash_interruptible_operation_t *operation);
4326 
4351 uint32_t psa_verify_hash_get_num_ops(
4352  const psa_verify_hash_interruptible_operation_t *operation);
4353 
4425 psa_status_t psa_sign_hash_start(
4426  psa_sign_hash_interruptible_operation_t *operation,
4427  psa_key_id_t key, psa_algorithm_t alg,
4428  const uint8_t *hash, size_t hash_length);
4429 
4518 psa_status_t psa_sign_hash_complete(
4519  psa_sign_hash_interruptible_operation_t *operation,
4520  uint8_t *signature, size_t signature_size,
4521  size_t *signature_length);
4522 
4560 psa_status_t psa_sign_hash_abort(
4561  psa_sign_hash_interruptible_operation_t *operation);
4562 
4637 psa_status_t psa_verify_hash_start(
4638  psa_verify_hash_interruptible_operation_t *operation,
4639  psa_key_id_t key, psa_algorithm_t alg,
4640  const uint8_t *hash, size_t hash_length,
4641  const uint8_t *signature, size_t signature_length);
4642 
4714 psa_status_t psa_verify_hash_complete(
4715  psa_verify_hash_interruptible_operation_t *operation);
4716 
4754 psa_status_t psa_verify_hash_abort(
4755  psa_verify_hash_interruptible_operation_t *operation);
4756 #endif
4757 
4760 #ifdef __cplusplus
4761 }
4762 #endif
4763 
4764 /* The file "crypto_sizes.h" contains definitions for size calculation
4765  * macros whose definitions are implementation-specific. */
4766 #include "crypto_sizes.h"
4767 
4768 /* The file "crypto_struct.h" contains definitions for
4769  * implementation-specific structs that are declared above. */
4770 #include "crypto_struct.h"
4771 
4772 /* The file "crypto_extra.h" contains vendor-specific definitions. This
4773  * can include vendor-defined algorithms, extra functions, etc. */
4774 #include "crypto_extra.h"
4775 
4776 #endif /* PSA_CRYPTO_H */
void psa_reset_key_attributes(psa_key_attributes_t *attributes)
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_generate_random(uint8_t *output, size_t output_size)
Generate random bytes.
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_get_key_attributes(psa_key_id_t key, psa_key_attributes_t *attributes)
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_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_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_aead_decrypt_setup(psa_aead_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, size_t capacity)
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. For hash-and-sign algorithms, this includes the hashing step...
psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
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_mac_verify_finish(psa_mac_operation_t *operation, const uint8_t *mac, size_t mac_length)
psa_status_t psa_key_derivation_verify_key(psa_key_derivation_operation_t *operation, psa_key_id_t expected)
struct psa_aead_operation_s psa_aead_operation_t
Definition: crypto.h:2232
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)
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_mac_abort(psa_mac_operation_t *operation)
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_mac_verify_setup(psa_mac_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_hash_resume(psa_hash_operation_t *operation, const uint8_t *hash_state, size_t hash_state_length)
Resume a previously suspended hash 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)
psa_status_t psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)
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)
psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length)
psa_status_t psa_key_derivation_get_capacity(const psa_key_derivation_operation_t *operation, size_t *capacity)
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_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_cipher_encrypt_setup(psa_cipher_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
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_finish(psa_cipher_operation_t *operation, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, const uint8_t *input, size_t input_length)
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)
psa_status_t psa_destroy_key(psa_key_id_t key)
Destroy a key.
psa_status_t psa_hash_verify(psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_length)
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, using a hash-and-sign verification algorithm...
psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length)
psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation)
psa_status_t psa_purge_key(psa_key_id_t key)
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)
Suspend an active hash operation.
struct psa_hash_operation_s psa_hash_operation_t
Definition: crypto.h:922
psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, const uint8_t *iv, size_t iv_length)
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_hash_setup(psa_hash_operation_t *operation, 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_key_derivation_output_key(const psa_key_attributes_t *attributes, psa_key_derivation_operation_t *operation, psa_key_id_t *key)
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)
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)
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 a hash or short message with a private key.
psa_status_t psa_crypto_init(void)
Library initialization.
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_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_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)
struct psa_key_derivation_s psa_key_derivation_operation_t
Definition: crypto.h:3236
psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, psa_key_id_t key, psa_algorithm_t alg)
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)
psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
struct psa_cipher_operation_s psa_cipher_operation_t
Definition: crypto.h:1709
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)
psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
psa_status_t psa_copy_key(psa_key_id_t source_key, const psa_key_attributes_t *attributes, psa_key_id_t *target_key)
psa_status_t psa_aead_abort(psa_aead_operation_t *operation)
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_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_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)
psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, psa_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_cipher_abort(psa_cipher_operation_t *operation)
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)
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)
struct psa_mac_operation_s psa_mac_operation_t
Definition: crypto.h:1290
psa_status_t psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)