TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_crypto_ipc_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "tfm_crypto_defs.h"
9 #include "psa/crypto.h"
10 #include "tfm_ns_interface.h"
11 #include "psa_manifest/sid.h"
12 #include "psa/client.h"
13 
14 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
15 
16 #define PSA_CONNECT(service) \
17  psa_handle_t ipc_handle; \
18  ipc_handle = psa_connect(service##_SID, service##_VERSION); \
19  if (!PSA_HANDLE_IS_VALID(ipc_handle)) { \
20  return PSA_ERROR_GENERIC_ERROR; \
21  } \
22 
23 #define PSA_CLOSE() psa_close(ipc_handle)
24 
25 #define API_DISPATCH(sfn_name, sfn_id) \
26  psa_call(ipc_handle, PSA_IPC_CALL, \
27  in_vec, ARRAY_SIZE(in_vec), \
28  out_vec, ARRAY_SIZE(out_vec))
29 
30 #define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id) \
31  psa_call(ipc_handle, PSA_IPC_CALL, \
32  in_vec, ARRAY_SIZE(in_vec), \
33  (psa_outvec *)NULL, 0)
34 
36 {
37  /* Service init is performed during TFM boot up,
38  * so application level initialisation is empty
39  */
40  return PSA_SUCCESS;
41 }
42 
44  psa_key_handle_t *handle)
45 {
46 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
48 #else
49  psa_status_t status;
50  const struct tfm_crypto_pack_iovec iov = {
52  };
53  psa_invec in_vec[] = {
54  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
55  {.base = &id, .len = sizeof(psa_key_id_t)},
56  };
57  psa_outvec out_vec[] = {
58  {.base = handle, .len = sizeof(psa_key_handle_t)},
59  };
60 
61  PSA_CONNECT(TFM_CRYPTO);
62 
64  TFM_CRYPTO_OPEN_KEY);
65 
66  PSA_CLOSE();
67 
68  return status;
69 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
70 }
71 
73 {
74 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
76 #else
77  psa_status_t status;
78  const struct tfm_crypto_pack_iovec iov = {
80  .key_handle = handle,
81  };
82  psa_invec in_vec[] = {
83  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
84  };
85 
86  PSA_CONNECT(TFM_CRYPTO);
87 
89  TFM_CRYPTO_CLOSE_KEY);;
90 
91  PSA_CLOSE();
92 
93  return status;
94 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
95 }
96 
98  const uint8_t *data,
99  size_t data_length,
100  psa_key_handle_t *handle)
101 {
102 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
104 #else
105  psa_status_t status;
106  struct tfm_crypto_pack_iovec iov = {
108  };
109  psa_invec in_vec[] = {
110  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
111  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
112  {.base = data, .len = data_length}
113  };
114  psa_outvec out_vec[] = {
115  {.base = handle, .len = sizeof(psa_key_handle_t)}
116  };
117 
118  PSA_CONNECT(TFM_CRYPTO);
119 
121  TFM_CRYPTO_IMPORT_KEY);
122  PSA_CLOSE();
123 
124  return status;
125 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
126 }
127 
129 {
130 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
132 #else
133  psa_status_t status;
134  struct tfm_crypto_pack_iovec iov = {
136  .key_handle = handle,
137  };
138  psa_invec in_vec[] = {
139  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
140  };
141 
142  PSA_CONNECT(TFM_CRYPTO);
143 
145  TFM_CRYPTO_DESTROY_KEY);
146  PSA_CLOSE();
147 
148  return status;
149 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
150 }
151 
153  psa_key_attributes_t *attributes)
154 {
155 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
157 #else
158  psa_status_t status;
159  struct tfm_crypto_pack_iovec iov = {
161  .key_handle = handle,
162  };
163  psa_invec in_vec[] = {
164  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
165  };
166  psa_outvec out_vec[] = {
167  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
168  };
169 
170  PSA_CONNECT(TFM_CRYPTO);
171 
173  TFM_CRYPTO_GET_KEY_ATTRIBUTES);
174  PSA_CLOSE();
175 
176  return status;
177 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
178 }
179 
181 {
182 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
183  return;
184 #else
185  struct tfm_crypto_pack_iovec iov = {
187  };
188  psa_invec in_vec[] = {
189  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
190  };
191  psa_outvec out_vec[] = {
192  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
193  };
194 
195  psa_handle_t ipc_handle;
197  if (!PSA_HANDLE_IS_VALID(ipc_handle)) {
198  return;
199  }
200 
202  TFM_CRYPTO_RESET_KEY_ATTRIBUTES);
203  PSA_CLOSE();
204 
205  return;
206 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
207 }
208 
210  uint8_t *data,
211  size_t data_size,
212  size_t *data_length)
213 {
214 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
216 #else
217  psa_status_t status;
218  struct tfm_crypto_pack_iovec iov = {
220  .key_handle = handle,
221  };
222  psa_invec in_vec[] = {
223  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
224  };
225  psa_outvec out_vec[] = {
226  {.base = data, .len = data_size}
227  };
228 
229  PSA_CONNECT(TFM_CRYPTO);
230 
232  TFM_CRYPTO_EXPORT_KEY);
233 
234  *data_length = out_vec[0].len;
235 
236  PSA_CLOSE();
237 
238  return status;
239 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
240 }
241 
243  uint8_t *data,
244  size_t data_size,
245  size_t *data_length)
246 {
247 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
249 #else
250  psa_status_t status;
251  struct tfm_crypto_pack_iovec iov = {
253  .key_handle = handle,
254  };
255 
256  psa_invec in_vec[] = {
257  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
258  };
259  psa_outvec out_vec[] = {
260  {.base = data, .len = data_size}
261  };
262 
263  PSA_CONNECT(TFM_CRYPTO);
264 
266  TFM_CRYPTO_EXPORT_PUBLIC_KEY);
267 
268  *data_length = out_vec[0].len;
269 
270  PSA_CLOSE();
271 
272  return status;
273 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
274 }
275 
277  const psa_key_attributes_t *attributes,
278  psa_key_handle_t *target_handle)
279 {
280 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
282 #else
283  psa_status_t status;
284  struct tfm_crypto_pack_iovec iov = {
286  .key_handle = source_handle,
287  };
288 
289  psa_invec in_vec[] = {
290  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
291  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
292 
293  };
294 
295  psa_outvec out_vec[] = {
296  {.base = target_handle, .len = sizeof(psa_key_handle_t)},
297  };
298 
299  PSA_CONNECT(TFM_CRYPTO);
300 
302  TFM_CRYPTO_COPY_KEY);
303 
304  PSA_CLOSE();
305 
306  return status;
307 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
308 }
309 
311  unsigned char *iv,
312  size_t iv_size,
313  size_t *iv_length)
314 {
315 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
317 #else
318  psa_status_t status;
319  struct tfm_crypto_pack_iovec iov = {
321  .op_handle = operation->handle,
322  };
323 
324  psa_invec in_vec[] = {
325  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
326  };
327  psa_outvec out_vec[] = {
328  {.base = &(operation->handle), .len = sizeof(uint32_t)},
329  {.base = iv, .len = iv_size},
330  };
331 
332  PSA_CONNECT(TFM_CRYPTO);
333 
335  TFM_CRYPTO_CIPHER_GENERATE_IV);
336 
337  *iv_length = out_vec[1].len;
338 
339  PSA_CLOSE();
340 
341  return status;
342 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
343 }
344 
346  const unsigned char *iv,
347  size_t iv_length)
348 {
349 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
351 #else
352  psa_status_t status;
353  struct tfm_crypto_pack_iovec iov = {
355  .op_handle = operation->handle,
356  };
357 
358  psa_invec in_vec[] = {
359  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
360  {.base = iv, .len = iv_length},
361  };
362  psa_outvec out_vec[] = {
363  {.base = &(operation->handle), .len = sizeof(uint32_t)},
364  };
365 
366  PSA_CONNECT(TFM_CRYPTO);
367 
369  TFM_CRYPTO_CIPHER_SET_IV);
370 
371  PSA_CLOSE();
372 
373  return status;
374 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
375 }
376 
378  psa_key_handle_t handle,
380 {
381 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
383 #else
384  psa_status_t status;
385  struct tfm_crypto_pack_iovec iov = {
387  .key_handle = handle,
388  .alg = alg,
389  .op_handle = operation->handle,
390  };
391 
392  psa_invec in_vec[] = {
393  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
394  };
395  psa_outvec out_vec[] = {
396  {.base = &(operation->handle), .len = sizeof(uint32_t)},
397  };
398 
399  PSA_CONNECT(TFM_CRYPTO);
400 
402  TFM_CRYPTO_CIPHER_ENCRYPT_SETUP);
403 
404  PSA_CLOSE();
405 
406  return status;
407 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
408 }
409 
411  psa_key_handle_t handle,
412  psa_algorithm_t alg)
413 {
414 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
416 #else
417  psa_status_t status;
418  struct tfm_crypto_pack_iovec iov = {
420  .key_handle = handle,
421  .alg = alg,
422  .op_handle = operation->handle,
423  };
424 
425  psa_invec in_vec[] = {
426  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
427  };
428  psa_outvec out_vec[] = {
429  {.base = &(operation->handle), .len = sizeof(uint32_t)},
430  };
431 
432  PSA_CONNECT(TFM_CRYPTO);
433 
435  TFM_CRYPTO_CIPHER_DECRYPT_SETUP);
436 
437  PSA_CLOSE();
438 
439  return status;
440 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
441 }
442 
444  const uint8_t *input,
445  size_t input_length,
446  unsigned char *output,
447  size_t output_size,
448  size_t *output_length)
449 {
450 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
452 #else
453  psa_status_t status;
454  struct tfm_crypto_pack_iovec iov = {
456  .op_handle = operation->handle,
457  };
458 
459  psa_invec in_vec[] = {
460  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
461  {.base = input, .len = input_length},
462  };
463  psa_outvec out_vec[] = {
464  {.base = &(operation->handle), .len = sizeof(uint32_t)},
465  {.base = output, .len = output_size}
466  };
467 
468  PSA_CONNECT(TFM_CRYPTO);
469 
471  TFM_CRYPTO_CIPHER_UPDATE);
472 
473  *output_length = out_vec[1].len;
474 
475  PSA_CLOSE();
476 
477  return status;
478 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
479 }
480 
482 {
483 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
485 #else
486  psa_status_t status;
487  struct tfm_crypto_pack_iovec iov = {
489  .op_handle = operation->handle,
490  };
491 
492  psa_invec in_vec[] = {
493  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
494  };
495  psa_outvec out_vec[] = {
496  {.base = &(operation->handle), .len = sizeof(uint32_t)},
497  };
498 
499  PSA_CONNECT(TFM_CRYPTO);
500 
502  TFM_CRYPTO_CIPHER_ABORT);
503 
504  PSA_CLOSE();
505 
506  return status;
507 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
508 }
509 
511  uint8_t *output,
512  size_t output_size,
513  size_t *output_length)
514 {
515 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
517 #else
518  psa_status_t status;
519  struct tfm_crypto_pack_iovec iov = {
521  .op_handle = operation->handle,
522  };
523 
524  psa_invec in_vec[] = {
525  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
526  };
527  psa_outvec out_vec[] = {
528  {.base = &(operation->handle), .len = sizeof(uint32_t)},
529  {.base = output, .len = output_size},
530  };
531 
532  PSA_CONNECT(TFM_CRYPTO);
533 
535  TFM_CRYPTO_CIPHER_FINISH);
536 
537  *output_length = out_vec[1].len;
538 
539  PSA_CLOSE();
540 
541  return status;
542 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
543 }
544 
546  psa_algorithm_t alg)
547 {
548 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
550 #else
551  psa_status_t status;
552  struct tfm_crypto_pack_iovec iov = {
554  .alg = alg,
555  .op_handle = operation->handle,
556  };
557 
558  psa_invec in_vec[] = {
559  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
560  };
561  psa_outvec out_vec[] = {
562  {.base = &(operation->handle), .len = sizeof(uint32_t)},
563  };
564 
565  PSA_CONNECT(TFM_CRYPTO);
566 
568  TFM_CRYPTO_HASH_SETUP);
569 
570  PSA_CLOSE();
571 
572  return status;
573 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
574 }
575 
577  const uint8_t *input,
578  size_t input_length)
579 {
580 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
582 #else
583  psa_status_t status;
584  struct tfm_crypto_pack_iovec iov = {
586  .op_handle = operation->handle,
587  };
588 
589  psa_invec in_vec[] = {
590  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
591  {.base = input, .len = input_length},
592  };
593  psa_outvec out_vec[] = {
594  {.base = &(operation->handle), .len = sizeof(uint32_t)},
595  };
596 
597  PSA_CONNECT(TFM_CRYPTO);
598 
600  TFM_CRYPTO_HASH_UPDATE);
601 
602  PSA_CLOSE();
603 
604  return status;
605 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
606 }
607 
609  uint8_t *hash,
610  size_t hash_size,
611  size_t *hash_length)
612 {
613 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
615 #else
616  psa_status_t status;
617  struct tfm_crypto_pack_iovec iov = {
619  .op_handle = operation->handle,
620  };
621 
622  psa_invec in_vec[] = {
623  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
624  };
625  psa_outvec out_vec[] = {
626  {.base = &(operation->handle), .len = sizeof(uint32_t)},
627  {.base = hash, .len = hash_size},
628  };
629 
630  PSA_CONNECT(TFM_CRYPTO);
631 
633  TFM_CRYPTO_HASH_FINISH);
634 
635  *hash_length = out_vec[1].len;
636 
637  PSA_CLOSE();
638 
639  return status;
640 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
641 }
642 
644  const uint8_t *hash,
645  size_t hash_length)
646 {
647 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
649 #else
650  psa_status_t status;
651  struct tfm_crypto_pack_iovec iov = {
653  .op_handle = operation->handle,
654  };
655 
656  psa_invec in_vec[] = {
657  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
658  {.base = hash, .len = hash_length},
659  };
660  psa_outvec out_vec[] = {
661  {.base = &(operation->handle), .len = sizeof(uint32_t)},
662  };
663 
664  PSA_CONNECT(TFM_CRYPTO);
665 
667  TFM_CRYPTO_HASH_VERIFY);
668 
669  PSA_CLOSE();
670 
671  return status;
672 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
673 }
674 
676 {
677 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
679 #else
680  psa_status_t status;
681  struct tfm_crypto_pack_iovec iov = {
683  .op_handle = operation->handle,
684  };
685 
686  psa_invec in_vec[] = {
687  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
688  };
689  psa_outvec out_vec[] = {
690  {.base = &(operation->handle), .len = sizeof(uint32_t)},
691  };
692 
693  PSA_CONNECT(TFM_CRYPTO);
694 
696  TFM_CRYPTO_HASH_ABORT);
697 
698  PSA_CLOSE();
699 
700  return status;
701 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
702 }
703 
705  psa_hash_operation_t *target_operation)
706 {
707 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
709 #else
710  psa_status_t status;
711  struct tfm_crypto_pack_iovec iov = {
713  .op_handle = source_operation->handle,
714  };
715 
716  psa_invec in_vec[] = {
717  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
718  };
719  psa_outvec out_vec[] = {
720  {.base = target_operation, .len = sizeof(psa_hash_operation_t)},
721  };
722 
723  if (target_operation && (target_operation->handle != 0)) {
724  return PSA_ERROR_BAD_STATE;
725  }
726 
727  PSA_CONNECT(TFM_CRYPTO);
728 
730  TFM_CRYPTO_HASH_CLONE);
731 
732  PSA_CLOSE();
733 
734  return status;
735 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
736 }
737 
739  const uint8_t *input,
740  size_t input_length,
741  uint8_t *hash,
742  size_t hash_size,
743  size_t *hash_length)
744 {
745 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
747 #else
748  psa_status_t status;
749  struct tfm_crypto_pack_iovec iov = {
751  .alg = alg,
752  };
753 
754  psa_invec in_vec[] = {
755  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
756  {.base = input, .len = input_length},
757  };
758 
759  psa_outvec out_vec[] = {
760  {.base = hash, .len = hash_size}
761  };
762 
763  PSA_CONNECT(TFM_CRYPTO);
764 
766  TFM_CRYPTO_HASH_COMPUTE);
767 
768  *hash_length = out_vec[0].len;
769 
770  PSA_CLOSE();
771 
772  return status;
773 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
774 }
775 
777  const uint8_t *input,
778  size_t input_length,
779  const uint8_t *hash,
780  size_t hash_length)
781 {
782 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
784 #else
785  psa_status_t status;
786  struct tfm_crypto_pack_iovec iov = {
788  .alg = alg,
789  };
790 
791  psa_invec in_vec[] = {
792  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
793  {.base = input, .len = input_length},
794  {.base = hash, .len = hash_length},
795  };
796 
797  PSA_CONNECT(TFM_CRYPTO);
798 
800  TFM_CRYPTO_HASH_COMPARE);
801 
802  PSA_CLOSE();
803 
804  return status;
805 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
806 }
807 
808 
809 
811  psa_key_handle_t handle,
812  psa_algorithm_t alg)
813 {
814 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
816 #else
817  psa_status_t status;
818  struct tfm_crypto_pack_iovec iov = {
820  .key_handle = handle,
821  .alg = alg,
822  .op_handle = operation->handle,
823  };
824 
825  psa_invec in_vec[] = {
826  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
827  };
828  psa_outvec out_vec[] = {
829  {.base = &(operation->handle), .len = sizeof(uint32_t)},
830  };
831 
832  PSA_CONNECT(TFM_CRYPTO);
833 
835  TFM_CRYPTO_MAC_SIGN_SETUP);
836 
837  PSA_CLOSE();
838 
839  return status;
840 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
841 }
842 
844  psa_key_handle_t handle,
845  psa_algorithm_t alg)
846 {
847 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
849 #else
850  psa_status_t status;
851  struct tfm_crypto_pack_iovec iov = {
853  .key_handle = handle,
854  .alg = alg,
855  .op_handle = operation->handle,
856  };
857 
858  psa_invec in_vec[] = {
859  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
860  };
861  psa_outvec out_vec[] = {
862  {.base = &(operation->handle), .len = sizeof(uint32_t)},
863  };
864 
865  PSA_CONNECT(TFM_CRYPTO);
866 
868  TFM_CRYPTO_MAC_VERIFY_SETUP);
869 
870  PSA_CLOSE();
871 
872  return status;
873 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
874 }
875 
877  const uint8_t *input,
878  size_t input_length)
879 {
880 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
882 #else
883  psa_status_t status;
884  struct tfm_crypto_pack_iovec iov = {
886  .op_handle = operation->handle,
887  };
888 
889  psa_invec in_vec[] = {
890  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
891  {.base = input, .len = input_length},
892  };
893  psa_outvec out_vec[] = {
894  {.base = &(operation->handle), .len = sizeof(uint32_t)},
895  };
896 
897  PSA_CONNECT(TFM_CRYPTO);
898 
900  TFM_CRYPTO_MAC_UPDATE);
901 
902  PSA_CLOSE();
903 
904  return status;
905 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
906 }
907 
909  uint8_t *mac,
910  size_t mac_size,
911  size_t *mac_length)
912 {
913 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
915 #else
916  psa_status_t status;
917  struct tfm_crypto_pack_iovec iov = {
919  .op_handle = operation->handle,
920  };
921 
922  psa_invec in_vec[] = {
923  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
924  };
925  psa_outvec out_vec[] = {
926  {.base = &(operation->handle), .len = sizeof(uint32_t)},
927  {.base = mac, .len = mac_size},
928  };
929 
930  PSA_CONNECT(TFM_CRYPTO);
931 
933  TFM_CRYPTO_MAC_SIGN_FINISH);
934 
935  *mac_length = out_vec[1].len;
936 
937  PSA_CLOSE();
938 
939  return status;
940 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
941 }
942 
944  const uint8_t *mac,
945  size_t mac_length)
946 {
947 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
949 #else
950  psa_status_t status;
951  struct tfm_crypto_pack_iovec iov = {
953  .op_handle = operation->handle,
954  };
955 
956  psa_invec in_vec[] = {
957  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
958  {.base = mac, .len = mac_length},
959  };
960  psa_outvec out_vec[] = {
961  {.base = &(operation->handle), .len = sizeof(uint32_t)},
962  };
963 
964  PSA_CONNECT(TFM_CRYPTO);
965 
967  TFM_CRYPTO_MAC_VERIFY_FINISH);
968 
969  PSA_CLOSE();
970 
971  return status;
972 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
973 }
974 
976 {
977 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
979 #else
980  psa_status_t status;
981  struct tfm_crypto_pack_iovec iov = {
983  .op_handle = operation->handle,
984  };
985 
986  psa_invec in_vec[] = {
987  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
988  };
989  psa_outvec out_vec[] = {
990  {.base = &(operation->handle), .len = sizeof(uint32_t)},
991  };
992 
993  PSA_CONNECT(TFM_CRYPTO);
994 
996  TFM_CRYPTO_MAC_ABORT);
997 
998  PSA_CLOSE();
999 
1000  return status;
1001 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
1002 }
1003 
1005  psa_algorithm_t alg,
1006  const uint8_t *nonce,
1007  size_t nonce_length,
1008  const uint8_t *additional_data,
1009  size_t additional_data_length,
1010  const uint8_t *plaintext,
1011  size_t plaintext_length,
1012  uint8_t *ciphertext,
1013  size_t ciphertext_size,
1014  size_t *ciphertext_length)
1015 {
1016 #ifdef TFM_CRYPTO_AEAD_MODULE_DISABLED
1017  return PSA_ERROR_NOT_SUPPORTED;
1018 #else
1019  psa_status_t status;
1020  struct tfm_crypto_pack_iovec iov = {
1022  .key_handle = handle,
1023  .alg = alg,
1024  .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
1025  };
1026 
1027  /* Sanitize the optional input */
1028  if ((additional_data == NULL) && (additional_data_length != 0)) {
1030  }
1031 
1032  size_t idx = 0;
1033  psa_invec in_vec[] = {
1034  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1035  {.base = plaintext, .len = plaintext_length},
1036  {.base = additional_data, .len = additional_data_length},
1037  };
1038  psa_outvec out_vec[] = {
1039  {.base = ciphertext, .len = ciphertext_size},
1040  };
1041 
1042  if (nonce_length > TFM_CRYPTO_MAX_NONCE_LENGTH) {
1044  }
1045 
1046  if (nonce != NULL) {
1047  for (idx = 0; idx < nonce_length; idx++) {
1048  iov.aead_in.nonce[idx] = nonce[idx];
1049  }
1050  }
1051 
1052  PSA_CONNECT(TFM_CRYPTO);
1053 
1054  size_t in_len = ARRAY_SIZE(in_vec);
1055  if (additional_data == NULL) {
1056  in_len--;
1057  }
1058  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1059  out_vec, ARRAY_SIZE(out_vec));
1060 
1061  *ciphertext_length = out_vec[0].len;
1062 
1063  PSA_CLOSE();
1064 
1065  return status;
1066 #endif /* TFM_CRYPTO_AEAD_MODULE_DISABLED */
1067 }
1068 
1070  psa_algorithm_t alg,
1071  const uint8_t *nonce,
1072  size_t nonce_length,
1073  const uint8_t *additional_data,
1074  size_t additional_data_length,
1075  const uint8_t *ciphertext,
1076  size_t ciphertext_length,
1077  uint8_t *plaintext,
1078  size_t plaintext_size,
1079  size_t *plaintext_length)
1080 {
1081 #ifdef TFM_CRYPTO_AEAD_MODULE_DISABLED
1082  return PSA_ERROR_NOT_SUPPORTED;
1083 #else
1084  psa_status_t status;
1085  struct tfm_crypto_pack_iovec iov = {
1087  .key_handle = handle,
1088  .alg = alg,
1089  .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
1090  };
1091 
1092  /* Sanitize the optional input */
1093  if ((additional_data == NULL) && (additional_data_length != 0)) {
1095  }
1096 
1097  size_t idx = 0;
1098  psa_invec in_vec[] = {
1099  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1100  {.base = ciphertext, .len = ciphertext_length},
1101  {.base = additional_data, .len = additional_data_length},
1102  };
1103  psa_outvec out_vec[] = {
1104  {.base = plaintext, .len = plaintext_size},
1105  };
1106 
1107  if (nonce_length > TFM_CRYPTO_MAX_NONCE_LENGTH) {
1109  }
1110 
1111  if (nonce != NULL) {
1112  for (idx = 0; idx < nonce_length; idx++) {
1113  iov.aead_in.nonce[idx] = nonce[idx];
1114  }
1115  }
1116 
1117  PSA_CONNECT(TFM_CRYPTO);
1118 
1119  size_t in_len = ARRAY_SIZE(in_vec);
1120  if (additional_data == NULL) {
1121  in_len--;
1122  }
1123  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1124  out_vec, ARRAY_SIZE(out_vec));
1125 
1126  *plaintext_length = out_vec[0].len;
1127 
1128  PSA_CLOSE();
1129 
1130  return status;
1131 #endif /* TFM_CRYPTO_AEAD_MODULE_DISABLED */
1132 }
1133 
1135  psa_algorithm_t alg,
1136  const uint8_t *hash,
1137  size_t hash_length,
1138  uint8_t *signature,
1139  size_t signature_size,
1140  size_t *signature_length)
1141 {
1142  return psa_sign_hash(handle, alg, hash, hash_length, signature, signature_size, signature_length);
1143 }
1144 
1146  psa_algorithm_t alg,
1147  const uint8_t *hash,
1148  size_t hash_length,
1149  uint8_t *signature,
1150  size_t signature_size,
1151  size_t *signature_length)
1152 {
1153 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1154  return PSA_ERROR_NOT_SUPPORTED;
1155 #else
1156  psa_status_t status;
1157  struct tfm_crypto_pack_iovec iov = {
1159  .key_handle = handle,
1160  .alg = alg,
1161  };
1162 
1163  psa_invec in_vec[] = {
1164  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1165  {.base = hash, .len = hash_length},
1166  };
1167  psa_outvec out_vec[] = {
1168  {.base = signature, .len = signature_size},
1169  };
1170 
1171  PSA_CONNECT(TFM_CRYPTO);
1172 
1174  TFM_CRYPTO_SIGN_HASH);
1175 
1176  *signature_length = out_vec[0].len;
1177 
1178  PSA_CLOSE();
1179 
1180  return status;
1181 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1182 }
1183 
1185  psa_algorithm_t alg,
1186  const uint8_t *hash,
1187  size_t hash_length,
1188  const uint8_t *signature,
1189  size_t signature_length)
1190 {
1191  return psa_verify_hash(handle, alg, hash, hash_length, signature, signature_length);
1192 }
1193 
1195  psa_algorithm_t alg,
1196  const uint8_t *hash,
1197  size_t hash_length,
1198  const uint8_t *signature,
1199  size_t signature_length)
1200 {
1201 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1202  return PSA_ERROR_NOT_SUPPORTED;
1203 #else
1204  psa_status_t status;
1205  struct tfm_crypto_pack_iovec iov = {
1207  .key_handle = handle,
1208  .alg = alg
1209  };
1210 
1211  psa_invec in_vec[] = {
1212  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1213  {.base = hash, .len = hash_length},
1214  {.base = signature, .len = signature_length}
1215  };
1216 
1217  PSA_CONNECT(TFM_CRYPTO);
1218 
1220  TFM_CRYPTO_VERIFY_HASH);
1221 
1222  PSA_CLOSE();
1223 
1224  return status;
1225 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1226 }
1227 
1229  psa_algorithm_t alg,
1230  const uint8_t *input,
1231  size_t input_length,
1232  const uint8_t *salt,
1233  size_t salt_length,
1234  uint8_t *output,
1235  size_t output_size,
1236  size_t *output_length)
1237 {
1238 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1239  return PSA_ERROR_NOT_SUPPORTED;
1240 #else
1241  psa_status_t status;
1242  struct tfm_crypto_pack_iovec iov = {
1244  .key_handle = handle,
1245  .alg = alg
1246  };
1247 
1248  /* Sanitize the optional input */
1249  if ((salt == NULL) && (salt_length != 0)) {
1251  }
1252 
1253  psa_invec in_vec[] = {
1254  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1255  {.base = input, .len = input_length},
1256  {.base = salt, .len = salt_length}
1257  };
1258 
1259  psa_outvec out_vec[] = {
1260  {.base = output, .len = output_size},
1261  };
1262 
1263  PSA_CONNECT(TFM_CRYPTO);
1264 
1265  size_t in_len = ARRAY_SIZE(in_vec);
1266  if (salt == NULL) {
1267  in_len--;
1268  }
1269  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1270  out_vec, ARRAY_SIZE(out_vec));
1271 
1272  *output_length = out_vec[0].len;
1273 
1274  PSA_CLOSE();
1275 
1276  return status;
1277 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1278 }
1279 
1281  psa_algorithm_t alg,
1282  const uint8_t *input,
1283  size_t input_length,
1284  const uint8_t *salt,
1285  size_t salt_length,
1286  uint8_t *output,
1287  size_t output_size,
1288  size_t *output_length)
1289 {
1290 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1291  return PSA_ERROR_NOT_SUPPORTED;
1292 #else
1293  psa_status_t status;
1294  struct tfm_crypto_pack_iovec iov = {
1296  .key_handle = handle,
1297  .alg = alg
1298  };
1299 
1300  /* Sanitize the optional input */
1301  if ((salt == NULL) && (salt_length != 0)) {
1303  }
1304 
1305  psa_invec in_vec[] = {
1306  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1307  {.base = input, .len = input_length},
1308  {.base = salt, .len = salt_length}
1309  };
1310 
1311  psa_outvec out_vec[] = {
1312  {.base = output, .len = output_size},
1313  };
1314 
1315  PSA_CONNECT(TFM_CRYPTO);
1316 
1317  size_t in_len = ARRAY_SIZE(in_vec);
1318  if (salt == NULL) {
1319  in_len--;
1320  }
1321  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1322  out_vec, ARRAY_SIZE(out_vec));
1323 
1324  *output_length = out_vec[0].len;
1325 
1326  PSA_CLOSE();
1327 
1328  return status;
1329 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1330 }
1331 
1333  const psa_key_derivation_operation_t *operation,
1334  size_t *capacity)
1335 {
1336 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1337  return PSA_ERROR_NOT_SUPPORTED;
1338 #else
1339  psa_status_t status;
1340  struct tfm_crypto_pack_iovec iov = {
1342  .op_handle = operation->handle,
1343  };
1344 
1345  psa_invec in_vec[] = {
1346  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1347  };
1348 
1349  psa_outvec out_vec[] = {
1350  {.base = capacity, .len = sizeof(size_t)},
1351  };
1352 
1353  PSA_CONNECT(TFM_CRYPTO);
1354 
1356  TFM_CRYPTO_KEY_DERIVATION_GET_CAPACITY);
1357 
1358  PSA_CLOSE();
1359 
1360  return status;
1361 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1362 }
1363 
1365  psa_key_derivation_operation_t *operation,
1366  uint8_t *output,
1367  size_t output_length)
1368 {
1369 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1370  return PSA_ERROR_NOT_SUPPORTED;
1371 #else
1372  psa_status_t status;
1373  struct tfm_crypto_pack_iovec iov = {
1375  .op_handle = operation->handle,
1376  };
1377 
1378  psa_invec in_vec[] = {
1379  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1380  };
1381 
1382  psa_outvec out_vec[] = {
1383  {.base = output, .len = output_length},
1384  };
1385 
1386  PSA_CONNECT(TFM_CRYPTO);
1387 
1389  TFM_CRYPTO_KEY_DERIVATION_OUTPUT_BYTES);
1390 
1391  PSA_CLOSE();
1392 
1393  return status;
1394 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1395 }
1396 
1398  psa_key_derivation_operation_t *operation,
1400  psa_key_handle_t handle)
1401 {
1402 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1403  return PSA_ERROR_NOT_SUPPORTED;
1404 #else
1405  psa_status_t status;
1406  struct tfm_crypto_pack_iovec iov = {
1408  .key_handle = handle,
1409  .step = step,
1410  .op_handle = operation->handle,
1411  };
1412 
1413  psa_invec in_vec[] = {
1414  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1415  };
1416 
1417  PSA_CONNECT(TFM_CRYPTO);
1418 
1420  TFM_CRYPTO_KEY_DERIVATION_INPUT_KEY);
1421 
1422  PSA_CLOSE();
1423 
1424  return status;
1425 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1426 }
1427 
1429  psa_key_derivation_operation_t *operation)
1430 {
1431 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1432  return PSA_ERROR_NOT_SUPPORTED;
1433 #else
1434  psa_status_t status;
1435  struct tfm_crypto_pack_iovec iov = {
1437  .op_handle = operation->handle,
1438  };
1439 
1440  psa_invec in_vec[] = {
1441  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1442  };
1443 
1444  psa_outvec out_vec[] = {
1445  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1446  };
1447 
1448  PSA_CONNECT(TFM_CRYPTO);
1449 
1451  TFM_CRYPTO_KEY_DERIVATION_ABORT);
1452 
1453  PSA_CLOSE();
1454 
1455  return status;
1456 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1457 }
1458 
1460  psa_key_derivation_operation_t *operation,
1462  psa_key_handle_t private_key,
1463  const uint8_t *peer_key,
1464  size_t peer_key_length)
1465 {
1466 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1467  return PSA_ERROR_NOT_SUPPORTED;
1468 #else
1469  psa_status_t status;
1470  struct tfm_crypto_pack_iovec iov = {
1472  .key_handle = private_key,
1473  .step = step,
1474  .op_handle = operation->handle,
1475  };
1476 
1477  psa_invec in_vec[] = {
1478  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1479  {.base = peer_key, .len = peer_key_length},
1480  };
1481 
1482  PSA_CONNECT(TFM_CRYPTO);
1483 
1485  TFM_CRYPTO_KEY_DERIVATION_KEY_AGREEMENT);
1486 
1487  PSA_CLOSE();
1488 
1489  return status;
1490 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1491 }
1492 
1494  size_t output_size)
1495 {
1496 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1497  return PSA_ERROR_NOT_SUPPORTED;
1498 #else
1499  psa_status_t status;
1500  struct tfm_crypto_pack_iovec iov = {
1502  };
1503 
1504  psa_invec in_vec[] = {
1505  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1506  };
1507 
1508  psa_outvec out_vec[] = {
1509  {.base = output, .len = output_size},
1510  };
1511 
1512  if (output_size == 0) {
1513  return PSA_SUCCESS;
1514  }
1515 
1516  PSA_CONNECT(TFM_CRYPTO);
1517 
1519  TFM_CRYPTO_GENERATE_RANDOM);
1520 
1521  PSA_CLOSE();
1522 
1523  return status;
1524 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1525 }
1526 
1528  psa_key_handle_t *handle)
1529 {
1530 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1531  return PSA_ERROR_NOT_SUPPORTED;
1532 #else
1533  psa_status_t status;
1534  struct tfm_crypto_pack_iovec iov = {
1536  };
1537 
1538  psa_invec in_vec[] = {
1539  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1540  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
1541  };
1542 
1543  psa_outvec out_vec[] = {
1544  {.base = handle, .len = sizeof(psa_key_handle_t)},
1545  };
1546 
1547  PSA_CONNECT(TFM_CRYPTO);
1548 
1550  TFM_CRYPTO_GENERATE_KEY);
1551  PSA_CLOSE();
1552 
1553  return status;
1554 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1555 }
1556 
1558  psa_key_type_t type,
1559  const uint8_t *data,
1560  size_t data_length)
1561 {
1562  psa_status_t status;
1563 
1564  status = PSA_ERROR_NOT_SUPPORTED;
1565 
1566  return status;
1567 }
1568 
1570  const psa_key_attributes_t *attributes,
1571  uint8_t *data,
1572  size_t data_size,
1573  size_t *data_length)
1574 {
1575  psa_status_t status;
1576 
1577  status = PSA_ERROR_NOT_SUPPORTED;
1578 
1579  return status;
1580 }
1581 
1583  const uint8_t *input,
1584  size_t input_length)
1585 {
1586  psa_status_t status;
1587 
1588  status = PSA_ERROR_NOT_SUPPORTED;
1589 
1590  return status;
1591 }
1592 
1594  uint8_t *ciphertext,
1595  size_t ciphertext_size,
1596  size_t *ciphertext_length,
1597  uint8_t *tag,
1598  size_t tag_size,
1599  size_t *tag_length)
1600 {
1601  psa_status_t status;
1602 
1603  status = PSA_ERROR_NOT_SUPPORTED;
1604 
1605  return status;
1606 }
1607 
1609  uint8_t *plaintext,
1610  size_t plaintext_size,
1611  size_t *plaintext_length,
1612  const uint8_t *tag,
1613  size_t tag_length)
1614 {
1615  psa_status_t status;
1616 
1617  status = PSA_ERROR_NOT_SUPPORTED;
1618 
1619  return status;
1620 }
1621 
1623 {
1624  psa_status_t status;
1625 
1626  status = PSA_ERROR_NOT_SUPPORTED;
1627 
1628  return status;
1629 }
1630 
1632  psa_algorithm_t alg,
1633  const uint8_t *input,
1634  size_t input_length,
1635  uint8_t *mac,
1636  size_t mac_size,
1637  size_t *mac_length)
1638 {
1639  psa_status_t status;
1640 
1641  status = PSA_ERROR_NOT_SUPPORTED;
1642 
1643  return status;
1644 }
1645 
1647  psa_algorithm_t alg,
1648  const uint8_t *input,
1649  size_t input_length,
1650  const uint8_t *mac,
1651  const size_t mac_length)
1652 {
1653  psa_status_t status;
1654 
1655  status = PSA_ERROR_NOT_SUPPORTED;
1656 
1657  return status;
1658 }
1659 
1661  psa_algorithm_t alg,
1662  const uint8_t *input,
1663  size_t input_length,
1664  uint8_t *output,
1665  size_t output_size,
1666  size_t *output_length)
1667 {
1668  psa_status_t status;
1669 
1670  status = PSA_ERROR_NOT_SUPPORTED;
1671 
1672  return status;
1673 }
1674 
1676  psa_algorithm_t alg,
1677  const uint8_t *input,
1678  size_t input_length,
1679  uint8_t *output,
1680  size_t output_size,
1681  size_t *output_length)
1682 {
1683  psa_status_t status;
1684 
1685  status = PSA_ERROR_NOT_SUPPORTED;
1686 
1687  return status;
1688 }
1689 
1691  psa_key_handle_t private_key,
1692  const uint8_t *peer_key,
1693  size_t peer_key_length,
1694  uint8_t *output,
1695  size_t output_size,
1696  size_t *output_length)
1697 {
1698 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1699  return PSA_ERROR_NOT_SUPPORTED;
1700 #else
1701  psa_status_t status;
1702  struct tfm_crypto_pack_iovec iov = {
1704  .alg = alg,
1705  .key_handle = private_key
1706  };
1707 
1708  psa_invec in_vec[] = {
1709  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1710  {.base = peer_key, .len = peer_key_length},
1711  };
1712 
1713  psa_outvec out_vec[] = {
1714  {.base = output, .len = output_size},
1715  };
1716 
1717  PSA_CONNECT(TFM_CRYPTO);
1718 
1720  TFM_CRYPTO_RAW_KEY_AGREEMENT);
1721 
1722  *output_length = out_vec[0].len;
1723 
1724  PSA_CLOSE();
1725 
1726  return status;
1727 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1728 }
1729 
1731  psa_algorithm_t alg)
1732 {
1733 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1734  return PSA_ERROR_NOT_SUPPORTED;
1735 #else
1736  psa_status_t status;
1737  struct tfm_crypto_pack_iovec iov = {
1739  .alg = alg,
1740  .op_handle = operation->handle,
1741  };
1742 
1743  psa_invec in_vec[] = {
1744  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1745  };
1746  psa_outvec out_vec[] = {
1747  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1748  };
1749 
1750  PSA_CONNECT(TFM_CRYPTO);
1751 
1753  TFM_CRYPTO_KEY_DERIVATION_SETUP);
1754  PSA_CLOSE();
1755 
1756  return status;
1757 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1758 }
1759 
1761  psa_key_derivation_operation_t *operation,
1762  size_t capacity)
1763 {
1764 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1765  return PSA_ERROR_NOT_SUPPORTED;
1766 #else
1767  psa_status_t status;
1768  struct tfm_crypto_pack_iovec iov = {
1770  .capacity = capacity,
1771  .op_handle = operation->handle,
1772  };
1773 
1774  psa_invec in_vec[] = {
1775  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1776  };
1777 
1778  PSA_CONNECT(TFM_CRYPTO);
1779 
1781  TFM_CRYPTO_KEY_DERIVATION_SET_CAPACITY);
1782  PSA_CLOSE();
1783 
1784  return status;
1785 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1786 }
1787 
1789  psa_key_derivation_operation_t *operation,
1791  const uint8_t *data,
1792  size_t data_length)
1793 {
1794 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1795  return PSA_ERROR_NOT_SUPPORTED;
1796 #else
1797  psa_status_t status;
1798  struct tfm_crypto_pack_iovec iov = {
1800  .step = step,
1801  .op_handle = operation->handle,
1802  };
1803 
1804  psa_invec in_vec[] = {
1805  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1806  {.base = data, .len = data_length},
1807  };
1808 
1809  PSA_CONNECT(TFM_CRYPTO);
1810 
1812  TFM_CRYPTO_KEY_DERIVATION_INPUT_BYTES);
1813  PSA_CLOSE();
1814 
1815  return status;
1816 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1817 }
1818 
1820  const psa_key_attributes_t *attributes,
1821  psa_key_derivation_operation_t *operation,
1822  psa_key_handle_t *handle)
1823 {
1824 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1825  return PSA_ERROR_NOT_SUPPORTED;
1826 #else
1827  psa_status_t status;
1828  struct tfm_crypto_pack_iovec iov = {
1830  .op_handle = operation->handle,
1831  };
1832 
1833  psa_invec in_vec[] = {
1834  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1835  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
1836  };
1837 
1838  psa_outvec out_vec[] = {
1839  {.base = handle, .len = sizeof(psa_key_handle_t)}
1840  };
1841 
1842  PSA_CONNECT(TFM_CRYPTO);
1843 
1845  TFM_CRYPTO_KEY_DERIVATION_OUTPUT_KEY);
1846  PSA_CLOSE();
1847 
1848  return status;
1849 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1850 }
1851 
1853  psa_key_handle_t handle,
1854  psa_algorithm_t alg)
1855 {
1856  psa_status_t status;
1857 
1858  status = PSA_ERROR_NOT_SUPPORTED;
1859 
1860  return status;
1861 }
1862 
1864  psa_key_handle_t handle,
1865  psa_algorithm_t alg)
1866 {
1867  psa_status_t status;
1868 
1869  status = PSA_ERROR_NOT_SUPPORTED;
1870 
1871  return status;
1872 }
1873 
1875  uint8_t *nonce,
1876  size_t nonce_size,
1877  size_t *nonce_length)
1878 {
1879  psa_status_t status;
1880 
1881  status = PSA_ERROR_NOT_SUPPORTED;
1882 
1883  return status;
1884 }
1885 
1887  const uint8_t *nonce,
1888  size_t nonce_length)
1889 {
1890  psa_status_t status;
1891 
1892  status = PSA_ERROR_NOT_SUPPORTED;
1893 
1894  return status;
1895 }
1896 
1898  size_t ad_length,
1899  size_t plaintext_length)
1900 {
1901  psa_status_t status;
1902 
1903  status = PSA_ERROR_NOT_SUPPORTED;
1904 
1905  return status;
1906 }
1907 
1909  const uint8_t *input,
1910  size_t input_length,
1911  uint8_t *output,
1912  size_t output_size,
1913  size_t *output_length)
1914 {
1915  psa_status_t status;
1916 
1917  status = PSA_ERROR_NOT_SUPPORTED;
1918 
1919  return status;
1920 }
psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
void psa_reset_key_attributes(psa_key_attributes_t *attributes)
#define TFM_CRYPTO_MAX_NONCE_LENGTH
This type is used to overcome a limitation in the number of maximum IOVECs that can be used especiall...
psa_status_t psa_generate_random(uint8_t *output, size_t output_size)
Generate random bytes.
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_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_destroy_key(psa_key_handle_t handle)
Destroy a key.
psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, const unsigned char *iv, size_t iv_length)
psa_status_t tfm_crypto_import_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:184
Structure used to pack non-pointer types in a call.
psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
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_status_t tfm_crypto_hash_abort(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:211
psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_status_t tfm_crypto_cipher_decrypt_setup(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, size_t capacity)
void * base
Definition: client.h:75
psa_status_t tfm_crypto_cipher_update(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
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_status_t psa_close_key(psa_key_handle_t handle)
psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
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_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, const uint8_t *mac, size_t mac_length)
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_status_t tfm_crypto_key_derivation_input_bytes(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t tfm_crypto_export_public_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:475
psa_status_t tfm_crypto_mac_sign_finish(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_mac.c:172
#define PSA_SUCCESS
Definition: crypto_values.h:35
psa_status_t tfm_crypto_key_derivation_set_capacity(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t tfm_crypto_open_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:245
Platform Security Architecture cryptography module.
psa_status_t tfm_crypto_cipher_abort(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t tfm_crypto_hash_verify(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:164
psa_status_t psa_asymmetric_verify(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)
psa_status_t psa_mac_abort(psa_mac_operation_t *operation)
uint16_t psa_key_derivation_step_t
Encoding of the step of a key derivation.
Definition: crypto_types.h:356
psa_status_t tfm_crypto_verify_hash(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
uint32_t psa_key_id_t
Definition: crypto_types.h:223
psa_status_t tfm_crypto_generate_random(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
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_status_t tfm_crypto_cipher_finish(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
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 tfm_crypto_hash_compute(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:306
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_algorithm_t alg
psa_status_t tfm_crypto_key_derivation_key_agreement(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t tfm_crypto_close_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:299
psa_status_t psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)
psa_status_t tfm_crypto_mac_verify_setup(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_mac.c:75
psa_status_t tfm_crypto_get_key_attributes(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:373
psa_status_t tfm_crypto_key_derivation_get_capacity(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
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_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 tfm_crypto_hash_finish(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:114
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_status_t tfm_crypto_hash_update(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:69
psa_status_t tfm_crypto_mac_update(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_mac.c:127
psa_status_t tfm_crypto_export_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:451
#define TFM_CRYPTO_SID
Definition: sid.h:40
psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_status_t psa_get_key_domain_parameters(const psa_key_attributes_t *attributes, uint8_t *data, size_t data_size, size_t *data_length)
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.
#define API_DISPATCH(sfn_name, sfn_id)
psa_status_t tfm_crypto_mac_verify_finish(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_mac.c:222
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 tfm_crypto_destroy_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:336
psa_status_t tfm_crypto_key_derivation_abort(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, const uint8_t *input, size_t input_length)
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_status_t tfm_crypto_cipher_encrypt_setup(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t psa_hash_verify(psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_length)
psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length)
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)
#define PSA_ERROR_INVALID_ARGUMENT
psa_handle_t psa_connect(uint32_t sid, uint32_t version)
Connect to an RoT Service by its SID.
Definition: psa_client.c:30
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, const size_t mac_length)
#define PSA_HANDLE_IS_VALID(handle)
Definition: client.h:43
psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation)
psa_status_t psa_asymmetric_sign(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)
psa_status_t psa_copy_key(psa_key_handle_t source_handle, const psa_key_attributes_t *attributes, psa_key_handle_t *target_handle)
#define PSA_CLOSE()
psa_status_t tfm_crypto_mac_abort(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_mac.c:269
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:90
psa_status_t tfm_crypto_sign_hash(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
struct psa_hash_operation_s psa_hash_operation_t
Definition: crypto.h:954
struct tfm_crypto_aead_pack_input aead_in
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_status_t tfm_crypto_hash_compare(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:335
#define TFM_CRYPTO_VERSION
Definition: sid.h:41
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 tfm_crypto_key_derivation_output_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, psa_key_handle_t handle, psa_algorithm_t alg)
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:58
psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes, psa_key_type_t type, const uint8_t *data, size_t data_length)
psa_status_t psa_get_key_attributes(psa_key_handle_t handle, psa_key_attributes_t *attributes)
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)
_unsigned_integral_type_ psa_key_handle_t
Key handle.
Definition: crypto.h:35
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_generate_key(const psa_key_attributes_t *attributes, psa_key_handle_t *handle)
Generate a key or key pair.
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_status_t tfm_crypto_hash_clone(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:257
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)
#define PSA_ERROR_NOT_SUPPORTED
Definition: crypto_values.h:52
psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
#define ARRAY_SIZE(arr)
psa_status_t tfm_crypto_key_derivation_input_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, unsigned char *iv, size_t iv_size, size_t *iv_length)
size_t len
Definition: client.h:76
#define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id)
psa_status_t psa_open_key(psa_key_id_t id, psa_key_handle_t *handle)
int32_t psa_handle_t
Definition: client.h:61
struct psa_client_key_attributes_s psa_key_attributes_t
Definition: crypto_types.h:347
psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
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_status_t psa_aead_abort(psa_aead_operation_t *operation)
psa_status_t tfm_crypto_cipher_generate_iv(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_cipher.c:23
psa_status_t tfm_crypto_key_derivation_setup(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
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 tfm_crypto_copy_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:499
#define PSA_CONNECT(service)
psa_status_t psa_cipher_update(psa_cipher_operation_t *operation, const uint8_t *input, size_t input_length, unsigned char *output, size_t output_size, size_t *output_length)
psa_status_t tfm_crypto_hash_setup(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_hash.c:23
psa_status_t tfm_crypto_cipher_set_iv(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_cipher.c:71
#define PSA_IPC_CALL
Definition: client.h:59
#define PSA_ERROR_BAD_STATE
psa_status_t tfm_crypto_key_derivation_output_bytes(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
const void * base
Definition: client.h:67
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43
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 tfm_crypto_mac_sign_setup(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_mac.c:23
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_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_status_t psa_call(psa_handle_t handle, int32_t type, const psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len)
Call an RoT Service on an established connection.
Definition: psa_client.c:47
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_status_t tfm_crypto_generate_key(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:561
psa_status_t tfm_crypto_reset_key_attributes(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_key.c:411
psa_status_t tfm_crypto_raw_key_agreement(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
psa_status_t psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)