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 
9 #pragma once
10 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include <stdlib.h>
27 #include "kernel_defines.h"
28 #include "psa/crypto.h"
29 
30 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT)
32 #endif
33 
34 #if IS_USED(MODULE_PSA_HASH)
39 psa_status_t psa_algorithm_dispatch_hash_setup(psa_hash_operation_t *operation,
40  psa_algorithm_t alg);
41 
46 psa_status_t psa_algorithm_dispatch_hash_update(psa_hash_operation_t *operation,
47  const uint8_t *input,
48  size_t input_length);
49 
54 psa_status_t psa_algorithm_dispatch_hash_finish(psa_hash_operation_t *operation,
55  uint8_t *hash,
56  size_t hash_size,
57  size_t *hash_length);
58 #endif /* MODULE_PSA_HASH */
59 
60 #if IS_USED(MODULE_PSA_ASYMMETRIC)
65 psa_status_t psa_algorithm_dispatch_sign_hash( const psa_key_attributes_t *attributes,
66  psa_algorithm_t alg,
67  const psa_key_slot_t *slot,
68  const uint8_t *hash,
69  size_t hash_length,
70  uint8_t *signature,
71  size_t signature_size,
72  size_t *signature_length);
73 
78 psa_status_t psa_algorithm_dispatch_sign_message(const psa_key_attributes_t *attributes,
79  psa_algorithm_t alg,
80  const psa_key_slot_t *slot,
81  const uint8_t *input,
82  size_t input_length,
83  uint8_t *signature,
84  size_t signature_size,
85  size_t *signature_length);
86 
91 psa_status_t psa_algorithm_dispatch_verify_hash( const psa_key_attributes_t *attributes,
92  psa_algorithm_t alg,
93  const psa_key_slot_t *slot,
94  const uint8_t *hash,
95  size_t hash_length,
96  const uint8_t *signature,
97  size_t signature_length);
98 
103 psa_status_t psa_algorithm_dispatch_verify_message( const psa_key_attributes_t *attributes,
104  psa_algorithm_t alg,
105  const psa_key_slot_t *slot,
106  const uint8_t *input,
107  size_t input_length,
108  const uint8_t *signature,
109  size_t signature_length);
110 #endif /* MODULE_PSA_ASYMMETRIC */
111 
112 #if IS_USED(MODULE_PSA_KEY_MANAGEMENT)
117 psa_status_t psa_algorithm_dispatch_generate_key( const psa_key_attributes_t *attributes,
118  psa_key_slot_t *slot);
119 
124 psa_status_t psa_algorithm_dispatch_import_key(const psa_key_attributes_t *attributes,
125  const uint8_t *data, size_t data_length,
126  psa_key_slot_t *slot, size_t *bits);
127 #endif
128 
129 #if IS_USED(MODULE_PSA_CIPHER)
134 psa_status_t psa_algorithm_dispatch_cipher_encrypt( const psa_key_attributes_t *attributes,
135  psa_algorithm_t alg,
136  const psa_key_slot_t *slot,
137  const uint8_t *input,
138  size_t input_length,
139  uint8_t *output,
140  size_t output_size,
141  size_t *output_length);
142 
147 psa_status_t psa_algorithm_dispatch_cipher_decrypt( const psa_key_attributes_t *attributes,
148  psa_algorithm_t alg,
149  const psa_key_slot_t *slot,
150  const uint8_t *input,
151  size_t input_length,
152  uint8_t *output,
153  size_t output_size,
154  size_t *output_length);
155 #endif /* MODULE_PSA_CIPHER */
156 
157 #if IS_USED(MODULE_PSA_AEAD)
162 psa_status_t psa_algorithm_dispatch_aead_encrypt( const psa_key_attributes_t *attributes,
163  psa_algorithm_t alg,
164  const psa_key_slot_t *slot,
165  const uint8_t *nonce,
166  size_t nonce_length,
167  const uint8_t *additional_data,
168  size_t additional_data_length,
169  const uint8_t *plaintext,
170  size_t plaintext_length,
171  uint8_t *ciphertext,
172  size_t ciphertext_size,
173  size_t *ciphertext_length);
174 
179 psa_status_t psa_algorithm_dispatch_aead_decrypt( const psa_key_attributes_t *attributes,
180  psa_algorithm_t alg,
181  const psa_key_slot_t *slot,
182  const uint8_t *nonce,
183  size_t nonce_length,
184  const uint8_t *additional_data,
185  size_t additional_data_length,
186  const uint8_t *ciphertext,
187  size_t ciphertext_length,
188  uint8_t *plaintext,
189  size_t plaintext_size,
190  size_t *plaintext_length);
191 #endif /* MODULE_PSA_AEAD */
192 #if IS_USED(MODULE_PSA_MAC)
197 psa_status_t psa_algorithm_dispatch_mac_compute(const psa_key_attributes_t *attributes,
198  psa_algorithm_t alg,
199  const psa_key_slot_t *slot,
200  const uint8_t *input,
201  size_t input_length,
202  uint8_t *mac,
203  size_t mac_size,
204  size_t *mac_length);
205 #endif
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: algorithm.h:38
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:40
PSA key slot management function declarations.
Structure containing a hash context and algorithm.
Structure storing key attributes.
Definition: attributes.h:51
Structure of a virtual key slot in local memory.