TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_crypto_func_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_veneers.h"
9 #include "tfm_crypto_defs.h"
10 #include "psa/crypto.h"
11 #include "tfm_ns_interface.h"
12 
13 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
14 
15 #define API_DISPATCH(sfn_name, sfn_id) \
16  tfm_ns_interface_dispatch((veneer_fn)tfm_##sfn_name##_veneer,\
17  (uint32_t)in_vec, ARRAY_SIZE(in_vec), \
18  (uint32_t)out_vec, ARRAY_SIZE(out_vec))
19 
20 #define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id) \
21  tfm_ns_interface_dispatch((veneer_fn)tfm_##sfn_name##_veneer,\
22  (uint32_t)in_vec, ARRAY_SIZE(in_vec), \
23  (uint32_t)NULL, 0)
24 
26 {
27  /* Service init is performed during TFM boot up,
28  * so application level initialisation is empty
29  */
30  return PSA_SUCCESS;
31 }
32 
34  psa_key_handle_t *handle)
35 {
36  const struct tfm_crypto_pack_iovec iov = {
38  };
39  psa_invec in_vec[] = {
40  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
41  {.base = &id, .len = sizeof(psa_key_id_t)},
42  };
43  psa_outvec out_vec[] = {
44  {.base = handle, .len = sizeof(psa_key_handle_t)},
45  };
46 
48  TFM_CRYPTO_OPEN_KEY);
49 }
50 
52 {
53  const struct tfm_crypto_pack_iovec iov = {
55  .key_handle = handle,
56  };
57  psa_invec in_vec[] = {
58  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
59  };
60 
62  TFM_CRYPTO_CLOSE_KEY);
63 }
64 
66  const uint8_t *data,
67  size_t data_length,
68  psa_key_handle_t *handle)
69 {
70  psa_status_t status;
71  struct tfm_crypto_pack_iovec iov = {
73  };
74  psa_invec in_vec[] = {
75  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
76  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
77  {.base = data, .len = data_length}
78  };
79  psa_outvec out_vec[] = {
80  {.base = handle, .len = sizeof(psa_key_handle_t)}
81  };
82 
84  TFM_CRYPTO_IMPORT_KEY);
85 
86  return status;
87 }
88 
90 {
91  psa_status_t status;
92  struct tfm_crypto_pack_iovec iov = {
94  .key_handle = handle,
95  };
96  psa_invec in_vec[] = {
97  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
98  };
99 
101  TFM_CRYPTO_DESTROY_KEY);
102 
103  return status;
104 }
105 
107  psa_key_attributes_t *attributes)
108 {
109  psa_status_t status;
110  struct tfm_crypto_pack_iovec iov = {
112  .key_handle = handle,
113  };
114  psa_invec in_vec[] = {
115  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
116  };
117  psa_outvec out_vec[] = {
118  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
119  };
120 
122  TFM_CRYPTO_GET_KEY_ATTRIBUTES);
123  return status;
124 }
125 
127 {
128  struct tfm_crypto_pack_iovec iov = {
130  };
131  psa_invec in_vec[] = {
132  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
133  };
134  psa_outvec out_vec[] = {
135  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
136  };
137 
139  TFM_CRYPTO_RESET_KEY_ATTRIBUTES);
140  return;
141 }
142 
144  uint8_t *data,
145  size_t data_size,
146  size_t *data_length)
147 {
148  psa_status_t status;
149  struct tfm_crypto_pack_iovec iov = {
151  .key_handle = handle,
152  };
153  psa_invec in_vec[] = {
154  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
155  };
156  psa_outvec out_vec[] = {
157  {.base = data, .len = data_size}
158  };
159 
161  TFM_CRYPTO_EXPORT_KEY);
162 
163  *data_length = out_vec[0].len;
164 
165  return status;
166 }
167 
169  uint8_t *data,
170  size_t data_size,
171  size_t *data_length)
172 {
173  psa_status_t status;
174  struct tfm_crypto_pack_iovec iov = {
176  .key_handle = handle,
177  };
178 
179  psa_invec in_vec[] = {
180  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
181  };
182  psa_outvec out_vec[] = {
183  {.base = data, .len = data_size}
184  };
185 
187  TFM_CRYPTO_EXPORT_PUBLIC_KEY);
188 
189  *data_length = out_vec[0].len;
190 
191  return status;
192 }
193 
195  const psa_key_attributes_t *attributes,
196  psa_key_handle_t *target_handle)
197 {
198  psa_status_t status;
199  struct tfm_crypto_pack_iovec iov = {
201  .key_handle = source_handle,
202  };
203 
204  psa_invec in_vec[] = {
205  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
206  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
207  };
208 
209  psa_outvec out_vec[] = {
210  {.base = target_handle, .len = sizeof(psa_key_handle_t)},
211  };
212 
214  TFM_CRYPTO_COPY_KEY);
215 
216  return status;
217 }
218 
220  unsigned char *iv,
221  size_t iv_size,
222  size_t *iv_length)
223 {
224  psa_status_t status;
225  struct tfm_crypto_pack_iovec iov = {
227  .op_handle = operation->handle,
228  };
229 
230  psa_invec in_vec[] = {
231  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
232  };
233  psa_outvec out_vec[] = {
234  {.base = &(operation->handle), .len = sizeof(uint32_t)},
235  {.base = iv, .len = iv_size},
236  };
237 
239  TFM_CRYPTO_CIPHER_GENERATE_IV);
240 
241  *iv_length = out_vec[1].len;
242 
243  return status;
244 }
245 
247  const unsigned char *iv,
248  size_t iv_length)
249 {
250  psa_status_t status;
251  struct tfm_crypto_pack_iovec iov = {
253  .op_handle = operation->handle,
254  };
255 
256  psa_invec in_vec[] = {
257  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
258  {.base = iv, .len = iv_length},
259  };
260  psa_outvec out_vec[] = {
261  {.base = &(operation->handle), .len = sizeof(uint32_t)},
262  };
263 
265  TFM_CRYPTO_CIPHER_SET_IV);
266 
267  return status;
268 }
269 
271  psa_key_handle_t handle,
273 {
274  psa_status_t status;
275  struct tfm_crypto_pack_iovec iov = {
277  .key_handle = handle,
278  .alg = alg,
279  .op_handle = operation->handle,
280  };
281 
282  psa_invec in_vec[] = {
283  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
284  };
285  psa_outvec out_vec[] = {
286  {.base = &(operation->handle), .len = sizeof(uint32_t)},
287  };
288 
290  TFM_CRYPTO_CIPHER_ENCRYPT_SETUP);
291 
292  return status;
293 }
294 
296  psa_key_handle_t handle,
297  psa_algorithm_t alg)
298 {
299  psa_status_t status;
300  struct tfm_crypto_pack_iovec iov = {
302  .key_handle = handle,
303  .alg = alg,
304  .op_handle = operation->handle,
305  };
306 
307  psa_invec in_vec[] = {
308  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
309  };
310  psa_outvec out_vec[] = {
311  {.base = &(operation->handle), .len = sizeof(uint32_t)},
312  };
313 
315  TFM_CRYPTO_CIPHER_DECRYPT_SETUP);
316 
317  return status;
318 }
319 
321  const uint8_t *input,
322  size_t input_length,
323  unsigned char *output,
324  size_t output_size,
325  size_t *output_length)
326 {
327  psa_status_t status;
328  struct tfm_crypto_pack_iovec iov = {
330  .op_handle = operation->handle,
331  };
332 
333  psa_invec in_vec[] = {
334  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
335  {.base = input, .len = input_length},
336  };
337  psa_outvec out_vec[] = {
338  {.base = &(operation->handle), .len = sizeof(uint32_t)},
339  {.base = output, .len = output_size}
340  };
341 
343  TFM_CRYPTO_CIPHER_UPDATE);
344 
345  *output_length = out_vec[1].len;
346 
347  return status;
348 }
349 
351 {
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  };
361  psa_outvec out_vec[] = {
362  {.base = &(operation->handle), .len = sizeof(uint32_t)},
363  };
364 
366  TFM_CRYPTO_CIPHER_ABORT);
367 
368  return status;
369 }
370 
372  uint8_t *output,
373  size_t output_size,
374  size_t *output_length)
375 {
376  psa_status_t status;
377  struct tfm_crypto_pack_iovec iov = {
379  .op_handle = operation->handle,
380  };
381 
382  psa_invec in_vec[] = {
383  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
384  };
385  psa_outvec out_vec[] = {
386  {.base = &(operation->handle), .len = sizeof(uint32_t)},
387  {.base = output, .len = output_size},
388  };
389 
391  TFM_CRYPTO_CIPHER_FINISH);
392 
393  *output_length = out_vec[1].len;
394 
395  return status;
396 }
397 
399  psa_algorithm_t alg)
400 {
401  psa_status_t status;
402  struct tfm_crypto_pack_iovec iov = {
404  .alg = alg,
405  .op_handle = operation->handle,
406  };
407 
408  psa_invec in_vec[] = {
409  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
410  };
411  psa_outvec out_vec[] = {
412  {.base = &(operation->handle), .len = sizeof(uint32_t)},
413  };
414 
416  TFM_CRYPTO_HASH_SETUP);
417 
418  return status;
419 }
420 
422  const uint8_t *input,
423  size_t input_length)
424 {
425  psa_status_t status;
426  struct tfm_crypto_pack_iovec iov = {
428  .op_handle = operation->handle,
429  };
430 
431  psa_invec in_vec[] = {
432  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
433  {.base = input, .len = input_length},
434  };
435  psa_outvec out_vec[] = {
436  {.base = &(operation->handle), .len = sizeof(uint32_t)},
437  };
438 
440  TFM_CRYPTO_HASH_UPDATE);
441 
442  return status;
443 }
444 
446  uint8_t *hash,
447  size_t hash_size,
448  size_t *hash_length)
449 {
450  psa_status_t status;
451  struct tfm_crypto_pack_iovec iov = {
453  .op_handle = operation->handle,
454  };
455 
456  psa_invec in_vec[] = {
457  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
458  };
459  psa_outvec out_vec[] = {
460  {.base = &(operation->handle), .len = sizeof(uint32_t)},
461  {.base = hash, .len = hash_size},
462  };
463 
465  TFM_CRYPTO_HASH_FINISH);
466 
467  *hash_length = out_vec[1].len;
468 
469  return status;
470 }
471 
473  const uint8_t *hash,
474  size_t hash_length)
475 {
476  psa_status_t status;
477  struct tfm_crypto_pack_iovec iov = {
479  .op_handle = operation->handle,
480  };
481 
482  psa_invec in_vec[] = {
483  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
484  {.base = hash, .len = hash_length},
485  };
486  psa_outvec out_vec[] = {
487  {.base = &(operation->handle), .len = sizeof(uint32_t)},
488  };
489 
491  TFM_CRYPTO_HASH_VERIFY);
492 
493  return status;
494 }
495 
497 {
498  psa_status_t status;
499  struct tfm_crypto_pack_iovec iov = {
501  .op_handle = operation->handle,
502  };
503 
504  psa_invec in_vec[] = {
505  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
506  };
507  psa_outvec out_vec[] = {
508  {.base = &(operation->handle), .len = sizeof(uint32_t)},
509  };
510 
512  TFM_CRYPTO_HASH_ABORT);
513 
514  return status;
515 }
516 
518  psa_hash_operation_t *target_operation)
519 {
520  psa_status_t status;
521  struct tfm_crypto_pack_iovec iov = {
523  .op_handle = source_operation->handle,
524  };
525 
526  psa_invec in_vec[] = {
527  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
528  };
529  psa_outvec out_vec[] = {
530  {.base = target_operation, .len = sizeof(psa_hash_operation_t)},
531  };
532 
533  if (target_operation && (target_operation->handle != 0)) {
534  return PSA_ERROR_BAD_STATE;
535  }
536 
538  TFM_CRYPTO_HASH_CLONE);
539 
540  return status;
541 }
542 
544  const uint8_t *input,
545  size_t input_length,
546  uint8_t *hash,
547  size_t hash_size,
548  size_t *hash_length)
549 {
550  psa_status_t status;
551  struct tfm_crypto_pack_iovec iov = {
553  .alg = alg,
554  };
555 
556  psa_invec in_vec[] = {
557  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
558  {.base = input, .len = input_length},
559  };
560 
561  psa_outvec out_vec[] = {
562  {.base = hash, .len = hash_size}
563  };
564 
566  TFM_CRYPTO_HASH_COMPUTE);
567 
568  *hash_length = out_vec[0].len;
569 
570  return status;
571 }
572 
574  const uint8_t *input,
575  size_t input_length,
576  const uint8_t *hash,
577  size_t hash_length)
578 {
579  psa_status_t status;
580  struct tfm_crypto_pack_iovec iov = {
582  .alg = alg,
583  };
584 
585  psa_invec in_vec[] = {
586  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
587  {.base = input, .len = input_length},
588  {.base = hash, .len = hash_length},
589  };
590 
592  TFM_CRYPTO_HASH_COMPARE);
593 
594  return status;
595 }
596 
598  psa_key_handle_t handle,
599  psa_algorithm_t alg)
600 {
601  psa_status_t status;
602  struct tfm_crypto_pack_iovec iov = {
604  .key_handle = handle,
605  .alg = alg,
606  .op_handle = operation->handle,
607  };
608 
609  psa_invec in_vec[] = {
610  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
611  };
612  psa_outvec out_vec[] = {
613  {.base = &(operation->handle), .len = sizeof(uint32_t)},
614  };
615 
617  TFM_CRYPTO_MAC_SIGN_SETUP);
618 
619  return status;
620 }
621 
623  psa_key_handle_t handle,
624  psa_algorithm_t alg)
625 {
626  psa_status_t status;
627  struct tfm_crypto_pack_iovec iov = {
629  .key_handle = handle,
630  .alg = alg,
631  .op_handle = operation->handle,
632  };
633 
634  psa_invec in_vec[] = {
635  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
636  };
637  psa_outvec out_vec[] = {
638  {.base = &(operation->handle), .len = sizeof(uint32_t)},
639  };
640 
642  TFM_CRYPTO_MAC_VERIFY_SETUP);
643 
644  return status;
645 }
646 
648  const uint8_t *input,
649  size_t input_length)
650 {
651  psa_status_t status;
652  struct tfm_crypto_pack_iovec iov = {
654  .op_handle = operation->handle,
655  };
656 
657  psa_invec in_vec[] = {
658  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
659  {.base = input, .len = input_length},
660  };
661  psa_outvec out_vec[] = {
662  {.base = &(operation->handle), .len = sizeof(uint32_t)},
663  };
664 
666  TFM_CRYPTO_MAC_UPDATE);
667 
668  return status;
669 }
670 
672  uint8_t *mac,
673  size_t mac_size,
674  size_t *mac_length)
675 {
676  psa_status_t status;
677  struct tfm_crypto_pack_iovec iov = {
679  .op_handle = operation->handle,
680  };
681 
682  psa_invec in_vec[] = {
683  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
684  };
685  psa_outvec out_vec[] = {
686  {.base = &(operation->handle), .len = sizeof(uint32_t)},
687  {.base = mac, .len = mac_size},
688  };
689 
691  TFM_CRYPTO_MAC_SIGN_FINISH);
692 
693  *mac_length = out_vec[1].len;
694 
695  return status;
696 }
697 
699  const uint8_t *mac,
700  size_t mac_length)
701 {
702  psa_status_t status;
703  struct tfm_crypto_pack_iovec iov = {
705  .op_handle = operation->handle,
706  };
707 
708  psa_invec in_vec[] = {
709  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
710  {.base = mac, .len = mac_length},
711  };
712  psa_outvec out_vec[] = {
713  {.base = &(operation->handle), .len = sizeof(uint32_t)},
714  };
715 
717  TFM_CRYPTO_MAC_VERIFY_FINISH);
718 
719  return status;
720 }
721 
723 {
724  psa_status_t status;
725  struct tfm_crypto_pack_iovec iov = {
727  .op_handle = operation->handle,
728  };
729 
730  psa_invec in_vec[] = {
731  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
732  };
733  psa_outvec out_vec[] = {
734  {.base = &(operation->handle), .len = sizeof(uint32_t)},
735  };
736 
738  TFM_CRYPTO_MAC_ABORT);
739 
740  return status;
741 }
742 
744  psa_algorithm_t alg,
745  const uint8_t *nonce,
746  size_t nonce_length,
747  const uint8_t *additional_data,
748  size_t additional_data_length,
749  const uint8_t *plaintext,
750  size_t plaintext_length,
751  uint8_t *ciphertext,
752  size_t ciphertext_size,
753  size_t *ciphertext_length)
754 {
755  psa_status_t status;
756  struct tfm_crypto_pack_iovec iov = {
758  .key_handle = handle,
759  .alg = alg,
760  .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
761  };
762 
763  /* Sanitize the optional input */
764  if ((additional_data == NULL) && (additional_data_length != 0)) {
766  }
767 
768  size_t idx = 0;
769  psa_invec in_vec[] = {
770  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
771  {.base = plaintext, .len = plaintext_length},
772  {.base = additional_data, .len = additional_data_length},
773  };
774  psa_outvec out_vec[] = {
775  {.base = ciphertext, .len = ciphertext_size},
776  };
777 
778  if (nonce_length > TFM_CRYPTO_MAX_NONCE_LENGTH) {
780  }
781 
782  if (nonce != NULL) {
783  for (idx = 0; idx < nonce_length; idx++) {
784  iov.aead_in.nonce[idx] = nonce[idx];
785  }
786  }
787 
789  TFM_CRYPTO_AEAD_ENCRYPT);
790 
791  *ciphertext_length = out_vec[0].len;
792 
793  return status;
794 }
795 
797  psa_algorithm_t alg,
798  const uint8_t *nonce,
799  size_t nonce_length,
800  const uint8_t *additional_data,
801  size_t additional_data_length,
802  const uint8_t *ciphertext,
803  size_t ciphertext_length,
804  uint8_t *plaintext,
805  size_t plaintext_size,
806  size_t *plaintext_length)
807 {
808  psa_status_t status;
809  struct tfm_crypto_pack_iovec iov = {
811  .key_handle = handle,
812  .alg = alg,
813  .aead_in = {.nonce = {0}, .nonce_length = nonce_length}
814  };
815 
816  /* Sanitize the optional input */
817  if ((additional_data == NULL) && (additional_data_length != 0)) {
819  }
820 
821  size_t idx = 0;
822  psa_invec in_vec[] = {
823  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
824  {.base = ciphertext, .len = ciphertext_length},
825  {.base = additional_data, .len = additional_data_length},
826  };
827  psa_outvec out_vec[] = {
828  {.base = plaintext, .len = plaintext_size},
829  };
830 
831  if (nonce_length > TFM_CRYPTO_MAX_NONCE_LENGTH) {
833  }
834 
835  if (nonce != NULL) {
836  for (idx = 0; idx < nonce_length; idx++) {
837  iov.aead_in.nonce[idx] = nonce[idx];
838  }
839  }
840 
842  TFM_CRYPTO_AEAD_DECRYPT);
843 
844  *plaintext_length = out_vec[0].len;
845 
846  return status;
847 }
848 
850  psa_algorithm_t alg,
851  const uint8_t *hash,
852  size_t hash_length,
853  uint8_t *signature,
854  size_t signature_size,
855  size_t *signature_length)
856 {
857  return psa_sign_hash(handle, alg, hash, hash_length, signature,
858  signature_size, signature_length);
859 }
860 
862  psa_algorithm_t alg,
863  const uint8_t *hash,
864  size_t hash_length,
865  uint8_t *signature,
866  size_t signature_size,
867  size_t *signature_length)
868 {
869  psa_status_t status;
870  struct tfm_crypto_pack_iovec iov = {
872  .key_handle = handle,
873  .alg = alg,
874  };
875 
876  psa_invec in_vec[] = {
877  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
878  {.base = hash, .len = hash_length},
879  };
880  psa_outvec out_vec[] = {
881  {.base = signature, .len = signature_size},
882  };
883 
885  TFM_CRYPTO_SIGN_HASH);
886 
887  *signature_length = out_vec[0].len;
888 
889  return status;
890 }
891 
893  psa_algorithm_t alg,
894  const uint8_t *hash,
895  size_t hash_length,
896  const uint8_t *signature,
897  size_t signature_length)
898 {
899  return psa_verify_hash(handle, alg, hash, hash_length,
900  signature, signature_length);
901 }
902 
904  psa_algorithm_t alg,
905  const uint8_t *hash,
906  size_t hash_length,
907  const uint8_t *signature,
908  size_t signature_length)
909 {
910  psa_status_t status;
911  struct tfm_crypto_pack_iovec iov = {
913  .key_handle = handle,
914  .alg = alg
915  };
916 
917  psa_invec in_vec[] = {
918  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
919  {.base = hash, .len = hash_length},
920  {.base = signature, .len = signature_length}
921  };
922 
924  TFM_CRYPTO_VERIFY_HASH);
925 
926  return status;
927 }
928 
930  psa_algorithm_t alg,
931  const uint8_t *input,
932  size_t input_length,
933  const uint8_t *salt,
934  size_t salt_length,
935  uint8_t *output,
936  size_t output_size,
937  size_t *output_length)
938 {
939  psa_status_t status;
940  struct tfm_crypto_pack_iovec iov = {
942  .key_handle = handle,
943  .alg = alg
944  };
945 
946  /* Sanitize the optional input */
947  if ((salt == NULL) && (salt_length != 0)) {
949  }
950 
951  psa_invec in_vec[] = {
952  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
953  {.base = input, .len = input_length},
954  {.base = salt, .len = salt_length}
955  };
956 
957  psa_outvec out_vec[] = {
958  {.base = output, .len = output_size},
959  };
960 
962  TFM_CRYPTO_ASYMMETRIC_ENCRYPT);
963 
964  *output_length = out_vec[0].len;
965 
966  return status;
967 }
968 
970  psa_algorithm_t alg,
971  const uint8_t *input,
972  size_t input_length,
973  const uint8_t *salt,
974  size_t salt_length,
975  uint8_t *output,
976  size_t output_size,
977  size_t *output_length)
978 {
979  psa_status_t status;
980  struct tfm_crypto_pack_iovec iov = {
982  .key_handle = handle,
983  .alg = alg
984  };
985 
986  /* Sanitize the optional input */
987  if ((salt == NULL) && (salt_length != 0)) {
989  }
990 
991  psa_invec in_vec[] = {
992  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
993  {.base = input, .len = input_length},
994  {.base = salt, .len = salt_length}
995  };
996 
997  psa_outvec out_vec[] = {
998  {.base = output, .len = output_size},
999  };
1000 
1002  TFM_CRYPTO_ASYMMETRIC_DECRYPT);
1003 
1004  *output_length = out_vec[0].len;
1005 
1006  return status;
1007 }
1008 
1010  const psa_key_derivation_operation_t *operation,
1011  size_t *capacity)
1012 {
1013  psa_status_t status;
1014  struct tfm_crypto_pack_iovec iov = {
1016  .op_handle = operation->handle,
1017  };
1018 
1019  psa_invec in_vec[] = {
1020  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1021  };
1022 
1023  psa_outvec out_vec[] = {
1024  {.base = capacity, .len = sizeof(size_t)},
1025  };
1026 
1028  TFM_CRYPTO_KEY_DERIVATION_GET_CAPACITY);
1029 
1030  return status;
1031 }
1032 
1034  psa_key_derivation_operation_t *operation,
1035  uint8_t *output,
1036  size_t output_length)
1037 {
1038  psa_status_t status;
1039  struct tfm_crypto_pack_iovec iov = {
1041  .op_handle = operation->handle,
1042  };
1043 
1044  psa_invec in_vec[] = {
1045  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1046  };
1047 
1048  psa_outvec out_vec[] = {
1049  {.base = output, .len = output_length},
1050  };
1051 
1053  TFM_CRYPTO_KEY_DERIVATION_OUTPUT_BYTES);
1054 
1055  return status;
1056 }
1057 
1059  psa_key_derivation_operation_t *operation,
1061  psa_key_handle_t handle)
1062 {
1063  psa_status_t status;
1064  struct tfm_crypto_pack_iovec iov = {
1066  .key_handle = handle,
1067  .step = step,
1068  .op_handle = operation->handle,
1069  };
1070 
1071  psa_invec in_vec[] = {
1072  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1073  };
1074 
1076  TFM_CRYPTO_KEY_DERIVATION_INPUT_KEY);
1077 
1078  return status;
1079 }
1080 
1082 {
1083  psa_status_t status;
1084  struct tfm_crypto_pack_iovec iov = {
1086  .op_handle = operation->handle,
1087  };
1088 
1089  psa_invec in_vec[] = {
1090  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1091  };
1092 
1093  psa_outvec out_vec[] = {
1094  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1095  };
1096 
1098  TFM_CRYPTO_KEY_DERIVATION_ABORT);
1099 
1100  return status;
1101 }
1102 
1104  psa_key_derivation_operation_t *operation,
1106  psa_key_handle_t private_key,
1107  const uint8_t *peer_key,
1108  size_t peer_key_length)
1109 {
1110  psa_status_t status;
1111  struct tfm_crypto_pack_iovec iov = {
1113  .key_handle = private_key,
1114  .step = step,
1115  .op_handle = operation->handle,
1116  };
1117 
1118  psa_invec in_vec[] = {
1119  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1120  {.base = peer_key, .len = peer_key_length},
1121  };
1122 
1124  TFM_CRYPTO_KEY_DERIVATION_KEY_AGREEMENT);
1125 
1126  return status;
1127 }
1128 
1130  size_t output_size)
1131 {
1132  psa_status_t status;
1133  struct tfm_crypto_pack_iovec iov = {
1135  };
1136 
1137  psa_invec in_vec[] = {
1138  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1139  };
1140 
1141  psa_outvec out_vec[] = {
1142  {.base = output, .len = output_size},
1143  };
1144 
1145  if (output_size == 0) {
1146  return PSA_SUCCESS;
1147  }
1148 
1150  TFM_CRYPTO_GENERATE_RANDOM);
1151 
1152  return status;
1153 }
1154 
1156  psa_key_handle_t *handle)
1157 {
1158  psa_status_t status;
1159  struct tfm_crypto_pack_iovec iov = {
1161  };
1162 
1163  psa_invec in_vec[] = {
1164  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1165  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
1166  };
1167 
1168  psa_outvec out_vec[] = {
1169  {.base = handle, .len = sizeof(psa_key_handle_t)},
1170  };
1171 
1173  TFM_CRYPTO_GENERATE_KEY);
1174 
1175  return status;
1176 }
1177 
1179  psa_key_type_t type,
1180  const uint8_t *data,
1181  size_t data_length)
1182 {
1183  psa_status_t status;
1184 
1185  status = PSA_ERROR_NOT_SUPPORTED;
1186 
1187  return status;
1188 }
1189 
1191  const psa_key_attributes_t *attributes,
1192  uint8_t *data,
1193  size_t data_size,
1194  size_t *data_length)
1195 {
1196  psa_status_t status;
1197 
1198  status = PSA_ERROR_NOT_SUPPORTED;
1199 
1200  return status;
1201 }
1202 
1204  const uint8_t *input,
1205  size_t input_length)
1206 {
1207  psa_status_t status;
1208 
1209  status = PSA_ERROR_NOT_SUPPORTED;
1210 
1211  return status;
1212 }
1213 
1215  uint8_t *ciphertext,
1216  size_t ciphertext_size,
1217  size_t *ciphertext_length,
1218  uint8_t *tag,
1219  size_t tag_size,
1220  size_t *tag_length)
1221 {
1222  psa_status_t status;
1223 
1224  status = PSA_ERROR_NOT_SUPPORTED;
1225 
1226  return status;
1227 }
1228 
1230  uint8_t *plaintext,
1231  size_t plaintext_size,
1232  size_t *plaintext_length,
1233  const uint8_t *tag,
1234  size_t tag_length)
1235 {
1236  psa_status_t status;
1237 
1238  status = PSA_ERROR_NOT_SUPPORTED;
1239 
1240  return status;
1241 }
1242 
1244 {
1245  psa_status_t status;
1246 
1247  status = PSA_ERROR_NOT_SUPPORTED;
1248 
1249  return status;
1250 }
1251 
1253  psa_algorithm_t alg,
1254  const uint8_t *input,
1255  size_t input_length,
1256  uint8_t *mac,
1257  size_t mac_size,
1258  size_t *mac_length)
1259 {
1260  psa_status_t status;
1261 
1262  status = PSA_ERROR_NOT_SUPPORTED;
1263 
1264  return status;
1265 }
1266 
1268  psa_algorithm_t alg,
1269  const uint8_t *input,
1270  size_t input_length,
1271  const uint8_t *mac,
1272  const size_t mac_length)
1273 {
1274  psa_status_t status;
1275 
1276  status = PSA_ERROR_NOT_SUPPORTED;
1277 
1278  return status;
1279 }
1280 
1282  psa_algorithm_t alg,
1283  const uint8_t *input,
1284  size_t input_length,
1285  uint8_t *output,
1286  size_t output_size,
1287  size_t *output_length)
1288 {
1289  psa_status_t status;
1290 
1291  status = PSA_ERROR_NOT_SUPPORTED;
1292 
1293  return status;
1294 }
1295 
1297  psa_algorithm_t alg,
1298  const uint8_t *input,
1299  size_t input_length,
1300  uint8_t *output,
1301  size_t output_size,
1302  size_t *output_length)
1303 {
1304  psa_status_t status;
1305 
1306  status = PSA_ERROR_NOT_SUPPORTED;
1307 
1308  return status;
1309 }
1310 
1312  psa_key_handle_t private_key,
1313  const uint8_t *peer_key,
1314  size_t peer_key_length,
1315  uint8_t *output,
1316  size_t output_size,
1317  size_t *output_length)
1318 {
1319  psa_status_t status;
1320  struct tfm_crypto_pack_iovec iov = {
1322  .alg = alg,
1323  .key_handle = private_key
1324  };
1325 
1326  psa_invec in_vec[] = {
1327  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1328  {.base = peer_key, .len = peer_key_length},
1329  };
1330 
1331  psa_outvec out_vec[] = {
1332  {.base = output, .len = output_size},
1333  };
1334 
1336  TFM_CRYPTO_RAW_KEY_AGREEMENT);
1337 
1338  *output_length = out_vec[0].len;
1339 
1340  return status;
1341 }
1342 
1344  psa_algorithm_t alg)
1345 {
1346  psa_status_t status;
1347  struct tfm_crypto_pack_iovec iov = {
1349  .alg = alg,
1350  .op_handle = operation->handle,
1351  };
1352 
1353  psa_invec in_vec[] = {
1354  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1355  };
1356  psa_outvec out_vec[] = {
1357  {.base = &(operation->handle), .len = sizeof(uint32_t)},
1358  };
1359 
1361  TFM_CRYPTO_KEY_DERIVATION_SETUP);
1362  return status;
1363 }
1364 
1366  psa_key_derivation_operation_t *operation,
1367  size_t capacity)
1368 {
1369  psa_status_t status;
1370  struct tfm_crypto_pack_iovec iov = {
1372  .capacity = capacity,
1373  .op_handle = operation->handle,
1374  };
1375 
1376  psa_invec in_vec[] = {
1377  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1378  };
1379 
1381  TFM_CRYPTO_KEY_DERIVATION_SET_CAPACITY);
1382  return status;
1383 }
1384 
1386  psa_key_derivation_operation_t *operation,
1388  const uint8_t *data,
1389  size_t data_length)
1390 {
1391  psa_status_t status;
1392  struct tfm_crypto_pack_iovec iov = {
1394  .step = step,
1395  .op_handle = operation->handle,
1396  };
1397 
1398  psa_invec in_vec[] = {
1399  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1400  {.base = data, .len = data_length},
1401  };
1402 
1404  TFM_CRYPTO_KEY_DERIVATION_INPUT_BYTES);
1405  return status;
1406 }
1407 
1409  const psa_key_attributes_t *attributes,
1410  psa_key_derivation_operation_t *operation,
1411  psa_key_handle_t *handle)
1412 {
1413  psa_status_t status;
1414  struct tfm_crypto_pack_iovec iov = {
1416  .op_handle = operation->handle,
1417  };
1418 
1419  psa_invec in_vec[] = {
1420  {.base = &iov, .len = sizeof(struct tfm_crypto_pack_iovec)},
1421  {.base = attributes, .len = sizeof(psa_key_attributes_t)},
1422  };
1423 
1424  psa_outvec out_vec[] = {
1425  {.base = handle, .len = sizeof(psa_key_handle_t)}
1426  };
1427 
1429  TFM_CRYPTO_KEY_DERIVATION_OUTPUT_KEY);
1430  return status;
1431 }
1432 
1434  psa_key_handle_t handle,
1435  psa_algorithm_t alg)
1436 {
1437  psa_status_t status;
1438 
1439  status = PSA_ERROR_NOT_SUPPORTED;
1440 
1441  return status;
1442 }
1443 
1445  psa_key_handle_t handle,
1446  psa_algorithm_t alg)
1447 {
1448  psa_status_t status;
1449 
1450  status = PSA_ERROR_NOT_SUPPORTED;
1451 
1452  return status;
1453 }
1454 
1456  uint8_t *nonce,
1457  size_t nonce_size,
1458  size_t *nonce_length)
1459 {
1460  psa_status_t status;
1461 
1462  status = PSA_ERROR_NOT_SUPPORTED;
1463 
1464  return status;
1465 }
1466 
1468  const uint8_t *nonce,
1469  size_t nonce_length)
1470 {
1471  psa_status_t status;
1472 
1473  status = PSA_ERROR_NOT_SUPPORTED;
1474 
1475  return status;
1476 }
1477 
1479  size_t ad_length,
1480  size_t plaintext_length)
1481 {
1482  psa_status_t status;
1483 
1484  status = PSA_ERROR_NOT_SUPPORTED;
1485 
1486  return status;
1487 }
1488 
1490  const uint8_t *input,
1491  size_t input_length,
1492  uint8_t *output,
1493  size_t output_size,
1494  size_t *output_length)
1495 {
1496  psa_status_t status;
1497 
1498  status = PSA_ERROR_NOT_SUPPORTED;
1499 
1500  return status;
1501 }
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.
#define API_DISPATCH(sfn_name, sfn_id)
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 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_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_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_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_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 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 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
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 psa_cipher_generate_iv(psa_cipher_operation_t *operation, unsigned char *iv, size_t iv_size, size_t *iv_length)
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_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)
#define API_DISPATCH_NO_OUTVEC(sfn_name, sfn_id)
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_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_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)
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)
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
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_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)
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
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_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_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 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 psa_cipher_set_iv(psa_cipher_operation_t *operation, const unsigned char *iv, size_t iv_length)
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)