psa_crypto_algorithm_dispatch.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 
20 #ifndef PSA_CRYPTO_ALGORITHM_DISPATCH_H
21 #define PSA_CRYPTO_ALGORITHM_DISPATCH_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <stdlib.h>
28 #include "kernel_defines.h"
29 #include "psa/crypto.h"
30 
31 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT)
33 #endif
34 
35 #if IS_USED(MODULE_PSA_HASH)
40 psa_status_t psa_algorithm_dispatch_hash_setup(psa_hash_operation_t *operation,
41  psa_algorithm_t alg);
42 
47 psa_status_t psa_algorithm_dispatch_hash_update(psa_hash_operation_t *operation,
48  const uint8_t *input,
49  size_t input_length);
50 
55 psa_status_t psa_algorithm_dispatch_hash_finish(psa_hash_operation_t *operation,
56  uint8_t *hash,
57  size_t hash_size,
58  size_t *hash_length);
59 #endif /* MODULE_PSA_HASH */
60 
61 #if IS_USED(MODULE_PSA_ASYMMETRIC)
66 psa_status_t psa_algorithm_dispatch_sign_hash( const psa_key_attributes_t *attributes,
67  psa_algorithm_t alg,
68  const psa_key_slot_t *slot,
69  const uint8_t *hash,
70  size_t hash_length,
71  uint8_t *signature,
72  size_t signature_size,
73  size_t *signature_length);
74 
79 psa_status_t psa_algorithm_dispatch_sign_message(const psa_key_attributes_t *attributes,
80  psa_algorithm_t alg,
81  const psa_key_slot_t *slot,
82  const uint8_t *input,
83  size_t input_length,
84  uint8_t *signature,
85  size_t signature_size,
86  size_t *signature_length);
87 
92 psa_status_t psa_algorithm_dispatch_verify_hash( const psa_key_attributes_t *attributes,
93  psa_algorithm_t alg,
94  const psa_key_slot_t *slot,
95  const uint8_t *hash,
96  size_t hash_length,
97  const uint8_t *signature,
98  size_t signature_length);
99 
104 psa_status_t psa_algorithm_dispatch_verify_message( const psa_key_attributes_t *attributes,
105  psa_algorithm_t alg,
106  const psa_key_slot_t *slot,
107  const uint8_t *input,
108  size_t input_length,
109  const uint8_t *signature,
110  size_t signature_length);
111 #endif /* MODULE_PSA_ASYMMETRIC */
112 
113 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT)
118 psa_status_t psa_algorithm_dispatch_generate_key( const psa_key_attributes_t *attributes,
119  psa_key_slot_t *slot);
120 
125 psa_status_t psa_algorithm_dispatch_import_key(const psa_key_attributes_t *attributes,
126  const uint8_t *data, size_t data_length,
127  psa_key_slot_t *slot, size_t *bits);
128 #endif
129 
130 #if IS_USED(MODULE_PSA_CIPHER)
135 psa_status_t psa_algorithm_dispatch_cipher_encrypt( const psa_key_attributes_t *attributes,
136  psa_algorithm_t alg,
137  const psa_key_slot_t *slot,
138  const uint8_t *input,
139  size_t input_length,
140  uint8_t *output,
141  size_t output_size,
142  size_t *output_length);
143 
148 psa_status_t psa_algorithm_dispatch_cipher_decrypt( const psa_key_attributes_t *attributes,
149  psa_algorithm_t alg,
150  const psa_key_slot_t *slot,
151  const uint8_t *input,
152  size_t input_length,
153  uint8_t *output,
154  size_t output_size,
155  size_t *output_length);
156 #endif /* MODULE_PSA_CIPHER */
157 
158 #if IS_USED(MODULE_PSA_MAC)
163 psa_status_t psa_algorithm_dispatch_mac_compute(const psa_key_attributes_t *attributes,
164  psa_algorithm_t alg,
165  const psa_key_slot_t *slot,
166  const uint8_t *input,
167  size_t input_length,
168  uint8_t *mac,
169  size_t mac_size,
170  size_t *mac_length);
171 #endif
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif /* PSA_CRYPTO_ALGORITHM_DISPATCH_H */
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: algorithm.h:39
Function declarations for PSA Crypto.
Common macros and compiler attributes/pragmas configuration.
int32_t psa_status_t
Status code type used for all PSA Certified APIs.
Definition: error.h:41
PSA key slot management function declarations.
Structure containing a hash context and algorithm.
Structure storing key attributes.
Definition: attributes.h:52
Structure of a virtual key slot in local memory.