mbed TLS v2.23.0: crypto.h Source File

mbed TLS v2.23.0

crypto.h
Go to the documentation of this file.
1
5 /*
6 * Copyright (C) 2018, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 #ifndef PSA_CRYPTO_H
23 #define PSA_CRYPTO_H
24
25 #include "crypto_platform.h"
26
27 #include <stddef.h>
28
29 #ifdef __DOXYGEN_ONLY__
30 /* This __DOXYGEN_ONLY__ block contains mock definitions for things that
31 * must be defined in the crypto_platform.h header. These mock definitions
32 * are present in this file as a convenience to generate pretty-printed
33 * documentation that includes those definitions. */
34
47 typedef _unsigned_integral_type_ psa_key_handle_t;
48
50 #endif /* __DOXYGEN_ONLY__ */
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 /* The file "crypto_types.h" declares types that encode errors,
57 * algorithms, key types, policies, etc. */
58 #include "crypto_types.h"
59
67 #define PSA_CRYPTO_API_VERSION_MAJOR 1
68
72 #define PSA_CRYPTO_API_VERSION_MINOR 0
73
76 /* The file "crypto_values.h" declares macros to build and analyze values
77 * of integral types defined in "crypto_types.h". */
78 #include "crypto_values.h"
79
108 psa_status_t psa_crypto_init(void);
109
121 #ifdef __DOXYGEN_ONLY__
122 /* This is an example definition for documentation purposes.
123 * Implementations should define a suitable value in `crypto_struct.h`.
124 */
125 #define PSA_KEY_ATTRIBUTES_INIT {0}
126 #endif
127
130 static psa_key_attributes_t psa_key_attributes_init(void);
131
152 static void psa_set_key_id(psa_key_attributes_t *attributes,
153 psa_key_id_t id);
154
180 static void psa_set_key_lifetime(psa_key_attributes_t *attributes,
181 psa_key_lifetime_t lifetime);
182
195 static psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes);
196
207 static psa_key_lifetime_t psa_get_key_lifetime(
208 const psa_key_attributes_t *attributes);
209
226 static void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
227 psa_key_usage_t usage_flags);
228
239 static psa_key_usage_t psa_get_key_usage_flags(
240 const psa_key_attributes_t *attributes);
241
264 static void psa_set_key_algorithm(psa_key_attributes_t *attributes,
265 psa_algorithm_t alg);
266
267
278 static psa_algorithm_t psa_get_key_algorithm(
279 const psa_key_attributes_t *attributes);
280
295 static void psa_set_key_type(psa_key_attributes_t *attributes,
296 psa_key_type_t type);
297
298
313 static void psa_set_key_bits(psa_key_attributes_t *attributes,
314 size_t bits);
315
326 static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes);
327
338 static size_t psa_get_key_bits(const psa_key_attributes_t *attributes);
339
366 psa_status_t psa_get_key_attributes(psa_key_handle_t handle,
367 psa_key_attributes_t *attributes);
368
381 void psa_reset_key_attributes(psa_key_attributes_t *attributes);
382
439 psa_status_t psa_open_key(psa_key_id_t id,
440 psa_key_handle_t *handle);
441
442
475 psa_status_t psa_close_key(psa_key_handle_t handle);
476
561 psa_status_t psa_copy_key(psa_key_handle_t source_handle,
562 const psa_key_attributes_t *attributes,
563 psa_key_handle_t *target_handle);
564
565
613 psa_status_t psa_destroy_key(psa_key_handle_t handle);
614
690 psa_status_t psa_import_key(const psa_key_attributes_t *attributes,
691 const uint8_t *data,
692 size_t data_length,
693 psa_key_handle_t *handle);
694
695
696
780 psa_status_t psa_export_key(psa_key_handle_t handle,
781 uint8_t *data,
782 size_t data_size,
783 size_t *data_length);
784
850 psa_status_t psa_export_public_key(psa_key_handle_t handle,
851 uint8_t *data,
852 size_t data_size,
853 size_t *data_length);
854
855
856
895 psa_status_t psa_hash_compute(psa_algorithm_t alg,
896 const uint8_t *input,
897 size_t input_length,
898 uint8_t *hash,
899 size_t hash_size,
900 size_t *hash_length);
901
931 psa_status_t psa_hash_compare(psa_algorithm_t alg,
932 const uint8_t *input,
933 size_t input_length,
934 const uint8_t *hash,
935 size_t hash_length);
936
965 typedef struct psa_hash_operation_s psa_hash_operation_t;
966
972 #ifdef __DOXYGEN_ONLY__
973 /* This is an example definition for documentation purposes.
974 * Implementations should define a suitable value in `crypto_struct.h`.
975 */
976 #define PSA_HASH_OPERATION_INIT {0}
977 #endif
978
981 static psa_hash_operation_t psa_hash_operation_init(void);
982
1032 psa_status_t psa_hash_setup(psa_hash_operation_t *operation,
1033 psa_algorithm_t alg);
1034
1059 psa_status_t psa_hash_update(psa_hash_operation_t *operation,
1060 const uint8_t *input,
1061 size_t input_length);
1062
1106 psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
1107 uint8_t *hash,
1108 size_t hash_size,
1109 size_t *hash_length);
1110
1148 psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
1149 const uint8_t *hash,
1150 size_t hash_length);
1151
1177 psa_status_t psa_hash_abort(psa_hash_operation_t *operation);
1178
1208 psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
1209 psa_hash_operation_t *target_operation);
1210
1258 psa_status_t psa_mac_compute(psa_key_handle_t handle,
1259 psa_algorithm_t alg,
1260 const uint8_t *input,
1261 size_t input_length,
1262 uint8_t *mac,
1263 size_t mac_size,
1264 size_t *mac_length);
1265
1298 psa_status_t psa_mac_verify(psa_key_handle_t handle,
1299 psa_algorithm_t alg,
1300 const uint8_t *input,
1301 size_t input_length,
1302 const uint8_t *mac,
1303 size_t mac_length);
1304
1333 typedef struct psa_mac_operation_s psa_mac_operation_t;
1334
1340 #ifdef __DOXYGEN_ONLY__
1341 /* This is an example definition for documentation purposes.
1342 * Implementations should define a suitable value in `crypto_struct.h`.
1343 */
1344 #define PSA_MAC_OPERATION_INIT {0}
1345 #endif
1346
1349 static psa_mac_operation_t psa_mac_operation_init(void);
1350
1410 psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation,
1411 psa_key_handle_t handle,
1412 psa_algorithm_t alg);
1413
1472 psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation,
1473 psa_key_handle_t handle,
1474 psa_algorithm_t alg);
1475
1503 psa_status_t psa_mac_update(psa_mac_operation_t *operation,
1504 const uint8_t *input,
1505 size_t input_length);
1506
1553 psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
1554 uint8_t *mac,
1555 size_t mac_size,
1556 size_t *mac_length);
1557
1597 psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
1598 const uint8_t *mac,
1599 size_t mac_length);
1600
1626 psa_status_t psa_mac_abort(psa_mac_operation_t *operation);
1627
1674 psa_status_t psa_cipher_encrypt(psa_key_handle_t handle,
1675 psa_algorithm_t alg,
1676 const uint8_t *input,
1677 size_t input_length,
1678 uint8_t *output,
1679 size_t output_size,
1680 size_t *output_length);
1681
1720 psa_status_t psa_cipher_decrypt(psa_key_handle_t handle,
1721 psa_algorithm_t alg,
1722 const uint8_t *input,
1723 size_t input_length,
1724 uint8_t *output,
1725 size_t output_size,
1726 size_t *output_length);
1727
1756 typedef struct psa_cipher_operation_s psa_cipher_operation_t;
1757
1763 #ifdef __DOXYGEN_ONLY__
1764 /* This is an example definition for documentation purposes.
1765 * Implementations should define a suitable value in `crypto_struct.h`.
1766 */
1767 #define PSA_CIPHER_OPERATION_INIT {0}
1768 #endif
1769
1772 static psa_cipher_operation_t psa_cipher_operation_init(void);
1773
1833 psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation,
1834 psa_key_handle_t handle,
1835 psa_algorithm_t alg);
1836
1896 psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation,
1897 psa_key_handle_t handle,
1898 psa_algorithm_t alg);
1899
1934 psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation,
1935 uint8_t *iv,
1936 size_t iv_size,
1937 size_t *iv_length);
1938
1976 psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation,
1977 const uint8_t *iv,
1978 size_t iv_length);
1979
2018 psa_status_t psa_cipher_update(psa_cipher_operation_t *operation,
2019 const uint8_t *input,
2020 size_t input_length,
2021 uint8_t *output,
2022 size_t output_size,
2023 size_t *output_length);
2024
2071 psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
2072 uint8_t *output,
2073 size_t output_size,
2074 size_t *output_length);
2075
2101 psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation);
2102
2157 psa_status_t psa_aead_encrypt(psa_key_handle_t handle,
2158 psa_algorithm_t alg,
2159 const uint8_t *nonce,
2160 size_t nonce_length,
2161 const uint8_t *additional_data,
2162 size_t additional_data_length,
2163 const uint8_t *plaintext,
2164 size_t plaintext_length,
2165 uint8_t *ciphertext,
2166 size_t ciphertext_size,
2167 size_t *ciphertext_length);
2168
2217 psa_status_t psa_aead_decrypt(psa_key_handle_t handle,
2218 psa_algorithm_t alg,
2219 const uint8_t *nonce,
2220 size_t nonce_length,
2221 const uint8_t *additional_data,
2222 size_t additional_data_length,
2223 const uint8_t *ciphertext,
2224 size_t ciphertext_length,
2225 uint8_t *plaintext,
2226 size_t plaintext_size,
2227 size_t *plaintext_length);
2228
2257 typedef struct psa_aead_operation_s psa_aead_operation_t;
2258
2264 #ifdef __DOXYGEN_ONLY__
2265 /* This is an example definition for documentation purposes.
2266 * Implementations should define a suitable value in `crypto_struct.h`.
2267 */
2268 #define PSA_AEAD_OPERATION_INIT {0}
2269 #endif
2270
2273 static psa_aead_operation_t psa_aead_operation_init(void);
2274
2340 psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation,
2341 psa_key_handle_t handle,
2342 psa_algorithm_t alg);
2343
2406 psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation,
2407 psa_key_handle_t handle,
2408 psa_algorithm_t alg);
2409
2446 psa_status_t psa_aead_generate_nonce(psa_aead_operation_t *operation,
2447 uint8_t *nonce,
2448 size_t nonce_size,
2449 size_t *nonce_length);
2450
2487 psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation,
2488 const uint8_t *nonce,
2489 size_t nonce_length);
2490
2533 psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation,
2534 size_t ad_length,
2535 size_t plaintext_length);
2536
2582 psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation,
2583 const uint8_t *input,
2584 size_t input_length);
2585
2660 psa_status_t psa_aead_update(psa_aead_operation_t *operation,
2661 const uint8_t *input,
2662 size_t input_length,
2663 uint8_t *output,
2664 size_t output_size,
2665 size_t *output_length);
2666
2736 psa_status_t psa_aead_finish(psa_aead_operation_t *operation,
2737 uint8_t *ciphertext,
2738 size_t ciphertext_size,
2739 size_t *ciphertext_length,
2740 uint8_t *tag,
2741 size_t tag_size,
2742 size_t *tag_length);
2743
2816 psa_status_t psa_aead_verify(psa_aead_operation_t *operation,
2817 uint8_t *plaintext,
2818 size_t plaintext_size,
2819 size_t *plaintext_length,
2820 const uint8_t *tag,
2821 size_t tag_length);
2822
2848 psa_status_t psa_aead_abort(psa_aead_operation_t *operation);
2849
2898 psa_status_t psa_sign_hash(psa_key_handle_t handle,
2899 psa_algorithm_t alg,
2900 const uint8_t *hash,
2901 size_t hash_length,
2902 uint8_t *signature,
2903 size_t signature_size,
2904 size_t *signature_length);
2905
2944 psa_status_t psa_verify_hash(psa_key_handle_t handle,
2945 psa_algorithm_t alg,
2946 const uint8_t *hash,
2947 size_t hash_length,
2948 const uint8_t *signature,
2949 size_t signature_length);
2950
3001 psa_status_t psa_asymmetric_encrypt(psa_key_handle_t handle,
3002 psa_algorithm_t alg,
3003 const uint8_t *input,
3004 size_t input_length,
3005 const uint8_t *salt,
3006 size_t salt_length,
3007 uint8_t *output,
3008 size_t output_size,
3009 size_t *output_length);
3010
3061 psa_status_t psa_asymmetric_decrypt(psa_key_handle_t handle,
3062 psa_algorithm_t alg,
3063 const uint8_t *input,
3064 size_t input_length,
3065 const uint8_t *salt,
3066 size_t salt_length,
3067 uint8_t *output,
3068 size_t output_size,
3069 size_t *output_length);
3070
3106 typedef struct psa_key_derivation_s psa_key_derivation_operation_t;
3107
3113 #ifdef __DOXYGEN_ONLY__
3114 /* This is an example definition for documentation purposes.
3115 * Implementations should define a suitable value in `crypto_struct.h`.
3116 */
3117 #define PSA_KEY_DERIVATION_OPERATION_INIT {0}
3118 #endif
3119
3122 static psa_key_derivation_operation_t psa_key_derivation_operation_init(void);
3123
3183 psa_status_t psa_key_derivation_setup(
3184 psa_key_derivation_operation_t *operation,
3185 psa_algorithm_t alg);
3186
3207 psa_status_t psa_key_derivation_get_capacity(
3208 const psa_key_derivation_operation_t *operation,
3209 size_t *capacity);
3210
3236 psa_status_t psa_key_derivation_set_capacity(
3237 psa_key_derivation_operation_t *operation,
3238 size_t capacity);
3239
3247 #define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY ((size_t)(-1))
3248
3291 psa_status_t psa_key_derivation_input_bytes(
3292 psa_key_derivation_operation_t *operation,
3293 psa_key_derivation_step_t step,
3294 const uint8_t *data,
3295 size_t data_length);
3296
3344 psa_status_t psa_key_derivation_input_key(
3345 psa_key_derivation_operation_t *operation,
3346 psa_key_derivation_step_t step,
3347 psa_key_handle_t handle);
3348
3413 psa_status_t psa_key_derivation_key_agreement(
3414 psa_key_derivation_operation_t *operation,
3415 psa_key_derivation_step_t step,
3416 psa_key_handle_t private_key,
3417 const uint8_t *peer_key,
3418 size_t peer_key_length);
3419
3458 psa_status_t psa_key_derivation_output_bytes(
3459 psa_key_derivation_operation_t *operation,
3460 uint8_t *output,
3461 size_t output_length);
3462
3597 psa_status_t psa_key_derivation_output_key(
3598 const psa_key_attributes_t *attributes,
3599 psa_key_derivation_operation_t *operation,
3600 psa_key_handle_t *handle);
3601
3625 psa_status_t psa_key_derivation_abort(
3626 psa_key_derivation_operation_t *operation);
3627
3678 psa_status_t psa_raw_key_agreement(psa_algorithm_t alg,
3679 psa_key_handle_t private_key,
3680 const uint8_t *peer_key,
3681 size_t peer_key_length,
3682 uint8_t *output,
3683 size_t output_size,
3684 size_t *output_length);
3685
3716 psa_status_t psa_generate_random(uint8_t *output,
3717 size_t output_size);
3718
3759 psa_status_t psa_generate_key(const psa_key_attributes_t *attributes,
3760 psa_key_handle_t *handle);
3761
3764 #ifdef __cplusplus
3765 }
3766 #endif
3767
3768 /* The file "crypto_sizes.h" contains definitions for size calculation
3769 * macros whose definitions are implementation-specific. */
3770 #include "crypto_sizes.h"
3771
3772 /* The file "crypto_struct.h" contains definitions for
3773 * implementation-specific structs that are declared above. */
3774 #include "crypto_struct.h"
3775
3776 /* The file "crypto_extra.h" contains vendor-specific definitions. This
3777 * can include vendor-defined algorithms, extra functions, etc. */
3778 #include "crypto_extra.h"
3779
3780 #endif /* PSA_CRYPTO_H */
psa_key_derivation_key_agreement
psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, psa_key_handle_t private_key, const uint8_t *peer_key, size_t peer_key_length)
psa_hash_verify
psa_status_t psa_hash_verify(psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_length)
psa_status_t
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:55
psa_raw_key_agreement
psa_status_t psa_raw_key_agreement(psa_algorithm_t alg, psa_key_handle_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_key_attributes_init
static psa_key_attributes_t psa_key_attributes_init(void)
psa_aead_set_lengths
psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length)
psa_mac_abort
psa_status_t psa_mac_abort(psa_mac_operation_t *operation)
psa_hash_compare
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)
psa_cipher_update
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_key_derivation_output_key
psa_status_t psa_key_derivation_output_key(const psa_key_attributes_t *attributes, psa_key_derivation_operation_t *operation, psa_key_handle_t *handle)
psa_set_key_algorithm
static void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg)
psa_mac_operation_s::alg
psa_algorithm_t alg
Definition: crypto_struct.h:131
psa_cipher_decrypt
psa_status_t psa_cipher_decrypt(psa_key_handle_t handle, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_key_attributes_s
Definition: crypto_struct.h:343
psa_cipher_operation_s::alg
psa_algorithm_t alg
Definition: crypto_struct.h:159
psa_export_public_key
psa_status_t psa_export_public_key(psa_key_handle_t handle, 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_key_derivation_setup
psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
psa_aead_update
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_hash_operation_s
Definition: crypto_struct.h:83
crypto_values.h
PSA cryptography module: macros to build and analyze integer values.
psa_aead_abort
psa_status_t psa_aead_abort(psa_aead_operation_t *operation)
psa_cipher_operation_init
static psa_cipher_operation_t psa_cipher_operation_init(void)
psa_generate_key
psa_status_t psa_generate_key(const psa_key_attributes_t *attributes, psa_key_handle_t *handle)
Generate a key or key pair.
psa_hash_operation_init
static psa_hash_operation_t psa_hash_operation_init(void)
crypto_sizes.h
PSA cryptography module: Mbed TLS buffer size macros.
psa_hash_clone
psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation)
psa_generate_random
psa_status_t psa_generate_random(uint8_t *output, size_t output_size)
Generate random bytes.
psa_aead_generate_nonce
psa_status_t psa_aead_generate_nonce(psa_aead_operation_t *operation, uint8_t *nonce, size_t nonce_size, size_t *nonce_length)
psa_key_id_t
uint32_t psa_key_id_t
Definition: crypto_types.h:237
psa_key_derivation_s::capacity
size_t capacity
Definition: crypto_struct.h:259
psa_aead_decrypt_setup
psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_mac_update
psa_status_t psa_mac_update(psa_mac_operation_t *operation, const uint8_t *input, size_t input_length)
psa_set_key_type
static void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type)
psa_aead_operation_init
static psa_aead_operation_t psa_aead_operation_init(void)
psa_get_key_algorithm
static psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes)
psa_get_key_attributes
psa_status_t psa_get_key_attributes(psa_key_handle_t handle, psa_key_attributes_t *attributes)
psa_aead_update_ad
psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, const uint8_t *input, size_t input_length)
psa_key_derivation_operation_init
static psa_key_derivation_operation_t psa_key_derivation_operation_init(void)
psa_copy_key
psa_status_t psa_copy_key(psa_key_handle_t source_handle, const psa_key_attributes_t *attributes, psa_key_handle_t *target_handle)
psa_key_derivation_output_bytes
psa_status_t psa_key_derivation_output_bytes(psa_key_derivation_operation_t *operation, uint8_t *output, size_t output_length)
psa_cipher_encrypt_setup
psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
crypto_types.h
PSA cryptography module: type aliases.
psa_aead_operation_s::alg
psa_algorithm_t alg
Definition: crypto_struct.h:181
psa_key_derivation_input_key
psa_status_t psa_key_derivation_input_key(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, psa_key_handle_t handle)
psa_sign_hash
psa_status_t psa_sign_hash(psa_key_handle_t handle, 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_hash_operation_s::alg
psa_algorithm_t alg
Definition: crypto_struct.h:84
psa_asymmetric_encrypt
psa_status_t psa_asymmetric_encrypt(psa_key_handle_t handle, 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_cipher_decrypt_setup
psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_set_key_bits
static void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits)
psa_cipher_abort
psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation)
psa_get_key_lifetime
static psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes)
psa_hash_update
psa_status_t psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)
psa_aead_operation_s
Definition: crypto_struct.h:180
psa_key_derivation_get_capacity
psa_status_t psa_key_derivation_get_capacity(const psa_key_derivation_operation_t *operation, size_t *capacity)
psa_hash_compute
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_set_key_id
static void psa_set_key_id(psa_key_attributes_t *attributes, psa_key_id_t id)
psa_hash_setup
psa_status_t psa_hash_setup(psa_hash_operation_t *operation, psa_algorithm_t alg)
psa_import_key
psa_status_t psa_import_key(const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, psa_key_handle_t *handle)
Import a key in binary format.
psa_mac_verify
psa_status_t psa_mac_verify(psa_key_handle_t handle, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *mac, size_t mac_length)
psa_key_derivation_s::alg
psa_algorithm_t alg
Definition: crypto_struct.h:257
psa_key_usage_t
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
Definition: crypto_types.h:248
psa_cipher_operation_s
Definition: crypto_struct.h:158
psa_hash_abort
psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
psa_cipher_finish
psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation, uint8_t *output, size_t output_size, size_t *output_length)
psa_algorithm_t
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:98
psa_crypto_init
psa_status_t psa_crypto_init(void)
Library initialization.
psa_mac_operation_s::mac_size
uint8_t mac_size
Definition: crypto_struct.h:137
psa_cipher_generate_iv
psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, uint8_t *iv, size_t iv_size, size_t *iv_length)
psa_mac_sign_finish
psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation, uint8_t *mac, size_t mac_size, size_t *mac_length)
psa_aead_decrypt
psa_status_t psa_aead_decrypt(psa_key_handle_t handle, 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_get_key_id
static psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
psa_get_key_usage_flags
static psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes)
psa_aead_encrypt_setup
psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_key_derivation_step_t
uint16_t psa_key_derivation_step_t
Encoding of the step of a key derivation.
Definition: crypto_types.h:382
psa_key_type_t
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:66
psa_aead_verify
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_mac_verify_finish
psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, const uint8_t *mac, size_t mac_length)
psa_get_key_bits
static size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
psa_mac_operation_s
Definition: crypto_struct.h:130
crypto_extra.h
PSA cryptography module: Mbed TLS vendor extensions.
psa_destroy_key
psa_status_t psa_destroy_key(psa_key_handle_t handle)
Destroy a key.
psa_mac_operation_init
static psa_mac_operation_t psa_mac_operation_init(void)
psa_cipher_operation_s::iv_size
uint8_t iv_size
Definition: crypto_struct.h:163
crypto_platform.h
PSA cryptography module: Mbed TLS platform definitions.
psa_mac_sign_setup
psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_cipher_set_iv
psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, const uint8_t *iv, size_t iv_length)
psa_set_key_usage_flags
static void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
psa_verify_hash
psa_status_t psa_verify_hash(psa_key_handle_t handle, 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.
psa_mac_verify_setup
psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_set_key_lifetime
static void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
psa_get_key_type
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
psa_asymmetric_decrypt
psa_status_t psa_asymmetric_decrypt(psa_key_handle_t handle, 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_hash_finish
psa_status_t psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)
crypto_struct.h
PSA cryptography module: Mbed TLS structured type implementations.
psa_cipher_encrypt
psa_status_t psa_cipher_encrypt(psa_key_handle_t handle, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_aead_finish
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_aead_set_nonce
psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length)
psa_key_derivation_input_bytes
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_key_handle_t
uint16_t psa_key_handle_t
Definition: crypto_platform.h:50
psa_aead_encrypt
psa_status_t psa_aead_encrypt(psa_key_handle_t handle, 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_key_lifetime_t
uint32_t psa_key_lifetime_t
Definition: crypto_types.h:141
psa_key_derivation_set_capacity
psa_status_t psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, size_t capacity)
psa_open_key
psa_status_t psa_open_key(psa_key_id_t id, psa_key_handle_t *handle)
psa_key_derivation_abort
psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
psa_mac_compute
psa_status_t psa_mac_compute(psa_key_handle_t handle, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *mac, size_t mac_size, size_t *mac_length)
psa_reset_key_attributes
void psa_reset_key_attributes(psa_key_attributes_t *attributes)
psa_key_derivation_s
Definition: crypto_struct.h:256
psa_export_key
psa_status_t psa_export_key(psa_key_handle_t handle, uint8_t *data, size_t data_size, size_t *data_length)
Export a key in binary format.
psa_close_key
psa_status_t psa_close_key(psa_key_handle_t handle)