TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_crypto_secure_api.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "tfm_veneers.h"
9 #include "tfm_crypto_defs.h"
10 #include "psa/crypto.h"
11 #ifdef TFM_PSA_API
12 #include "psa_manifest/sid.h"
13 #endif
14 
15 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
16 
17 #ifdef TFM_PSA_API
18 #include "psa/client.h"
19 
20 #define PSA_CONNECT(service) \
21  psa_handle_t ipc_handle; \
22  ipc_handle = psa_connect(service##_SID, service##_VERSION); \
23  if (!PSA_HANDLE_IS_VALID(ipc_handle)) { \
24  return PSA_ERROR_GENERIC_ERROR; \
25  } \
26 
27 #define PSA_CLOSE() psa_close(ipc_handle)
28 
29 #define API_DISPATCH(sfn_name, sfn_id) \
30  psa_call(ipc_handle, PSA_IPC_CALL, \
31  in_vec, ARRAY_SIZE(in_vec), \
32  out_vec, ARRAY_SIZE(out_vec))
33 
34 #define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id) \
35  psa_call(ipc_handle, PSA_IPC_CALL, \
36  in_vec, ARRAY_SIZE(in_vec), \
37  (psa_outvec *)NULL, 0)
38 #else
39 #define API_DISPATCH(sfn_name, sfn_id) \
40  tfm_##sfn_name##_veneer( \
41  in_vec, ARRAY_SIZE(in_vec), \
42  out_vec, ARRAY_SIZE(out_vec))
43 
44 #define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id) \
45  tfm_##sfn_name##_veneer( \
46  in_vec, ARRAY_SIZE(in_vec), \
47  NULL, 0)
48 #endif /* TFM_PSA_API */
49 
50 __attribute__((section("SFN")))
52 {
53  /* Service init is performed during TFM boot up,
54  * so application level initialisation is empty
55  */
56  return PSA_SUCCESS;
57 }
58 
59 __attribute__((section("SFN")))
60 
62  psa_key_handle_t *handle)
63 {
64 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
66 #else
67  psa_status_t status;
68  struct tfm_crypto_pack_iovec iov = {
70  };
71  psa_invec in_vec[] = {
72  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
73  {.base = &id, .len = sizeof(psa_key_id_t)},
74  };
75  psa_outvec out_vec[] = {
76  {.base = handle, .len = sizeof(psa_key_handle_t)},
77  };
78 
79 #ifdef TFM_PSA_API
80  PSA_CONNECT(TFM_CRYPTO);
81 #endif
82 
84  TFM_CRYPTO_OPEN_KEY);
85 
86 #ifdef TFM_PSA_API
87  PSA_CLOSE();
88 #endif
89 
90  return status;
91 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
92 }
93 
94 __attribute__((section("SFN")))
96 {
97 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
99 #else
100  psa_status_t status;
101  struct tfm_crypto_pack_iovec iov = {
103  .key_handle = handle,
104  };
105  psa_invec in_vec[] = {
106  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
107  };
108 
109 #ifdef TFM_PSA_API
110  PSA_CONNECT(TFM_CRYPTO);
111 #endif
112 
114  TFM_CRYPTO_CLOSE_KEY);;
115 
116 #ifdef TFM_PSA_API
117  PSA_CLOSE();
118 #endif
119 
120  return status;
121 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
122 }
123 
124 __attribute__((section("SFN")))
126  const uint8_t *data,
127  size_t data_length,
128  psa_key_handle_t *handle)
129 {
130 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
132 #else
133  psa_status_t status;
134  struct tfm_crypto_pack_iovec iov = {
136  };
137  psa_invec in_vec[] = {
138  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
139  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
140  {.base = data, .len = data_length}
141  };
142  psa_outvec out_vec[] = {
143  {.base = handle, .len = sizeof(psa_key_handle_t)}
144  };
145 
146 #ifdef TFM_PSA_API
147  PSA_CONNECT(TFM_CRYPTO);
148 #endif
149 
151  TFM_CRYPTO_IMPORT_KEY);
152 #ifdef TFM_PSA_API
153  PSA_CLOSE();
154 #endif
155 
156  return status;
157 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
158 }
159 
160 __attribute__((section("SFN")))
162 {
163 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
165 #else
166  psa_status_t status;
167  struct tfm_crypto_pack_iovec iov = {
169  .key_handle = handle,
170  };
171  psa_invec in_vec[] = {
172  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
173  };
174 
175 #ifdef TFM_PSA_API
176  PSA_CONNECT(TFM_CRYPTO);
177 #endif
178 
180  TFM_CRYPTO_DESTROY_KEY);
181 #ifdef TFM_PSA_API
182  PSA_CLOSE();
183 #endif
184 
185  return status;
186 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
187 }
188 
189 __attribute__((section("SFN")))
191  psa_key_attributes_t *attributes)
192 {
193 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
195 #else
196  psa_status_t status;
197  struct tfm_crypto_pack_iovec iov = {
199  .key_handle = handle,
200  };
201  psa_invec in_vec[] = {
202  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
203  };
204  psa_outvec out_vec[] = {
205  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
206  };
207 
208 #ifdef TFM_PSA_API
209  PSA_CONNECT(TFM_CRYPTO);
210 #endif
211 
213  TFM_CRYPTO_GET_KEY_ATTRIBUTES);
214 #ifdef TFM_PSA_API
215  PSA_CLOSE();
216 #endif
217 
218  return status;
219 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
220 }
221 
223 {
224 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
226 #else
227  struct tfm_crypto_pack_iovec iov = {
229  };
230  psa_invec in_vec[] = {
231  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
232  };
233  psa_outvec out_vec[] = {
234  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
235  };
236 
237 #ifdef TFM_PSA_API
238  psa_handle_t ipc_handle;
240  if (!PSA_HANDLE_IS_VALID(ipc_handle)) {
241  return;
242  }
243 #endif
244 
246  TFM_CRYPTO_RESET_KEY_ATTRIBUTES);
247 #ifdef TFM_PSA_API
248  PSA_CLOSE();
249 #endif
250 
251  return;
252 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
253 }
254 
255 __attribute__((section("SFN")))
257  uint8_t *data,
258  size_t data_size,
259  size_t *data_length)
260 {
261 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
263 #else
264  psa_status_t status;
265  struct tfm_crypto_pack_iovec iov = {
267  .key_handle = handle,
268  };
269  psa_invec in_vec[] = {
270  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
271  };
272  psa_outvec out_vec[] = {
273  {.base = data, .len = data_size}
274  };
275 
276 #ifdef TFM_PSA_API
277  PSA_CONNECT(TFM_CRYPTO);
278 #endif
279 
281  TFM_CRYPTO_EXPORT_KEY);
282 
283  *data_length = out_vec[0].len;
284 
285 #ifdef TFM_PSA_API
286  PSA_CLOSE();
287 #endif
288 
289  return status;
290 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
291 }
292 
293 __attribute__((section("SFN")))
295  uint8_t *data,
296  size_t data_size,
297  size_t *data_length)
298 {
299 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
301 #else
302  psa_status_t status;
303  struct tfm_crypto_pack_iovec iov = {
305  .key_handle = handle,
306  };
307 
308  psa_invec in_vec[] = {
309  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
310  };
311  psa_outvec out_vec[] = {
312  {.base = data, .len = data_size}
313  };
314 
315 #ifdef TFM_PSA_API
316  PSA_CONNECT(TFM_CRYPTO);
317 #endif
318 
320  TFM_CRYPTO_EXPORT_PUBLIC_KEY);
321 
322  *data_length = out_vec[0].len;
323 
324 #ifdef TFM_PSA_API
325  PSA_CLOSE();
326 #endif
327 
328  return status;
329 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
330 }
331 
332 __attribute__((section("SFN")))
334  const psa_key_attributes_t *attributes,
335  psa_key_handle_t *target_handle)
336 {
337 #ifdef TFM_CRYPTO_KEY_MODULE_DISABLED
339 #else
340  psa_status_t status;
341  struct tfm_crypto_pack_iovec iov = {
343  .key_handle = source_handle,
344  };
345 
346  psa_invec in_vec[] = {
347  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
348  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
349  };
350 
351  psa_outvec out_vec[] = {
352  {.base = target_handle, .len = sizeof(psa_key_handle_t)},
353  };
354 
355 #ifdef TFM_PSA_API
356  PSA_CONNECT(TFM_CRYPTO);
357 #endif
358 
360  TFM_CRYPTO_COPY_KEY);
361 #ifdef TFM_PSA_API
362  PSA_CLOSE();
363 #endif
364 
365  return status;
366 #endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
367 }
368 
369 __attribute__((section("SFN")))
371  unsigned char *iv,
372  size_t iv_size,
373  size_t *iv_length)
374 {
375 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
377 #else
378  psa_status_t status;
379  struct tfm_crypto_pack_iovec iov = {
381  .op_handle = operation->handle,
382  };
383 
384  psa_invec in_vec[] = {
385  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
386  };
387  psa_outvec out_vec[] = {
388  {.base = &(operation->handle), .len = sizeof(uint32_t)},
389  {.base = iv, .len = iv_size},
390  };
391 
392 #ifdef TFM_PSA_API
393  PSA_CONNECT(TFM_CRYPTO);
394 #endif
395 
397  TFM_CRYPTO_CIPHER_GENERATE_IV);
398 
399  *iv_length = out_vec[1].len;
400 
401 #ifdef TFM_PSA_API
402  PSA_CLOSE();
403 #endif
404 
405  return status;
406 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
407 }
408 
409 __attribute__((section("SFN")))
411  const unsigned char *iv,
412  size_t iv_length)
413 {
414 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
416 #else
417  psa_status_t status;
418  struct tfm_crypto_pack_iovec iov = {
420  .op_handle = operation->handle,
421  };
422 
423  psa_invec in_vec[] = {
424  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
425  {.base = iv, .len = iv_length},
426  };
427  psa_outvec out_vec[] = {
428  {.base = &(operation->handle), .len = sizeof(uint32_t)},
429  };
430 
431 #ifdef TFM_PSA_API
432  PSA_CONNECT(TFM_CRYPTO);
433 #endif
434 
436  TFM_CRYPTO_CIPHER_SET_IV);
437 #ifdef TFM_PSA_API
438  PSA_CLOSE();
439 #endif
440 
441  return status;
442 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
443 }
444 
445 __attribute__((section("SFN")))
447  psa_key_handle_t handle,
449 {
450 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
452 #else
453  psa_status_t status;
454  struct tfm_crypto_pack_iovec iov = {
456  .key_handle = handle,
457  .alg = alg,
458  .op_handle = operation->handle,
459  };
460 
461  psa_invec in_vec[] = {
462  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
463  };
464  psa_outvec out_vec[] = {
465  {.base = &(operation->handle), .len = sizeof(uint32_t)},
466  };
467 
468 #ifdef TFM_PSA_API
469  PSA_CONNECT(TFM_CRYPTO);
470 #endif
471 
473  TFM_CRYPTO_CIPHER_ENCRYPT_SETUP);
474 #ifdef TFM_PSA_API
475  PSA_CLOSE();
476 #endif
477 
478  return status;
479 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
480 }
481 
482 __attribute__((section("SFN")))
484  psa_key_handle_t handle,
485  psa_algorithm_t alg)
486 {
487 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
489 #else
490  psa_status_t status;
491  struct tfm_crypto_pack_iovec iov = {
493  .key_handle = handle,
494  .alg = alg,
495  .op_handle = operation->handle,
496  };
497 
498  psa_invec in_vec[] = {
499  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
500  };
501  psa_outvec out_vec[] = {
502  {.base = &(operation->handle), .len = sizeof(uint32_t)},
503  };
504 
505 #ifdef TFM_PSA_API
506  PSA_CONNECT(TFM_CRYPTO);
507 #endif
508 
510  TFM_CRYPTO_CIPHER_DECRYPT_SETUP);
511 #ifdef TFM_PSA_API
512  PSA_CLOSE();
513 #endif
514 
515  return status;
516 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
517 }
518 
519 __attribute__((section("SFN")))
521  const uint8_t *input,
522  size_t input_length,
523  unsigned char *output,
524  size_t output_size,
525  size_t *output_length)
526 {
527 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
529 #else
530  psa_status_t status;
531  struct tfm_crypto_pack_iovec iov = {
533  .op_handle = operation->handle,
534  };
535 
536  psa_invec in_vec[] = {
537  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
538  {.base = input, .len = input_length},
539  };
540  psa_outvec out_vec[] = {
541  {.base = &(operation->handle), .len = sizeof(uint32_t)},
542  {.base = output, .len = output_size}
543  };
544 
545 #ifdef TFM_PSA_API
546  PSA_CONNECT(TFM_CRYPTO);
547 #endif
548 
550  TFM_CRYPTO_CIPHER_UPDATE);
551 
552  *output_length = out_vec[1].len;
553 
554 #ifdef TFM_PSA_API
555  PSA_CLOSE();
556 #endif
557 
558  return status;
559 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
560 }
561 
562 __attribute__((section("SFN")))
564 {
565 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
567 #else
568  psa_status_t status;
569  struct tfm_crypto_pack_iovec iov = {
571  .op_handle = operation->handle,
572  };
573 
574  psa_invec in_vec[] = {
575  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
576  };
577  psa_outvec out_vec[] = {
578  {.base = &(operation->handle), .len = sizeof(uint32_t)},
579  };
580 
581 #ifdef TFM_PSA_API
582  PSA_CONNECT(TFM_CRYPTO);
583 #endif
584 
586  TFM_CRYPTO_CIPHER_ABORT);
587 #ifdef TFM_PSA_API
588  PSA_CLOSE();
589 #endif
590 
591  return status;
592 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
593 }
594 
595 __attribute__((section("SFN")))
597  uint8_t *output,
598  size_t output_size,
599  size_t *output_length)
600 {
601 #ifdef TFM_CRYPTO_CIPHER_MODULE_DISABLED
603 #else
604  psa_status_t status;
605  struct tfm_crypto_pack_iovec iov = {
607  .op_handle = operation->handle,
608  };
609 
610  psa_invec in_vec[] = {
611  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
612  };
613  psa_outvec out_vec[] = {
614  {.base = &(operation->handle), .len = sizeof(uint32_t)},
615  {.base = output, .len = output_size},
616  };
617 
618 #ifdef TFM_PSA_API
619  PSA_CONNECT(TFM_CRYPTO);
620 #endif
621 
623  TFM_CRYPTO_CIPHER_FINISH);
624 
625  *output_length = out_vec[1].len;
626 
627 #ifdef TFM_PSA_API
628  PSA_CLOSE();
629 #endif
630 
631  return status;
632 #endif /* TFM_CRYPTO_CIPHER_MODULE_DISABLED */
633 }
634 
635 __attribute__((section("SFN")))
637  psa_algorithm_t alg)
638 {
639 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
641 #else
642  psa_status_t status;
643  struct tfm_crypto_pack_iovec iov = {
645  .alg = alg,
646  .op_handle = operation->handle,
647  };
648 
649  psa_invec in_vec[] = {
650  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
651  };
652  psa_outvec out_vec[] = {
653  {.base = &(operation->handle), .len = sizeof(uint32_t)},
654  };
655 
656 #ifdef TFM_PSA_API
657  PSA_CONNECT(TFM_CRYPTO);
658 #endif
659 
661  TFM_CRYPTO_HASH_SETUP);
662 
663 #ifdef TFM_PSA_API
664  PSA_CLOSE();
665 #endif
666 
667  return status;
668 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
669 }
670 
671 __attribute__((section("SFN")))
673  const uint8_t *input,
674  size_t input_length)
675 {
676 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
678 #else
679  psa_status_t status;
680  struct tfm_crypto_pack_iovec iov = {
682  .op_handle = operation->handle,
683  };
684 
685  psa_invec in_vec[] = {
686  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
687  {.base = input, .len = input_length},
688  };
689  psa_outvec out_vec[] = {
690  {.base = &(operation->handle), .len = sizeof(uint32_t)},
691  };
692 
693 #ifdef TFM_PSA_API
694  PSA_CONNECT(TFM_CRYPTO);
695 #endif
696 
698  TFM_CRYPTO_HASH_UPDATE);
699 
700 #ifdef TFM_PSA_API
701  PSA_CLOSE();
702 #endif
703 
704  return status;
705 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
706 }
707 
708 __attribute__((section("SFN")))
710  uint8_t *hash,
711  size_t hash_size,
712  size_t *hash_length)
713 {
714 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
716 #else
717  psa_status_t status;
718  struct tfm_crypto_pack_iovec iov = {
720  .op_handle = operation->handle,
721  };
722 
723  psa_invec in_vec[] = {
724  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
725  };
726  psa_outvec out_vec[] = {
727  {.base = &(operation->handle), .len = sizeof(uint32_t)},
728  {.base = hash, .len = hash_size},
729  };
730 
731 #ifdef TFM_PSA_API
732  PSA_CONNECT(TFM_CRYPTO);
733 #endif
734 
736  TFM_CRYPTO_HASH_FINISH);
737 
738  *hash_length = out_vec[1].len;
739 
740 #ifdef TFM_PSA_API
741  PSA_CLOSE();
742 #endif
743 
744  return status;
745 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
746 }
747 
748 __attribute__((section("SFN")))
750  const uint8_t *hash,
751  size_t hash_length)
752 {
753 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
755 #else
756  psa_status_t status;
757  struct tfm_crypto_pack_iovec iov = {
759  .op_handle = operation->handle,
760  };
761 
762  psa_invec in_vec[] = {
763  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
764  {.base = hash, .len = hash_length},
765  };
766  psa_outvec out_vec[] = {
767  {.base = &(operation->handle), .len = sizeof(uint32_t)},
768  };
769 
770 #ifdef TFM_PSA_API
771  PSA_CONNECT(TFM_CRYPTO);
772 #endif
773 
775  TFM_CRYPTO_HASH_VERIFY);
776 #ifdef TFM_PSA_API
777  PSA_CLOSE();
778 #endif
779 
780  return status;
781 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
782 }
783 
784 __attribute__((section("SFN")))
786 {
787 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
789 #else
790  psa_status_t status;
791  struct tfm_crypto_pack_iovec iov = {
793  .op_handle = operation->handle,
794  };
795 
796  psa_invec in_vec[] = {
797  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
798  };
799  psa_outvec out_vec[] = {
800  {.base = &(operation->handle), .len = sizeof(uint32_t)},
801  };
802 
803 #ifdef TFM_PSA_API
804  PSA_CONNECT(TFM_CRYPTO);
805 #endif
806 
808  TFM_CRYPTO_HASH_ABORT);
809 #ifdef TFM_PSA_API
810  PSA_CLOSE();
811 #endif
812 
813  return status;
814 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
815 }
816 
817 __attribute__((section("SFN")))
819  psa_hash_operation_t *target_operation)
820 {
821 #ifdef TFM_CRYPTO_HASH_MODULE_DISABLED
823 #else
824  psa_status_t status;
825  struct tfm_crypto_pack_iovec iov = {
827  .op_handle = source_operation->handle,
828  };
829 
830  psa_invec in_vec[] = {
831  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
832  };
833  psa_outvec out_vec[] = {
834  {.base = target_operation, .len = sizeof(psa_hash_operation_t)},
835  };
836 
837  if (target_operation && (target_operation->handle != 0)) {
838  return PSA_ERROR_BAD_STATE;
839  }
840 
841 #ifdef TFM_PSA_API
842  PSA_CONNECT(TFM_CRYPTO);
843 #endif
844 
846  TFM_CRYPTO_HASH_CLONE);
847 #ifdef TFM_PSA_API
848  PSA_CLOSE();
849 #endif
850 
851  return status;
852 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
853 }
854 
855 __attribute__((section("SFN")))
857  const uint8_t *input,
858  size_t input_length,
859  uint8_t *hash,
860  size_t hash_size,
861  size_t *hash_length)
862 {
863 #if (TFM_CRYPTO_HASH_MODULE_DISABLED != 0)
865 #else
866  psa_status_t status;
867  struct tfm_crypto_pack_iovec iov = {
869  .alg = alg,
870  };
871 
872  psa_invec in_vec[] = {
873  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
874  {.base = input, .len = input_length},
875  };
876 
877  psa_outvec out_vec[] = {
878  {.base = hash, .len = hash_size}
879  };
880 
881 #ifdef TFM_PSA_API
882  PSA_CONNECT(TFM_CRYPTO);
883 #endif
884 
886  TFM_CRYPTO_HASH_COMPUTE);
887 
888  *hash_length = out_vec[0].len;
889 
890 #ifdef TFM_PSA_API
891  PSA_CLOSE();
892 #endif
893 
894  return status;
895 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
896 }
897 
898 __attribute__((section("SFN")))
900  const uint8_t *input,
901  size_t input_length,
902  const uint8_t *hash,
903  size_t hash_length)
904 {
905 #if (TFM_CRYPTO_HASH_MODULE_DISABLED != 0)
907 #else
908  psa_status_t status;
909  struct tfm_crypto_pack_iovec iov = {
911  .alg = alg,
912  };
913 
914  psa_invec in_vec[] = {
915  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
916  {.base = input, .len = input_length},
917  {.base = hash, .len = hash_length},
918  };
919 
920 #ifdef TFM_PSA_API
921  PSA_CONNECT(TFM_CRYPTO);
922 #endif
923 
925  TFM_CRYPTO_HASH_COMPARE);
926 
927 #ifdef TFM_PSA_API
928  PSA_CLOSE();
929 #endif
930 
931  return status;
932 #endif /* TFM_CRYPTO_HASH_MODULE_DISABLED */
933 }
934 
935 __attribute__((section("SFN")))
937  psa_key_handle_t handle,
938  psa_algorithm_t alg)
939 {
940 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
942 #else
943  psa_status_t status;
944  struct tfm_crypto_pack_iovec iov = {
946  .key_handle = handle,
947  .alg = alg,
948  .op_handle = operation->handle,
949  };
950 
951  psa_invec in_vec[] = {
952  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
953  };
954  psa_outvec out_vec[] = {
955  {.base = &(operation->handle), .len = sizeof(uint32_t)},
956  };
957 
958 #ifdef TFM_PSA_API
959  PSA_CONNECT(TFM_CRYPTO);
960 #endif
961 
963  TFM_CRYPTO_MAC_SIGN_SETUP);
964 #ifdef TFM_PSA_API
965  PSA_CLOSE();
966 #endif
967 
968  return status;
969 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
970 }
971 
972 __attribute__((section("SFN")))
974  psa_key_handle_t handle,
975  psa_algorithm_t alg)
976 {
977 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
979 #else
980  psa_status_t status;
981  struct tfm_crypto_pack_iovec iov = {
983  .key_handle = handle,
984  .alg = alg,
985  .op_handle = operation->handle,
986  };
987 
988  psa_invec in_vec[] = {
989  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
990  };
991  psa_outvec out_vec[] = {
992  {.base = &(operation->handle), .len = sizeof(uint32_t)},
993  };
994 
995 #ifdef TFM_PSA_API
996  PSA_CONNECT(TFM_CRYPTO);
997 #endif
998 
1000  TFM_CRYPTO_MAC_VERIFY_SETUP);
1001 #ifdef TFM_PSA_API
1002  PSA_CLOSE();
1003 #endif
1004 
1005  return status;
1006 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
1007 }
1008 
1009 __attribute__((section("SFN")))
1011  const uint8_t *input,
1012  size_t input_length)
1013 {
1014 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
1015  return PSA_ERROR_NOT_SUPPORTED;
1016 #else
1017  psa_status_t status;
1018  struct tfm_crypto_pack_iovec iov = {
1020  .op_handle = operation->handle,
1021  };
1022 
1023  psa_invec in_vec[] = {
1024  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1025  {.base = input, .len = input_length},
1026  };
1027  psa_outvec out_vec[] = {
1028  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1029  };
1030 
1031 #ifdef TFM_PSA_API
1032  PSA_CONNECT(TFM_CRYPTO);
1033 #endif
1034 
1036  TFM_CRYPTO_MAC_UPDATE);
1037 #ifdef TFM_PSA_API
1038  PSA_CLOSE();
1039 #endif
1040 
1041  return status;
1042 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
1043 }
1044 
1045 __attribute__((section("SFN")))
1047  uint8_t *mac,
1048  size_t mac_size,
1049  size_t *mac_length)
1050 {
1051 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
1052  return PSA_ERROR_NOT_SUPPORTED;
1053 #else
1054  psa_status_t status;
1055  struct tfm_crypto_pack_iovec iov = {
1057  .op_handle = operation->handle,
1058  };
1059 
1060  psa_invec in_vec[] = {
1061  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1062  };
1063  psa_outvec out_vec[] = {
1064  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1065  {.base = mac, .len = mac_size},
1066  };
1067 
1068 #ifdef TFM_PSA_API
1069  PSA_CONNECT(TFM_CRYPTO);
1070 #endif
1071 
1073  TFM_CRYPTO_MAC_SIGN_FINISH);
1074 
1075  *mac_length = out_vec[1].len;
1076 
1077 #ifdef TFM_PSA_API
1078  PSA_CLOSE();
1079 #endif
1080 
1081  return status;
1082 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
1083 }
1084 
1085 __attribute__((section("SFN")))
1087  const uint8_t *mac,
1088  size_t mac_length)
1089 {
1090 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
1091  return PSA_ERROR_NOT_SUPPORTED;
1092 #else
1093  psa_status_t status;
1094  struct tfm_crypto_pack_iovec iov = {
1096  .op_handle = operation->handle,
1097  };
1098 
1099  psa_invec in_vec[] = {
1100  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1101  {.base = mac, .len = mac_length},
1102  };
1103  psa_outvec out_vec[] = {
1104  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1105  };
1106 
1107 #ifdef TFM_PSA_API
1108  PSA_CONNECT(TFM_CRYPTO);
1109 #endif
1110 
1112  TFM_CRYPTO_MAC_VERIFY_FINISH);
1113 
1114 #ifdef TFM_PSA_API
1115  PSA_CLOSE();
1116 #endif
1117 
1118  return status;
1119 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
1120 }
1121 
1122 __attribute__((section("SFN")))
1124 {
1125 #ifdef TFM_CRYPTO_MAC_MODULE_DISABLED
1126  return PSA_ERROR_NOT_SUPPORTED;
1127 #else
1128  psa_status_t status;
1129  struct tfm_crypto_pack_iovec iov = {
1131  .op_handle = operation->handle,
1132  };
1133 
1134  psa_invec in_vec[] = {
1135  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1136  };
1137  psa_outvec out_vec[] = {
1138  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1139  };
1140 
1141 #ifdef TFM_PSA_API
1142  PSA_CONNECT(TFM_CRYPTO);
1143 #endif
1144 
1146  TFM_CRYPTO_MAC_ABORT);
1147 #ifdef TFM_PSA_API
1148  PSA_CLOSE();
1149 #endif
1150 
1151  return status;
1152 #endif /* TFM_CRYPTO_MAC_MODULE_DISABLED */
1153 }
1154 
1155 __attribute__((section("SFN")))
1157  psa_algorithm_t alg,
1158  const uint8_t *nonce,
1159  size_t nonce_length,
1160  const uint8_t *additional_data,
1161  size_t additional_data_length,
1162  const uint8_t *plaintext,
1163  size_t plaintext_length,
1164  uint8_t *ciphertext,
1165  size_t ciphertext_size,
1166  size_t *ciphertext_length)
1167 {
1168 #ifdef TFM_CRYPTO_AEAD_MODULE_DISABLED
1169  return PSA_ERROR_NOT_SUPPORTED;
1170 #else
1171  psa_status_t status;
1172  struct tfm_crypto_pack_iovec iov = {
1174  .key_handle = handle,
1175  .alg = alg,
1176  .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
1177  };
1178 
1179  /* Sanitize the optional input */
1180  if ((additional_data == NULL) && (additional_data_length != 0)) {
1182  }
1183 
1184  size_t idx = 0;
1185  psa_invec in_vec[] = {
1186  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1187  {.base = plaintext, .len = plaintext_length},
1188  {.base = additional_data, .len = additional_data_length},
1189  };
1190  psa_outvec out_vec[] = {
1191  {.base = ciphertext, .len = ciphertext_size},
1192  };
1193 
1194  if (nonce_length > TFM_CRYPTO_MAX_NONCE_LENGTH) {
1196  }
1197 
1198  if (nonce != NULL) {
1199  for (idx = 0; idx < nonce_length; idx++) {
1200  iov.aead_in.nonce[idx] = nonce[idx];
1201  }
1202  }
1203 
1204 #ifdef TFM_PSA_API
1205  PSA_CONNECT(TFM_CRYPTO);
1206 #endif
1207 
1208 #ifdef TFM_PSA_API
1209  size_t in_len = ARRAY_SIZE(in_vec);
1210  if (additional_data == NULL) {
1211  in_len--;
1212  }
1213  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1214  out_vec, ARRAY_SIZE(out_vec));
1215 #else
1217  TFM_CRYPTO_AEAD_ENCRYPT);
1218 #endif
1219 
1220  *ciphertext_length = out_vec[0].len;
1221 
1222 #ifdef TFM_PSA_API
1223  PSA_CLOSE();
1224 #endif
1225 
1226  return status;
1227 #endif /* TFM_CRYPTO_AEAD_MODULE_DISABLED */
1228 }
1229 
1230 __attribute__((section("SFN")))
1232  psa_algorithm_t alg,
1233  const uint8_t *nonce,
1234  size_t nonce_length,
1235  const uint8_t *additional_data,
1236  size_t additional_data_length,
1237  const uint8_t *ciphertext,
1238  size_t ciphertext_length,
1239  uint8_t *plaintext,
1240  size_t plaintext_size,
1241  size_t *plaintext_length)
1242 {
1243 #ifdef TFM_CRYPTO_AEAD_MODULE_DISABLED
1244  return PSA_ERROR_NOT_SUPPORTED;
1245 #else
1246  psa_status_t status;
1247  struct tfm_crypto_pack_iovec iov = {
1249  .key_handle = handle,
1250  .alg = alg,
1251  .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
1252  };
1253 
1254  /* Sanitize the optional input */
1255  if ((additional_data == NULL) && (additional_data_length != 0)) {
1257  }
1258 
1259  size_t idx = 0;
1260  psa_invec in_vec[] = {
1261  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1262  {.base = ciphertext, .len = ciphertext_length},
1263  {.base = additional_data, .len = additional_data_length},
1264  };
1265  psa_outvec out_vec[] = {
1266  {.base = plaintext, .len = plaintext_size},
1267  };
1268 
1269  if (nonce_length > TFM_CRYPTO_MAX_NONCE_LENGTH) {
1271  }
1272 
1273  if (nonce != NULL) {
1274  for (idx = 0; idx < nonce_length; idx++) {
1275  iov.aead_in.nonce[idx] = nonce[idx];
1276  }
1277  }
1278 
1279 #ifdef TFM_PSA_API
1280  PSA_CONNECT(TFM_CRYPTO);
1281 #endif
1282 
1283 #ifdef TFM_PSA_API
1284  size_t in_len = ARRAY_SIZE(in_vec);
1285  if (additional_data == NULL) {
1286  in_len--;
1287  }
1288  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1289  out_vec, ARRAY_SIZE(out_vec));
1290 #else
1292  TFM_CRYPTO_AEAD_DECRYPT);
1293 #endif
1294 
1295  *plaintext_length = out_vec[0].len;
1296 
1297 #ifdef TFM_PSA_API
1298  PSA_CLOSE();
1299 #endif
1300 
1301  return status;
1302 #endif /* TFM_CRYPTO_AEAD_MODULE_DISABLED */
1303 }
1304 
1305 __attribute__((section("SFN")))
1307  psa_algorithm_t alg,
1308  const uint8_t *hash,
1309  size_t hash_length,
1310  uint8_t *signature,
1311  size_t signature_size,
1312  size_t *signature_length)
1313 {
1314  return psa_sign_hash(handle, alg, hash, hash_length, signature, signature_size, signature_length);
1315 }
1316 
1317 __attribute__((section("SFN")))
1319  psa_algorithm_t alg,
1320  const uint8_t *hash,
1321  size_t hash_length,
1322  uint8_t *signature,
1323  size_t signature_size,
1324  size_t *signature_length)
1325 {
1326 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1327  return PSA_ERROR_NOT_SUPPORTED;
1328 #else
1329  psa_status_t status;
1330  struct tfm_crypto_pack_iovec iov = {
1332  .key_handle = handle,
1333  .alg = alg,
1334  };
1335 
1336  psa_invec in_vec[] = {
1337  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1338  {.base = hash, .len = hash_length},
1339  };
1340  psa_outvec out_vec[] = {
1341  {.base = signature, .len = signature_size},
1342  };
1343 
1344 #ifdef TFM_PSA_API
1345  PSA_CONNECT(TFM_CRYPTO);
1346 #endif
1348  TFM_CRYPTO_SIGN_HASH);
1349 
1350  *signature_length = out_vec[0].len;
1351 
1352 #ifdef TFM_PSA_API
1353  PSA_CLOSE();
1354 #endif
1355 
1356  return status;
1357 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1358 }
1359 
1360 __attribute__((section("SFN")))
1362  psa_algorithm_t alg,
1363  const uint8_t *hash,
1364  size_t hash_length,
1365  const uint8_t *signature,
1366  size_t signature_length)
1367 {
1368  return psa_verify_hash(handle, alg, hash, hash_length, signature, signature_length);
1369 }
1370 
1371 __attribute__((section("SFN")))
1373  psa_algorithm_t alg,
1374  const uint8_t *hash,
1375  size_t hash_length,
1376  const uint8_t *signature,
1377  size_t signature_length)
1378 {
1379 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1380  return PSA_ERROR_NOT_SUPPORTED;
1381 #else
1382  psa_status_t status;
1383  struct tfm_crypto_pack_iovec iov = {
1385  .key_handle = handle,
1386  .alg = alg
1387  };
1388 
1389  psa_invec in_vec[] = {
1390  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1391  {.base = hash, .len = hash_length},
1392  {.base = signature, .len = signature_length}
1393  };
1394 
1395 #ifdef TFM_PSA_API
1396  PSA_CONNECT(TFM_CRYPTO);
1397 #endif
1398 
1400  TFM_CRYPTO_VERIFY_HASH);
1401 #ifdef TFM_PSA_API
1402  PSA_CLOSE();
1403 #endif
1404 
1405  return status;
1406 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1407 }
1408 
1409 __attribute__((section("SFN")))
1411  psa_algorithm_t alg,
1412  const uint8_t *input,
1413  size_t input_length,
1414  const uint8_t *salt,
1415  size_t salt_length,
1416  uint8_t *output,
1417  size_t output_size,
1418  size_t *output_length)
1419 {
1420 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1421  return PSA_ERROR_NOT_SUPPORTED;
1422 #else
1423  psa_status_t status;
1424  struct tfm_crypto_pack_iovec iov = {
1426  .key_handle = handle,
1427  .alg = alg
1428  };
1429 
1430  /* Sanitize the optional input */
1431  if ((salt == NULL) && (salt_length != 0)) {
1433  }
1434 
1435  psa_invec in_vec[] = {
1436  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1437  {.base = input, .len = input_length},
1438  {.base = salt, .len = salt_length}
1439  };
1440 
1441  psa_outvec out_vec[] = {
1442  {.base = output, .len = output_size},
1443  };
1444 
1445 #ifdef TFM_PSA_API
1446  PSA_CONNECT(TFM_CRYPTO);
1447 #endif
1448 
1449 #ifdef TFM_PSA_API
1450  size_t in_len = ARRAY_SIZE(in_vec);
1451  if (salt == NULL) {
1452  in_len--;
1453  }
1454  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1455  out_vec, ARRAY_SIZE(out_vec));
1456 #else
1458  TFM_CRYPTO_ASYMMETRIC_ENCRYPT);
1459 #endif
1460 
1461  *output_length = out_vec[0].len;
1462 
1463 #ifdef TFM_PSA_API
1464  PSA_CLOSE();
1465 #endif
1466 
1467  return status;
1468 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1469 }
1470 
1471 __attribute__((section("SFN")))
1473  psa_algorithm_t alg,
1474  const uint8_t *input,
1475  size_t input_length,
1476  const uint8_t *salt,
1477  size_t salt_length,
1478  uint8_t *output,
1479  size_t output_size,
1480  size_t *output_length)
1481 {
1482 #ifdef TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED
1483  return PSA_ERROR_NOT_SUPPORTED;
1484 #else
1485  psa_status_t status;
1486  struct tfm_crypto_pack_iovec iov = {
1488  .key_handle = handle,
1489  .alg = alg
1490  };
1491 
1492  /* Sanitize the optional input */
1493  if ((salt == NULL) && (salt_length != 0)) {
1495  }
1496 
1497  psa_invec in_vec[] = {
1498  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1499  {.base = input, .len = input_length},
1500  {.base = salt, .len = salt_length}
1501  };
1502 
1503  psa_outvec out_vec[] = {
1504  {.base = output, .len = output_size},
1505  };
1506 
1507 #ifdef TFM_PSA_API
1508  PSA_CONNECT(TFM_CRYPTO);
1509 #endif
1510 
1511 #ifdef TFM_PSA_API
1512  size_t in_len = ARRAY_SIZE(in_vec);
1513  if (salt == NULL) {
1514  in_len--;
1515  }
1516  status = psa_call(ipc_handle, PSA_IPC_CALL, in_vec, in_len,
1517  out_vec, ARRAY_SIZE(out_vec));
1518 #else
1520  TFM_CRYPTO_ASYMMETRIC_DECRYPT);
1521 #endif
1522 
1523  *output_length = out_vec[0].len;
1524 
1525 #ifdef TFM_PSA_API
1526  PSA_CLOSE();
1527 #endif
1528 
1529  return status;
1530 #endif /* TFM_CRYPTO_ASYMMETRIC_MODULE_DISABLED */
1531 }
1532 
1533 __attribute__((section("SFN")))
1535  const psa_key_derivation_operation_t *operation,
1536  size_t *capacity)
1537 {
1538 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1539  return PSA_ERROR_NOT_SUPPORTED;
1540 #else
1541  psa_status_t status;
1542  struct tfm_crypto_pack_iovec iov = {
1544  .op_handle = operation->handle,
1545  };
1546 
1547  psa_invec in_vec[] = {
1548  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1549  };
1550 
1551  psa_outvec out_vec[] = {
1552  {.base = capacity, .len = sizeof(size_t)},
1553  };
1554 
1555 #ifdef TFM_PSA_API
1556  PSA_CONNECT(TFM_CRYPTO);
1557 #endif
1558 
1560  TFM_CRYPTO_KEY_DERIVATION_GET_CAPACITY);
1561 #ifdef TFM_PSA_API
1562  PSA_CLOSE();
1563 #endif
1564 
1565  return status;
1566 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1567 }
1568 
1569 __attribute__((section("SFN")))
1571  psa_key_derivation_operation_t *operation,
1572  uint8_t *output,
1573  size_t output_length)
1574 {
1575 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1576  return PSA_ERROR_NOT_SUPPORTED;
1577 #else
1578  psa_status_t status;
1579  struct tfm_crypto_pack_iovec iov = {
1581  .op_handle = operation->handle,
1582  };
1583 
1584  psa_invec in_vec[] = {
1585  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1586  };
1587 
1588  psa_outvec out_vec[] = {
1589  {.base = output, .len = output_length},
1590  };
1591 
1592 #ifdef TFM_PSA_API
1593  PSA_CONNECT(TFM_CRYPTO);
1594 #endif
1595 
1597  TFM_CRYPTO_KEY_DERIVATION_OUTPUT_BYTES);
1598 #ifdef TFM_PSA_API
1599  PSA_CLOSE();
1600 #endif
1601 
1602  return status;
1603 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1604 }
1605 
1606 __attribute__((section("SFN")))
1608  psa_key_derivation_operation_t *operation,
1610  psa_key_handle_t handle)
1611 {
1612 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1613  return PSA_ERROR_NOT_SUPPORTED;
1614 #else
1615  psa_status_t status;
1616  struct tfm_crypto_pack_iovec iov = {
1618  .key_handle = handle,
1619  .step = step,
1620  .op_handle = operation->handle,
1621  };
1622 
1623  psa_invec in_vec[] = {
1624  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1625  };
1626 
1627 #ifdef TFM_PSA_API
1628  PSA_CONNECT(TFM_CRYPTO);
1629 #endif
1630 
1632  TFM_CRYPTO_KEY_DERIVATION_INPUT_KEY);
1633 #ifdef TFM_PSA_API
1634  PSA_CLOSE();
1635 #endif
1636 
1637  return status;
1638 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1639 }
1640 
1641 __attribute__((section("SFN")))
1643 {
1644 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1645  return PSA_ERROR_NOT_SUPPORTED;
1646 #else
1647  psa_status_t status;
1648  struct tfm_crypto_pack_iovec iov = {
1650  .op_handle = operation->handle,
1651  };
1652 
1653  psa_invec in_vec[] = {
1654  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1655  };
1656 
1657  psa_outvec out_vec[] = {
1658  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1659  };
1660 
1661 #ifdef TFM_PSA_API
1662  PSA_CONNECT(TFM_CRYPTO);
1663 #endif
1664 
1666  TFM_CRYPTO_KEY_DERIVATION_ABORT);
1667 #ifdef TFM_PSA_API
1668  PSA_CLOSE();
1669 #endif
1670 
1671  return status;
1672 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1673 }
1674 
1675 __attribute__((section("SFN")))
1677  psa_key_derivation_operation_t *operation,
1679  psa_key_handle_t private_key,
1680  const uint8_t *peer_key,
1681  size_t peer_key_length)
1682 {
1683 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1684  return PSA_ERROR_NOT_SUPPORTED;
1685 #else
1686  psa_status_t status;
1687  struct tfm_crypto_pack_iovec iov = {
1689  .key_handle = private_key,
1690  .step = step,
1691  .op_handle = operation->handle,
1692  };
1693 
1694  psa_invec in_vec[] = {
1695  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1696  {.base = peer_key, .len = peer_key_length},
1697  };
1698 
1699  psa_outvec out_vec[] = {
1700  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1701  };
1702 
1703 #ifdef TFM_PSA_API
1704  PSA_CONNECT(TFM_CRYPTO);
1705 #endif
1706 
1708  TFM_CRYPTO_KEY_DERIVATION_KEY_AGREEMENT);
1709 
1710 #ifdef TFM_PSA_API
1711  PSA_CLOSE();
1712 #endif
1713 
1714  return status;
1715 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1716 }
1717 
1718 __attribute__((section("SFN")))
1720  size_t output_size)
1721 {
1722 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1723  return PSA_ERROR_NOT_SUPPORTED;
1724 #else
1725  psa_status_t status;
1726  struct tfm_crypto_pack_iovec iov = {
1728  };
1729 
1730  psa_invec in_vec[] = {
1731  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1732  };
1733 
1734  psa_outvec out_vec[] = {
1735  {.base = output, .len = output_size},
1736  };
1737 
1738  if (output_size == 0) {
1739  return PSA_SUCCESS;
1740  }
1741 
1742 #ifdef TFM_PSA_API
1743  PSA_CONNECT(TFM_CRYPTO);
1744 #endif
1745 
1747  TFM_CRYPTO_GENERATE_RANDOM);
1748 
1749 #ifdef TFM_PSA_API
1750  PSA_CLOSE();
1751 #endif
1752 
1753  return status;
1754 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1755 }
1756 
1757 __attribute__((section("SFN")))
1759  psa_key_handle_t *handle)
1760 {
1761 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1762  return PSA_ERROR_NOT_SUPPORTED;
1763 #else
1764  psa_status_t status;
1765  struct tfm_crypto_pack_iovec iov = {
1767  };
1768 
1769  psa_invec in_vec[] = {
1770  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1771  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
1772  };
1773 
1774  psa_outvec out_vec[] = {
1775  {.base = handle, .len = sizeof(psa_key_handle_t)},
1776  };
1777 
1778 #ifdef TFM_PSA_API
1779  PSA_CONNECT(TFM_CRYPTO);
1780 #endif
1781 
1783  TFM_CRYPTO_GENERATE_KEY);
1784 #ifdef TFM_PSA_API
1785  PSA_CLOSE();
1786 #endif
1787 
1788  return status;
1789 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1790 }
1791 
1792 __attribute__((section("SFN")))
1794  psa_key_type_t type,
1795  const uint8_t *data,
1796  size_t data_length)
1797 {
1798  psa_status_t status;
1799 
1800  status = PSA_ERROR_NOT_SUPPORTED;
1801 
1802  return status;
1803 }
1804 
1805 __attribute__((section("SFN")))
1807  const psa_key_attributes_t *attributes,
1808  uint8_t *data,
1809  size_t data_size,
1810  size_t *data_length)
1811 {
1812  psa_status_t status;
1813 
1814  status = PSA_ERROR_NOT_SUPPORTED;
1815 
1816  return status;
1817 }
1818 
1819 __attribute__((section("SFN")))
1821  const uint8_t *input,
1822  size_t input_length)
1823 {
1824  psa_status_t status;
1825 
1826  status = PSA_ERROR_NOT_SUPPORTED;
1827 
1828  return status;
1829 }
1830 
1831 __attribute__((section("SFN")))
1833  uint8_t *ciphertext,
1834  size_t ciphertext_size,
1835  size_t *ciphertext_length,
1836  uint8_t *tag,
1837  size_t tag_size,
1838  size_t *tag_length)
1839 {
1840  psa_status_t status;
1841 
1842  status = PSA_ERROR_NOT_SUPPORTED;
1843 
1844  return status;
1845 }
1846 
1847 __attribute__((section("SFN")))
1849  uint8_t *plaintext,
1850  size_t plaintext_size,
1851  size_t *plaintext_length,
1852  const uint8_t *tag,
1853  size_t tag_length)
1854 {
1855  psa_status_t status;
1856 
1857  status = PSA_ERROR_NOT_SUPPORTED;
1858 
1859  return status;
1860 }
1861 
1862 __attribute__((section("SFN")))
1864 {
1865  psa_status_t status;
1866 
1867  status = PSA_ERROR_NOT_SUPPORTED;
1868 
1869  return status;
1870 }
1871 
1872 __attribute__((section("SFN")))
1874  psa_algorithm_t alg,
1875  const uint8_t *input,
1876  size_t input_length,
1877  uint8_t *mac,
1878  size_t mac_size,
1879  size_t *mac_length)
1880 {
1881  psa_status_t status;
1882 
1883  status = PSA_ERROR_NOT_SUPPORTED;
1884 
1885  return status;
1886 }
1887 
1888 __attribute__((section("SFN")))
1890  psa_algorithm_t alg,
1891  const uint8_t *input,
1892  size_t input_length,
1893  const uint8_t *mac,
1894  const size_t mac_length)
1895 {
1896  psa_status_t status;
1897 
1898  status = PSA_ERROR_NOT_SUPPORTED;
1899 
1900  return status;
1901 }
1902 
1903 __attribute__((section("SFN")))
1905  psa_algorithm_t alg,
1906  const uint8_t *input,
1907  size_t input_length,
1908  uint8_t *output,
1909  size_t output_size,
1910  size_t *output_length)
1911 {
1912  psa_status_t status;
1913 
1914  status = PSA_ERROR_NOT_SUPPORTED;
1915 
1916  return status;
1917 }
1918 
1919 __attribute__((section("SFN")))
1921  psa_algorithm_t alg,
1922  const uint8_t *input,
1923  size_t input_length,
1924  uint8_t *output,
1925  size_t output_size,
1926  size_t *output_length)
1927 {
1928  psa_status_t status;
1929 
1930  status = PSA_ERROR_NOT_SUPPORTED;
1931 
1932  return status;
1933 }
1934 
1935 __attribute__((section("SFN")))
1937  psa_key_handle_t private_key,
1938  const uint8_t *peer_key,
1939  size_t peer_key_length,
1940  uint8_t *output,
1941  size_t output_size,
1942  size_t *output_length)
1943 {
1944 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1945  return PSA_ERROR_NOT_SUPPORTED;
1946 #else
1947  psa_status_t status;
1948  struct tfm_crypto_pack_iovec iov = {
1950  .alg = alg,
1951  .key_handle = private_key
1952  };
1953 
1954  psa_invec in_vec[] = {
1955  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1956  {.base = peer_key, .len = peer_key_length},
1957  };
1958 
1959  psa_outvec out_vec[] = {
1960  {.base = output, .len = output_size},
1961  };
1962 
1963 #ifdef TFM_PSA_API
1964  PSA_CONNECT(TFM_CRYPTO);
1965 #endif
1967  TFM_CRYPTO_RAW_KEY_AGREEMENT);
1968 
1969  *output_length = out_vec[0].len;
1970 
1971 #ifdef TFM_PSA_API
1972  PSA_CLOSE();
1973 #endif
1974 
1975  return status;
1976 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
1977 }
1978 
1979 __attribute__((section("SFN")))
1981  psa_algorithm_t alg)
1982 {
1983 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
1984  return PSA_ERROR_NOT_SUPPORTED;
1985 #else
1986  psa_status_t status;
1987  struct tfm_crypto_pack_iovec iov = {
1989  .alg = alg,
1990  .op_handle = operation->handle,
1991  };
1992 
1993  psa_invec in_vec[] = {
1994  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1995  };
1996  psa_outvec out_vec[] = {
1997  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1998  };
1999 
2000 #ifdef TFM_PSA_API
2001  PSA_CONNECT(TFM_CRYPTO);
2002 #endif
2003 
2005  TFM_CRYPTO_KEY_DERIVATION_SETUP);
2006 #ifdef TFM_PSA_API
2007  PSA_CLOSE();
2008 #endif
2009 
2010  return status;
2011 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
2012 }
2013 
2014 __attribute__((section("SFN")))
2016  psa_key_derivation_operation_t *operation,
2017  size_t capacity)
2018 {
2019 #ifdef TFM_CRYPTO_GENERATOR_MODULE_DISABLED
2020  return PSA_ERROR_NOT_SUPPORTED;
2021 #else
2022  psa_status_t status;
2023  struct tfm_crypto_pack_iovec iov = {
2025  .capacity = capacity,
2026  .op_handle = operation->handle,
2027  };
2028 
2029  psa_invec in_vec[] = {
2030  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
2031  };
2032 
2033 #ifdef TFM_PSA_API
2034  PSA_CONNECT(TFM_CRYPTO);
2035 #endif
2036 
2038  TFM_CRYPTO_KEY_DERIVATION_SET_CAPACITY);
2039 #ifdef TFM_PSA_API
2040  PSA_CLOSE();
2041 #endif
2042 
2043  return status;
2044 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
2045 }
2046 
2047 __attribute__((section("SFN")))
2049  psa_key_derivation_operation_t *operation,
2051  const uint8_t *data,
2052  size_t data_length)
2053 {
2054 #if (TFM_CRYPTO_GENERATOR_MODULE_DISABLED != 0)
2055  return PSA_ERROR_NOT_SUPPORTED;
2056 #else
2057  psa_status_t status;
2058  struct tfm_crypto_pack_iovec iov = {
2060  .step = step,
2061  .op_handle = operation->handle,
2062  };
2063 
2064  psa_invec in_vec[] = {
2065  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
2066  {.base = data, .len = data_length},
2067  };
2068 
2069 #ifdef TFM_PSA_API
2070  PSA_CONNECT(TFM_CRYPTO);
2071 #endif
2072 
2074  TFM_CRYPTO_KEY_DERIVATION_INPUT_BYTES);
2075 #ifdef TFM_PSA_API
2076  PSA_CLOSE();
2077 #endif
2078 
2079  return status;
2080 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
2081 }
2082 
2083 __attribute__((section("SFN")))
2085  const psa_key_attributes_t *attributes,
2086  psa_key_derivation_operation_t *operation,
2087  psa_key_handle_t *handle)
2088 {
2089 #if (TFM_CRYPTO_GENERATOR_MODULE_DISABLED != 0)
2090  return PSA_ERROR_NOT_SUPPORTED;
2091 #else
2092  psa_status_t status;
2093  struct tfm_crypto_pack_iovec iov = {
2095  .op_handle = operation->handle,
2096  };
2097 
2098  psa_invec in_vec[] = {
2099  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
2100  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
2101  };
2102 
2103  psa_outvec out_vec[] = {
2104  {.base = handle, .len = sizeof(psa_key_handle_t)}
2105  };
2106 
2107 #ifdef TFM_PSA_API
2108  PSA_CONNECT(TFM_CRYPTO);
2109 #endif
2110 
2112  TFM_CRYPTO_KEY_DERIVATION_OUTPUT_KEY);
2113 #ifdef TFM_PSA_API
2114  PSA_CLOSE();
2115 #endif
2116 
2117  return status;
2118 #endif /* TFM_CRYPTO_GENERATOR_MODULE_DISABLED */
2119 }
2120 
2121 __attribute__((section("SFN")))
2123  psa_key_handle_t handle,
2124  psa_algorithm_t alg)
2125 {
2126  psa_status_t status;
2127 
2128  status = PSA_ERROR_NOT_SUPPORTED;
2129 
2130  return status;
2131 }
2132 
2133 __attribute__((section("SFN")))
2135  psa_key_handle_t handle,
2136  psa_algorithm_t alg)
2137 {
2138  psa_status_t status;
2139 
2140  status = PSA_ERROR_NOT_SUPPORTED;
2141 
2142  return status;
2143 }
2144 
2145 __attribute__((section("SFN")))
2147  uint8_t *nonce,
2148  size_t nonce_size,
2149  size_t *nonce_length)
2150 {
2151  psa_status_t status;
2152 
2153  status = PSA_ERROR_NOT_SUPPORTED;
2154 
2155  return status;
2156 }
2157 
2158 __attribute__((section("SFN")))
2160  const uint8_t *nonce,
2161  size_t nonce_length)
2162 {
2163  psa_status_t status;
2164 
2165  status = PSA_ERROR_NOT_SUPPORTED;
2166 
2167  return status;
2168 }
2169 
2170 __attribute__((section("SFN")))
2172  size_t ad_length,
2173  size_t plaintext_length)
2174 {
2175  psa_status_t status;
2176 
2177  status = PSA_ERROR_NOT_SUPPORTED;
2178 
2179  return status;
2180 }
2181 
2182 __attribute__((section("SFN")))
2184  const uint8_t *input,
2185  size_t input_length,
2186  uint8_t *output,
2187  size_t output_size,
2188  size_t *output_length)
2189 {
2190  psa_status_t status;
2191 
2192  status = PSA_ERROR_NOT_SUPPORTED;
2193 
2194  return status;
2195 }
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)
psa_status_t tfm_crypto_aead_encrypt(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_aead.c:23
#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 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 tfm_crypto_asymmetric_encrypt(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 psa_cipher_generate_iv(psa_cipher_operation_t *operation, unsigned char *iv, size_t iv_size, size_t *iv_length)
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_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)
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)
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_asymmetric_decrypt(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
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_aead_decrypt(psa_invec in_vec[], size_t in_len, psa_outvec out_vec[], size_t out_len)
Definition: crypto_aead.c:68
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_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_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
#define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id)
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_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_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_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_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_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)
#define ARRAY_SIZE(arr)
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_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)
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)
size_t len
Definition: client.h:76
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 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 API_DISPATCH(sfn_name, sfn_id)
#define PSA_ERROR_BAD_STATE
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 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_cipher_set_iv(psa_cipher_operation_t *operation, const unsigned char *iv, size_t iv_length)
psa_status_t psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)
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)