ChibiOS/HAL  7.0.3
hal_crypto_lld.c
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 /**
18  * @file hal_crypto_lld.c
19  * @brief PLATFORM cryptographic subsystem low level driver source.
20  *
21  * @addtogroup CRYPTO
22  * @{
23  */
24 
25 #include "hal.h"
26 
27 #if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Driver local definitions. */
31 /*===========================================================================*/
32 
33 /*===========================================================================*/
34 /* Driver exported variables. */
35 /*===========================================================================*/
36 
37 /** @brief CRY1 driver identifier.*/
38 #if PLATFORM_CRY_USE_CRY1 || defined(__DOXYGEN__)
40 #endif
41 
42 /*===========================================================================*/
43 /* Driver local variables and types. */
44 /*===========================================================================*/
45 
46 /*===========================================================================*/
47 /* Driver local functions. */
48 /*===========================================================================*/
49 
50 /*===========================================================================*/
51 /* Driver interrupt handlers. */
52 /*===========================================================================*/
53 
54 /*===========================================================================*/
55 /* Driver exported functions. */
56 /*===========================================================================*/
57 
58 /**
59  * @brief Low level crypto driver initialization.
60  *
61  * @notapi
62  */
63 void cry_lld_init(void) {
64 
65 }
66 
67 /**
68  * @brief Configures and activates the crypto peripheral.
69  *
70  * @param[in] cryp pointer to the @p CRYDriver object
71  *
72  * @notapi
73  */
74 void cry_lld_start(CRYDriver *cryp) {
75 
76  if (cryp->state == CRY_STOP) {
77 
78  }
79 }
80 
81 /**
82  * @brief Deactivates the crypto peripheral.
83  *
84  * @param[in] cryp pointer to the @p CRYDriver object
85  *
86  * @notapi
87  */
88 void cry_lld_stop(CRYDriver *cryp) {
89 
90  if (cryp->state == CRY_READY) {
91 
92  }
93 }
94 
95 #if (CRY_LLD_SUPPORTS_AES == TRUE) || defined(__DOXYGEN__)
96 /**
97  * @brief Initializes the AES transient key.
98  * @note It is the underlying implementation to decide which key sizes are
99  * allowable.
100  *
101  * @param[in] cryp pointer to the @p CRYDriver object
102  * @param[in] size key size in bytes
103  * @param[in] keyp pointer to the key data
104  * @return The operation status.
105  * @retval CRY_NOERROR if the operation succeeded.
106  * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
107  * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
108  * the specified algorithm.
109  *
110  * @notapi
111  */
113  size_t size,
114  const uint8_t *keyp) {
115 
116  (void)cryp;
117  (void)size;
118  (void)keyp;
119 
120  return CRY_ERR_INV_ALGO;
121 }
122 
123 /**
124  * @brief Encryption of a single block using AES.
125  * @note The implementation of this function must guarantee that it can
126  * be called from any context.
127  *
128  * @param[in] cryp pointer to the @p CRYDriver object
129  * @param[in] key_id the key to be used for the operation, zero is
130  * the transient key, other values are keys stored
131  * in an unspecified way
132  * @param[in] in buffer containing the input plaintext
133  * @param[out] out buffer for the output cyphertext
134  * @return The operation status.
135  * @retval CRY_NOERROR if the operation succeeded.
136  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
137  * device instance.
138  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
139  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
140  * or refers to an empty key slot.
141  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
142  * dependent.
143  *
144  * @notapi
145  */
147  crykey_t key_id,
148  const uint8_t *in,
149  uint8_t *out) {
150 
151  (void)cryp;
152  (void)key_id;
153  (void)in;
154  (void)out;
155 
156  return CRY_ERR_INV_ALGO;
157 }
158 
159 /**
160  * @brief Decryption of a single block using AES.
161  * @note The implementation of this function must guarantee that it can
162  * be called from any context.
163  *
164  * @param[in] cryp pointer to the @p CRYDriver object
165  * @param[in] key_id the key to be used for the operation, zero is
166  * the transient key, other values are keys stored
167  * in an unspecified way
168  * @param[in] in buffer containing the input cyphertext
169  * @param[out] out buffer for the output plaintext
170  * @return The operation status.
171  * @retval CRY_NOERROR if the operation succeeded.
172  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
173  * device instance.
174  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
175  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
176  * or refers to an empty key slot.
177  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
178  * dependent.
179  *
180  * @notapi
181  */
183  crykey_t key_id,
184  const uint8_t *in,
185  uint8_t *out) {
186 
187  (void)cryp;
188  (void)key_id;
189  (void)in;
190  (void)out;
191 
192  return CRY_ERR_INV_ALGO;
193 }
194 #endif
195 
196 #if (CRY_LLD_SUPPORTS_AES_ECB == TRUE) || defined(__DOXYGEN__)
197 /**
198  * @brief Encryption operation using AES-ECB.
199  * @note The function operates on data buffers whose lenght is a multiple
200  * of an AES block, this means that padding must be done by the
201  * caller.
202  *
203  * @param[in] cryp pointer to the @p CRYDriver object
204  * @param[in] key_id the key to be used for the operation, zero is
205  * the transient key, other values are keys stored
206  * in an unspecified way
207  * @param[in] size size of the plaintext buffer, this number must
208  * be a multiple of the selected key size
209  * @param[in] in buffer containing the input plaintext
210  * @param[out] out buffer for the output cyphertext
211  * @return The operation status.
212  * @retval CRY_NOERROR if the operation succeeded.
213  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
214  * device instance.
215  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
216  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
217  * or refers to an empty key slot.
218  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
219  * dependent.
220  *
221  * @notapi
222  */
224  crykey_t key_id,
225  size_t size,
226  const uint8_t *in,
227  uint8_t *out) {
228 
229  (void)cryp;
230  (void)key_id;
231  (void)size;
232  (void)in;
233  (void)out;
234 
235  return CRY_ERR_INV_ALGO;
236 }
237 
238 /**
239  * @brief Decryption operation using AES-ECB.
240  * @note The function operates on data buffers whose lenght is a multiple
241  * of an AES block, this means that padding must be done by the
242  * caller.
243  *
244  * @param[in] cryp pointer to the @p CRYDriver object
245  * @param[in] key_id the key to be used for the operation, zero is
246  * the transient key, other values are keys stored
247  * in an unspecified way
248  * @param[in] size size of the plaintext buffer, this number must
249  * be a multiple of the selected key size
250  * @param[in] in buffer containing the input plaintext
251  * @param[out] out buffer for the output cyphertext
252  * @return The operation status.
253  * @retval CRY_NOERROR if the operation succeeded.
254  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
255  * device instance.
256  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
257  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
258  * or refers to an empty key slot.
259  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
260  * dependent.
261  *
262  * @notapi
263  */
265  crykey_t key_id,
266  size_t size,
267  const uint8_t *in,
268  uint8_t *out) {
269 
270  (void)cryp;
271  (void)key_id;
272  (void)size;
273  (void)in;
274  (void)out;
275 
276  return CRY_ERR_INV_ALGO;
277 }
278 #endif
279 
280 #if (CRY_LLD_SUPPORTS_AES_CBC == TRUE) || defined(__DOXYGEN__)
281 /**
282  * @brief Encryption operation using AES-CBC.
283  * @note The function operates on data buffers whose lenght is a multiple
284  * of an AES block, this means that padding must be done by the
285  * caller.
286  *
287  * @param[in] cryp pointer to the @p CRYDriver object
288  * @param[in] key_id the key to be used for the operation, zero is
289  * the transient key, other values are keys stored
290  * in an unspecified way
291  * @param[in] size size of the plaintext buffer, this number must
292  * be a multiple of the selected key size
293  * @param[in] in buffer containing the input plaintext
294  * @param[out] out buffer for the output cyphertext
295  * @param[in] iv 128 bits initial vector
296  * @return The operation status.
297  * @retval CRY_NOERROR if the operation succeeded.
298  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
299  * device instance.
300  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
301  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
302  * or refers to an empty key slot.
303  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
304  * dependent.
305  *
306  * @notapi
307  */
309  crykey_t key_id,
310  size_t size,
311  const uint8_t *in,
312  uint8_t *out,
313  const uint8_t *iv) {
314 
315  (void)cryp;
316  (void)key_id;
317  (void)size;
318  (void)in;
319  (void)out;
320  (void)iv;
321 
322  return CRY_ERR_INV_ALGO;
323 }
324 
325 /**
326  * @brief Decryption operation using AES-CBC.
327  * @note The function operates on data buffers whose lenght is a multiple
328  * of an AES block, this means that padding must be done by the
329  * caller.
330  *
331  * @param[in] cryp pointer to the @p CRYDriver object
332  * @param[in] key_id the key to be used for the operation, zero is
333  * the transient key, other values are keys stored
334  * in an unspecified way
335  * @param[in] size size of the plaintext buffer, this number must
336  * be a multiple of the selected key size
337  * @param[in] in buffer containing the input plaintext
338  * @param[out] out buffer for the output cyphertext
339  * @param[in] iv 128 bits initial vector
340  * @return The operation status.
341  * @retval CRY_NOERROR if the operation succeeded.
342  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
343  * device instance.
344  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
345  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
346  * or refers to an empty key slot.
347  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
348  * dependent.
349  *
350  * @notapi
351  */
353  crykey_t key_id,
354  size_t size,
355  const uint8_t *in,
356  uint8_t *out,
357  const uint8_t *iv) {
358 
359  (void)cryp;
360  (void)key_id;
361  (void)size;
362  (void)in;
363  (void)out;
364  (void)iv;
365 
366  return CRY_ERR_INV_ALGO;
367 }
368 #endif
369 
370 #if (CRY_LLD_SUPPORTS_AES_CFB == TRUE) || defined(__DOXYGEN__)
371 /**
372  * @brief Encryption operation using AES-CFB.
373  * @note The function operates on data buffers whose lenght is a multiple
374  * of an AES block, this means that padding must be done by the
375  * caller.
376  *
377  * @param[in] cryp pointer to the @p CRYDriver object
378  * @param[in] key_id the key to be used for the operation, zero is
379  * the transient key, other values are keys stored
380  * in an unspecified way
381  * @param[in] size size of the plaintext buffer, this number must
382  * be a multiple of the selected key size
383  * @param[in] in buffer containing the input plaintext
384  * @param[out] out buffer for the output cyphertext
385  * @param[in] iv 128 bits initial vector
386  * @return The operation status.
387  * @retval CRY_NOERROR if the operation succeeded.
388  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
389  * device instance.
390  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
391  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
392  * or refers to an empty key slot.
393  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
394  * dependent.
395  *
396  * @notapi
397  */
399  crykey_t key_id,
400  size_t size,
401  const uint8_t *in,
402  uint8_t *out,
403  const uint8_t *iv) {
404 
405  (void)cryp;
406  (void)key_id;
407  (void)size;
408  (void)in;
409  (void)out;
410  (void)iv;
411 
412  return CRY_ERR_INV_ALGO;
413 }
414 
415 /**
416  * @brief Decryption operation using AES-CFB.
417  * @note The function operates on data buffers whose lenght is a multiple
418  * of an AES block, this means that padding must be done by the
419  * caller.
420  *
421  * @param[in] cryp pointer to the @p CRYDriver object
422  * @param[in] key_id the key to be used for the operation, zero is
423  * the transient key, other values are keys stored
424  * in an unspecified way
425  * @param[in] size size of the plaintext buffer, this number must
426  * be a multiple of the selected key size
427  * @param[in] in buffer containing the input plaintext
428  * @param[out] out buffer for the output cyphertext
429  * @param[in] iv 128 bits initial vector
430  * @return The operation status.
431  * @retval CRY_NOERROR if the operation succeeded.
432  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
433  * device instance.
434  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
435  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
436  * or refers to an empty key slot.
437  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
438  * dependent.
439  *
440  * @notapi
441  */
443  crykey_t key_id,
444  size_t size,
445  const uint8_t *in,
446  uint8_t *out,
447  const uint8_t *iv) {
448 
449  (void)cryp;
450  (void)key_id;
451  (void)size;
452  (void)in;
453  (void)out;
454  (void)iv;
455 
456  return CRY_ERR_INV_ALGO;
457 }
458 #endif
459 
460 #if (CRY_LLD_SUPPORTS_AES_CTR == TRUE) || defined(__DOXYGEN__)
461 /**
462  * @brief Encryption operation using AES-CTR.
463  * @note The function operates on data buffers whose lenght is a multiple
464  * of an AES block, this means that padding must be done by the
465  * caller.
466  *
467  * @param[in] cryp pointer to the @p CRYDriver object
468  * @param[in] key_id the key to be used for the operation, zero is
469  * the transient key, other values are keys stored
470  * in an unspecified way
471  * @param[in] size size of the plaintext buffer, this number must
472  * be a multiple of 16
473  * @param[in] in buffer containing the input plaintext
474  * @param[out] out buffer for the output cyphertext
475  * @param[in] iv 128 bits initial vector + counter, it contains
476  * a 96 bits IV and a 32 bits counter
477  * @return The operation status.
478  * @retval CRY_NOERROR if the operation succeeded.
479  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
480  * device instance.
481  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
482  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
483  * or refers to an empty key slot.
484  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
485  * dependent.
486  *
487  * @notapi
488  */
490  crykey_t key_id,
491  size_t size,
492  const uint8_t *in,
493  uint8_t *out,
494  const uint8_t *iv) {
495 
496  (void)cryp;
497  (void)key_id;
498  (void)size;
499  (void)in;
500  (void)out;
501  (void)iv;
502 
503  return CRY_ERR_INV_ALGO;
504 }
505 
506 /**
507  * @brief Decryption operation using AES-CTR.
508  * @note The function operates on data buffers whose lenght is a multiple
509  * of an AES block, this means that padding must be done by the
510  * caller.
511  *
512  * @param[in] cryp pointer to the @p CRYDriver object
513  * @param[in] key_id the key to be used for the operation, zero is
514  * the transient key, other values are keys stored
515  * in an unspecified way
516  * @param[in] size size of the plaintext buffer, this number must
517  * be a multiple of 16
518  * @param[in] in buffer containing the input cyphertext
519  * @param[out] out buffer for the output plaintext
520  * @param[in] iv 128 bits initial vector + counter, it contains
521  * a 96 bits IV and a 32 bits counter
522  * @return The operation status.
523  * @retval CRY_NOERROR if the operation succeeded.
524  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
525  * device instance.
526  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
527  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
528  * or refers to an empty key slot.
529  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
530  * dependent.
531  *
532  * @notapi
533  */
535  crykey_t key_id,
536  size_t size,
537  const uint8_t *in,
538  uint8_t *out,
539  const uint8_t *iv) {
540 
541  (void)cryp;
542  (void)key_id;
543  (void)size;
544  (void)in;
545  (void)out;
546  (void)iv;
547 
548  return CRY_ERR_INV_ALGO;
549 }
550 #endif
551 
552 #if (CRY_LLD_SUPPORTS_AES_GCM == TRUE) || defined(__DOXYGEN__)
553 /**
554  * @brief Encryption operation using AES-GCM.
555  * @note The function operates on data buffers whose lenght is a multiple
556  * of an AES block, this means that padding must be done by the
557  * caller.
558  *
559  * @param[in] cryp pointer to the @p CRYDriver object
560  * @param[in] key_id the key to be used for the operation, zero is
561  * the transient key, other values are keys stored
562  * in an unspecified way
563  * @param[in] auth_size size of the data buffer to be authenticated
564  * @param[in] auth_in buffer containing the data to be authenticated
565  * @param[in] text_size size of the text buffer, this number must be a
566  * multiple of 16
567  * @param[in] text_in buffer containing the input plaintext
568  * @param[out] text_out buffer for the output cyphertext
569  * @param[in] iv 128 bits input vector
570  * @param[in] tag_size size of the authentication tag, this number
571  * must be between 1 and 16
572  * @param[out] tag_out buffer for the generated authentication tag
573  * @return The operation status.
574  * @retval CRY_NOERROR if the operation succeeded.
575  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
576  * device instance.
577  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
578  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
579  * or refers to an empty key slot.
580  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
581  * dependent.
582  *
583  * @notapi
584  */
586  crykey_t key_id,
587  size_t auth_size,
588  const uint8_t *auth_in,
589  size_t text_size,
590  const uint8_t *text_in,
591  uint8_t *text_out,
592  const uint8_t *iv,
593  size_t tag_size,
594  uint8_t *tag_out) {
595 
596  (void)cryp;
597  (void)key_id;
598  (void)auth_size;
599  (void)auth_in;
600  (void)text_size;
601  (void)text_in;
602  (void)text_out;
603  (void)iv;
604  (void)tag_size;
605  (void)tag_out;
606 
607  return CRY_ERR_INV_ALGO;
608 }
609 
610 /**
611  * @brief Decryption operation using AES-GCM.
612  * @note The function operates on data buffers whose lenght is a multiple
613  * of an AES block, this means that padding must be done by the
614  * caller.
615  *
616  * @param[in] cryp pointer to the @p CRYDriver object
617  * @param[in] key_id the key to be used for the operation, zero is
618  * the transient key, other values are keys stored
619  * in an unspecified way
620  * @param[in] auth_size size of the data buffer to be authenticated
621  * @param[in] auth_in buffer containing the data to be authenticated
622  * @param[in] text_size size of the text buffer, this number must be a
623  * multiple of 16
624  * @param[in] text_in buffer containing the input plaintext
625  * @param[out] text_out buffer for the output cyphertext
626  * @param[in] iv 128 bits input vector
627  * @param[in] tag_size size of the authentication tag, this number
628  * must be between 1 and 16
629  * @param[in] tag_in buffer for the generated authentication tag
630  * @return The operation status.
631  * @retval CRY_NOERROR if the operation succeeded.
632  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
633  * device instance.
634  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
635  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
636  * or refers to an empty key slot.
637  * @retval CRY_ERR_AUTH_FAILED authentication failed
638  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
639  * dependent.
640  *
641  * @notapi
642  */
644  crykey_t key_id,
645  size_t auth_size,
646  const uint8_t *auth_in,
647  size_t text_size,
648  const uint8_t *text_in,
649  uint8_t *text_out,
650  const uint8_t *iv,
651  size_t tag_size,
652  const uint8_t *tag_in) {
653 
654  (void)cryp;
655  (void)key_id;
656  (void)auth_size;
657  (void)auth_in;
658  (void)text_size;
659  (void)text_in;
660  (void)text_out;
661  (void)iv;
662  (void)tag_size;
663  (void)tag_in;
664 
665  return CRY_ERR_INV_ALGO;
666 }
667 #endif
668 
669 #if (CRY_LLD_SUPPORTS_DES == TRUE) || defined(__DOXYGEN__)
670 /**
671  * @brief Initializes the DES transient key.
672  * @note It is the underlying implementation to decide which key sizes are
673  * allowable.
674  *
675  * @param[in] cryp pointer to the @p CRYDriver object
676  * @param[in] size key size in bytes
677  * @param[in] keyp pointer to the key data
678  * @return The operation status.
679  * @retval CRY_NOERROR if the operation succeeded.
680  * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
681  * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
682  * the specified algorithm.
683  *
684  * @notapi
685  */
687  size_t size,
688  const uint8_t *keyp) {
689 
690  (void)cryp;
691  (void)size;
692  (void)keyp;
693 
694  return CRY_ERR_INV_ALGO;
695 }
696 
697 /**
698  * @brief Encryption of a single block using (T)DES.
699  * @note The implementation of this function must guarantee that it can
700  * be called from any context.
701  *
702  * @param[in] cryp pointer to the @p CRYDriver object
703  * @param[in] key_id the key to be used for the operation, zero is
704  * the transient key, other values are keys stored
705  * in an unspecified way
706  * @param[in] in buffer containing the input plaintext
707  * @param[out] out buffer for the output cyphertext
708  * @return The operation status.
709  * @retval CRY_NOERROR if the operation succeeded.
710  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
711  * device instance.
712  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
713  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
714  * or refers to an empty key slot.
715  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
716  * dependent.
717  *
718  * @notapi
719  */
721  crykey_t key_id,
722  const uint8_t *in,
723  uint8_t *out) {
724 
725  (void)cryp;
726  (void)key_id;
727  (void)in;
728  (void)out;
729 
730  return CRY_ERR_INV_ALGO;
731 }
732 
733 /**
734  * @brief Decryption of a single block using (T)DES.
735  * @note The implementation of this function must guarantee that it can
736  * be called from any context.
737  *
738  *
739  * @param[in] cryp pointer to the @p CRYDriver object
740  * @param[in] key_id the key to be used for the operation, zero is
741  * the transient key, other values are keys stored
742  * in an unspecified way
743  * @param[in] in buffer containing the input cyphertext
744  * @param[out] out buffer for the output plaintext
745  * @return The operation status.
746  * @retval CRY_NOERROR if the operation succeeded.
747  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
748  * device instance.
749  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
750  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
751  * or refers to an empty key slot.
752  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
753  * dependent.
754  *
755  * @notapi
756  */
758  crykey_t key_id,
759  const uint8_t *in,
760  uint8_t *out) {
761 
762  (void)cryp;
763  (void)key_id;
764  (void)in;
765  (void)out;
766 
767  return CRY_ERR_INV_ALGO;
768 }
769 #endif
770 
771 #if (CRY_LLD_SUPPORTS_DES_ECB == TRUE) || defined(__DOXYGEN__)
772 /**
773  * @brief Encryption operation using (T)DES-ECB.
774  * @note The function operates on data buffers whose length is a multiple
775  * of an DES block, this means that padding must be done by the
776  * caller.
777  *
778  * @param[in] cryp pointer to the @p CRYDriver object
779  * @param[in] key_id the key to be used for the operation, zero is
780  * the transient key, other values are keys stored
781  * in an unspecified way
782  * @param[in] size size of the plaintext buffer, this number must
783  * be a multiple of 8
784  * @param[in] in buffer containing the input plaintext
785  * @param[out] out buffer for the output cyphertext
786  * @return The operation status.
787  * @retval CRY_NOERROR if the operation succeeded.
788  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
789  * device instance.
790  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
791  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
792  * or refers to an empty key slot.
793  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
794  * dependent.
795  *
796  * @notapi
797  */
799  crykey_t key_id,
800  size_t size,
801  const uint8_t *in,
802  uint8_t *out) {
803 
804  (void)cryp;
805  (void)key_id;
806  (void)size;
807  (void)in;
808  (void)out;
809 
810  return CRY_ERR_INV_ALGO;
811 }
812 
813 /**
814  * @brief Decryption operation using (T)DES-ECB.
815  * @note The function operates on data buffers whose length is a multiple
816  * of an DES block, this means that padding must be done by the
817  * caller.
818  *
819  * @param[in] cryp pointer to the @p CRYDriver object
820  * @param[in] key_id the key to be used for the operation, zero is
821  * the transient key, other values are keys stored
822  * in an unspecified way
823  * @param[in] size size of the plaintext buffer, this number must
824  * be a multiple of 8
825  * @param[in] in buffer containing the input cyphertext
826  * @param[out] out buffer for the output plaintext
827  * @return T he operation status.
828  * @retval CRY_NOERROR if the operation succeeded.
829  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
830  * device instance.
831  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
832  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
833  * or refers to an empty key slot.
834  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
835  * dependent.
836  *
837  * @notapi
838  */
840  crykey_t key_id,
841  size_t size,
842  const uint8_t *in,
843  uint8_t *out) {
844 
845  (void)cryp;
846  (void)key_id;
847  (void)size;
848  (void)in;
849  (void)out;
850 
851  return CRY_ERR_INV_ALGO;
852 }
853 #endif
854 
855 #if (CRY_LLD_SUPPORTS_DES_CBC == TRUE) || defined(__DOXYGEN__)
856 /**
857  * @brief Encryption operation using (T)DES-CBC.
858  * @note The function operates on data buffers whose length is a multiple
859  * of an DES block, this means that padding must be done by the
860  * caller.
861  *
862  * @param[in] cryp pointer to the @p CRYDriver object
863  * @param[in] key_id the key to be used for the operation, zero is
864  * the transient key, other values are keys stored
865  * in an unspecified way
866  * @param[in] size size of the plaintext buffer, this number must
867  * be a multiple of 8
868  * @param[in] in buffer containing the input plaintext
869  * @param[out] out buffer for the output cyphertext
870  * @param[in] iv 64 bits input vector
871  * @return The operation status.
872  * @retval CRY_NOERROR if the operation succeeded.
873  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
874  * device instance.
875  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
876  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
877  * or refers to an empty key slot.
878  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
879  * dependent.
880  *
881  * @notapi
882  */
884  crykey_t key_id,
885  size_t size,
886  const uint8_t *in,
887  uint8_t *out,
888  const uint8_t *iv) {
889 
890  (void)cryp;
891  (void)key_id;
892  (void)size;
893  (void)in;
894  (void)out;
895  (void)iv;
896 
897  return CRY_ERR_INV_ALGO;
898 }
899 
900 /**
901  * @brief Decryption operation using (T)DES-CBC.
902  * @note The function operates on data buffers whose length is a multiple
903  * of an DES block, this means that padding must be done by the
904  * caller.
905  *
906  * @param[in] cryp pointer to the @p CRYDriver object
907  * @param[in] key_id the key to be used for the operation, zero is
908  * the transient key, other values are keys stored
909  * in an unspecified way
910  * @param[in] size size of the plaintext buffer, this number must
911  * be a multiple of 8
912  * @param[in] in buffer containing the input cyphertext
913  * @param[out] out buffer for the output plaintext
914  * @param[in] iv 64 bits input vector
915  * @return The operation status.
916  * @retval CRY_NOERROR if the operation succeeded.
917  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
918  * device instance.
919  * @retval CRY_ERR_INV_KEY_TYPE the selected key is invalid for this operation.
920  * @retval CRY_ERR_INV_KEY_ID if the specified key identifier is invalid
921  * or refers to an empty key slot.
922  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
923  * dependent.
924  *
925  * @notapi
926  */
928  crykey_t key_id,
929  size_t size,
930  const uint8_t *in,
931  uint8_t *out,
932  const uint8_t *iv) {
933 
934  (void)cryp;
935  (void)key_id;
936  (void)size;
937  (void)in;
938  (void)out;
939  (void)iv;
940 
941  return CRY_ERR_INV_ALGO;
942 }
943 #endif
944 
945 #if (CRY_LLD_SUPPORTS_SHA1 == TRUE) || defined(__DOXYGEN__)
946 /**
947  * @brief Hash initialization using SHA1.
948  * @note Use of this algorithm is not recommended because proven weak.
949  *
950  * @param[in] cryp pointer to the @p CRYDriver object
951  * @param[out] sha1ctxp pointer to a SHA1 context to be initialized
952  * @retval CRY_NOERROR if the operation succeeded.
953  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
954  * device instance.
955  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
956  * dependent.
957  *
958  * @notapi
959  */
961 
962  (void)cryp;
963  (void)sha1ctxp;
964 
965  return CRY_ERR_INV_ALGO;
966 }
967 
968 /**
969  * @brief Hash update using SHA1.
970  * @note Use of this algorithm is not recommended because proven weak.
971  *
972  * @param[in] cryp pointer to the @p CRYDriver object
973  * @param[in] sha1ctxp pointer to a SHA1 context
974  * @param[in] size size of input buffer
975  * @param[in] in buffer containing the input text
976  * @return The operation status.
977  * @retval CRY_NOERROR if the operation succeeded.
978  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
979  * device instance.
980  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
981  * dependent.
982  *
983  * @notapi
984  */
986  size_t size, const uint8_t *in) {
987 
988  (void)cryp;
989  (void)sha1ctxp;
990  (void)size;
991  (void)in;
992 
993  return CRY_ERR_INV_ALGO;
994 }
995 
996 /**
997  * @brief Hash finalization using SHA1.
998  * @note Use of this algorithm is not recommended because proven weak.
999  *
1000  * @param[in] cryp pointer to the @p CRYDriver object
1001  * @param[in] sha1ctxp pointer to a SHA1 context
1002  * @param[out] out 160 bits output buffer
1003  * @return The operation status.
1004  * @retval CRY_NOERROR if the operation succeeded.
1005  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1006  * device instance.
1007  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1008  * dependent.
1009  *
1010  * @notapi
1011  */
1013  uint8_t *out) {
1014 
1015  (void)cryp;
1016  (void)sha1ctxp;
1017  (void)out;
1018 
1019  return CRY_ERR_INV_ALGO;
1020 }
1021 #endif
1022 
1023 #if (CRY_LLD_SUPPORTS_SHA256 == TRUE) || defined(__DOXYGEN__)
1024 /**
1025  * @brief Hash initialization using SHA256.
1026  *
1027  * @param[in] cryp pointer to the @p CRYDriver object
1028  * @param[out] sha256ctxp pointer to a SHA256 context to be initialized
1029  * @retval CRY_NOERROR if the operation succeeded.
1030  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1031  * device instance.
1032  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1033  * dependent.
1034  *
1035  * @notapi
1036  */
1038 
1039  (void)cryp;
1040  (void)sha256ctxp;
1041 
1042  return CRY_ERR_INV_ALGO;
1043 }
1044 
1045 /**
1046  * @brief Hash update using SHA256.
1047  *
1048  * @param[in] cryp pointer to the @p CRYDriver object
1049  * @param[in] sha256ctxp pointer to a SHA256 context
1050  * @param[in] size size of input buffer
1051  * @param[in] in buffer containing the input text
1052  * @return The operation status.
1053  * @retval CRY_NOERROR if the operation succeeded.
1054  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1055  * device instance.
1056  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1057  * dependent.
1058  *
1059  * @notapi
1060  */
1062  size_t size, const uint8_t *in) {
1063 
1064  (void)cryp;
1065  (void)sha256ctxp;
1066  (void)size;
1067  (void)in;
1068 
1069  return CRY_ERR_INV_ALGO;
1070 }
1071 
1072 /**
1073  * @brief Hash finalization using SHA256.
1074  *
1075  * @param[in] cryp pointer to the @p CRYDriver object
1076  * @param[in] sha256ctxp pointer to a SHA256 context
1077  * @param[out] out 256 bits output buffer
1078  * @return The operation status.
1079  * @retval CRY_NOERROR if the operation succeeded.
1080  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1081  * device instance.
1082  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1083  * dependent.
1084  *
1085  * @notapi
1086  */
1088  uint8_t *out) {
1089 
1090  (void)cryp;
1091  (void)sha256ctxp;
1092  (void)out;
1093 
1094  return CRY_ERR_INV_ALGO;
1095 }
1096 #endif
1097 
1098 #if (CRY_LLD_SUPPORTS_SHA512 == TRUE) || defined(__DOXYGEN__)
1099 /**
1100  * @brief Hash initialization using SHA512.
1101  *
1102  * @param[in] cryp pointer to the @p CRYDriver object
1103  * @param[out] sha512ctxp pointer to a SHA512 context to be initialized
1104  * @retval CRY_NOERROR if the operation succeeded.
1105  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1106  * device instance.
1107  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1108  * dependent.
1109  *
1110  * @notapi
1111  */
1113 
1114  (void)cryp;
1115  (void)sha512ctxp;
1116 
1117  return CRY_ERR_INV_ALGO;
1118 }
1119 
1120 /**
1121  * @brief Hash update using SHA512.
1122  *
1123  * @param[in] cryp pointer to the @p CRYDriver object
1124  * @param[in] sha512ctxp pointer to a SHA512 context
1125  * @param[in] size size of input buffer
1126  * @param[in] in buffer containing the input text
1127  * @return The operation status.
1128  * @retval CRY_NOERROR if the operation succeeded.
1129  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1130  * device instance.
1131  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1132  * dependent.
1133  *
1134  * @notapi
1135  */
1137  size_t size, const uint8_t *in) {
1138 
1139  (void)cryp;
1140  (void)sha512ctxp;
1141  (void)size;
1142  (void)in;
1143 
1144  return CRY_ERR_INV_ALGO;
1145 }
1146 
1147 /**
1148  * @brief Hash finalization using SHA512.
1149  *
1150  * @param[in] cryp pointer to the @p CRYDriver object
1151  * @param[in] sha512ctxp pointer to a SHA512 context
1152  * @param[out] out 512 bits output buffer
1153  * @return The operation status.
1154  * @retval CRY_NOERROR if the operation succeeded.
1155  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1156  * device instance.
1157  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1158  * dependent.
1159  *
1160  * @notapi
1161  */
1163  uint8_t *out) {
1164 
1165  (void)cryp;
1166  (void)sha512ctxp;
1167  (void)out;
1168 
1169  return CRY_ERR_INV_ALGO;
1170 }
1171 #endif
1172 
1173 #if (CRY_LLD_SUPPORTS_HMAC_SHA256 == TRUE) || defined(__DOXYGEN__)
1174 /**
1175  * @brief Initializes the HMAC transient key.
1176  * @note It is the underlying implementation to decide which key sizes are
1177  * allowable.
1178  *
1179  * @param[in] cryp pointer to the @p CRYDriver object
1180  * @param[in] size key size in bytes
1181  * @param[in] keyp pointer to the key data
1182  * @return The operation status.
1183  * @retval CRY_NOERROR if the operation succeeded.
1184  * @retval CRY_ERR_INV_ALGO if the algorithm is unsupported.
1185  * @retval CRY_ERR_INV_KEY_SIZE if the specified key size is invalid for
1186  * the specified algorithm.
1187  *
1188  * @notapi
1189  */
1191  size_t size,
1192  const uint8_t *keyp) {
1193 
1194  (void)cryp;
1195  (void)size;
1196  (void)keyp;
1197 
1198  return CRY_ERR_INV_ALGO;
1199 }
1200 
1201 /**
1202  * @brief Hash initialization using HMAC_SHA256.
1203  *
1204  * @param[in] cryp pointer to the @p CRYDriver object
1205  * @param[out] hmacsha256ctxp pointer to a HMAC_SHA256 context to be
1206  * initialized
1207  * @return The operation status.
1208  * @retval CRY_NOERROR if the operation succeeded.
1209  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1210  * device instance.
1211  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1212  * dependent.
1213  *
1214  * @notapi
1215  */
1217  HMACSHA256Context *hmacsha256ctxp) {
1218 
1219  (void)cryp;
1220  (void)hmacsha256ctxp;
1221 
1222  return CRY_ERR_INV_ALGO;
1223 }
1224 
1225 /**
1226  * @brief Hash update using HMAC.
1227  *
1228  * @param[in] cryp pointer to the @p CRYDriver object
1229  * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context
1230  * @param[in] size size of input buffer
1231  * @param[in] in buffer containing the input text
1232  * @return The operation status.
1233  * @retval CRY_NOERROR if the operation succeeded.
1234  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1235  * device instance.
1236  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1237  * dependent.
1238  *
1239  * @notapi
1240  */
1242  HMACSHA256Context *hmacsha256ctxp,
1243  size_t size,
1244  const uint8_t *in) {
1245 
1246  (void)cryp;
1247  (void)hmacsha256ctxp;
1248  (void)size;
1249  (void)in;
1250 
1251  return CRY_ERR_INV_ALGO;
1252 }
1253 
1254 /**
1255  * @brief Hash finalization using HMAC.
1256  *
1257  * @param[in] cryp pointer to the @p CRYDriver object
1258  * @param[in] hmacsha256ctxp pointer to a HMAC_SHA256 context
1259  * @param[out] out 256 bits output buffer
1260  * @return The operation status.
1261  * @retval CRY_NOERROR if the operation succeeded.
1262  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1263  * device instance.
1264  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1265  * dependent.
1266  *
1267  * @notapi
1268  */
1270  HMACSHA256Context *hmacsha256ctxp,
1271  uint8_t *out) {
1272 
1273  (void)cryp;
1274  (void)hmacsha256ctxp;
1275  (void)out;
1276 
1277  return CRY_ERR_INV_ALGO;
1278 }
1279 #endif
1280 
1281 #if (CRY_LLD_SUPPORTS_HMAC_SHA512 == TRUE) || defined(__DOXYGEN__)
1282 /**
1283  * @brief Hash initialization using HMAC_SHA512.
1284  *
1285  * @param[in] cryp pointer to the @p CRYDriver object
1286  * @param[out] hmacsha512ctxp pointer to a HMAC_SHA512 context to be
1287  * initialized
1288  * @return The operation status.
1289  * @retval CRY_NOERROR if the operation succeeded.
1290  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1291  * device instance.
1292  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1293  * dependent.
1294  *
1295  * @notapi
1296  */
1298  HMACSHA512Context *hmacsha512ctxp) {
1299 
1300  (void)cryp;
1301  (void)hmacsha512ctxp;
1302 
1303  return CRY_ERR_INV_ALGO;
1304 }
1305 
1306 /**
1307  * @brief Hash update using HMAC.
1308  *
1309  * @param[in] cryp pointer to the @p CRYDriver object
1310  * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context
1311  * @param[in] size size of input buffer
1312  * @param[in] in buffer containing the input text
1313  * @return The operation status.
1314  * @retval CRY_NOERROR if the operation succeeded.
1315  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1316  * device instance.
1317  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1318  * dependent.
1319  *
1320  * @notapi
1321  */
1323  HMACSHA512Context *hmacsha512ctxp,
1324  size_t size,
1325  const uint8_t *in) {
1326 
1327  (void)cryp;
1328  (void)hmacsha512ctxp;
1329  (void)size;
1330  (void)in;
1331 
1332  return CRY_ERR_INV_ALGO;
1333 }
1334 
1335 /**
1336  * @brief Hash finalization using HMAC.
1337  *
1338  * @param[in] cryp pointer to the @p CRYDriver object
1339  * @param[in] hmacsha512ctxp pointer to a HMAC_SHA512 context
1340  * @param[out] out 512 bits output buffer
1341  * @return The operation status.
1342  * @retval CRY_NOERROR if the operation succeeded.
1343  * @retval CRY_ERR_INV_ALGO if the operation is unsupported on this
1344  * device instance.
1345  * @retval CRY_ERR_OP_FAILURE if the operation failed, implementation
1346  * dependent.
1347  *
1348  * @notapi
1349  */
1351  HMACSHA512Context *hmacsha512ctxp,
1352  uint8_t *out) {
1353 
1354  (void)cryp;
1355  (void)hmacsha512ctxp;
1356  (void)out;
1357 
1358  return CRY_ERR_INV_ALGO;
1359 }
1360 #endif
1361 
1362 #endif /* HAL_USE_CRY == TRUE */
1363 
1364 /** @} */
cryerror_t cry_lld_SHA1_init(CRYDriver *cryp, SHA1Context *sha1ctxp)
Hash initialization using SHA1.
cryerror_t cry_lld_encrypt_AES_GCM(CRYDriver *cryp, crykey_t key_id, size_t auth_size, const uint8_t *auth_in, size_t text_size, const uint8_t *text_in, uint8_t *text_out, const uint8_t *iv, size_t tag_size, uint8_t *tag_out)
Encryption operation using AES-GCM.
cryerror_t cry_lld_decrypt_AES_CFB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using AES-CFB.
cryerror_t cry_lld_encrypt_AES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using AES-CBC.
cryerror_t cry_lld_SHA1_final(CRYDriver *cryp, SHA1Context *sha1ctxp, uint8_t *out)
Hash finalization using SHA1.
cryerror_t cry_lld_SHA1_update(CRYDriver *cryp, SHA1Context *sha1ctxp, size_t size, const uint8_t *in)
Hash update using SHA1.
Type of a SHA512 context.
Definition: hal_crypto.h:187
cryerror_t cry_lld_decrypt_DES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Decryption operation using (T)DES-ECB.
cryerror_t cry_lld_HMACSHA256_init(CRYDriver *cryp, HMACSHA256Context *hmacsha256ctxp)
Hash initialization using HMAC_SHA256.
Structure representing an CRY driver.
HAL subsystem header.
cryerror_t cry_lld_des_loadkey(CRYDriver *cryp, size_t size, const uint8_t *keyp)
Initializes the DES transient key.
cryerror_t cry_lld_encrypt_DES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using (T)DES-CBC.
void cry_lld_stop(CRYDriver *cryp)
Deactivates the crypto peripheral.
cryerror_t cry_lld_encrypt_AES_CFB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using AES-CFB.
cryerror_t
Driver error codes.
Definition: hal_crypto.h:89
cryerror_t cry_lld_decrypt_AES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Decryption operation using AES-ECB.
cryerror_t cry_lld_HMACSHA512_update(CRYDriver *cryp, HMACSHA512Context *hmacsha512ctxp, size_t size, const uint8_t *in)
Hash update using HMAC.
Type of a HMAC_SHA512 context.
Definition: hal_crypto.h:203
Type of a HMAC_SHA256 context.
Definition: hal_crypto.h:195
cryerror_t cry_lld_decrypt_AES_GCM(CRYDriver *cryp, crykey_t key_id, size_t auth_size, const uint8_t *auth_in, size_t text_size, const uint8_t *text_in, uint8_t *text_out, const uint8_t *iv, size_t tag_size, const uint8_t *tag_in)
Decryption operation using AES-GCM.
void cry_lld_start(CRYDriver *cryp)
Configures and activates the crypto peripheral.
uint32_t crykey_t
CRY key identifier type.
cryerror_t cry_lld_decrypt_AES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Decryption of a single block using AES.
cryerror_t cry_lld_SHA512_init(CRYDriver *cryp, SHA512Context *sha512ctxp)
Hash initialization using SHA512.
void cry_lld_init(void)
Low level crypto driver initialization.
cryerror_t cry_lld_SHA512_final(CRYDriver *cryp, SHA512Context *sha512ctxp, uint8_t *out)
Hash finalization using SHA512.
cryerror_t cry_lld_decrypt_AES_CTR(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using AES-CTR.
cryerror_t cry_lld_HMACSHA256_final(CRYDriver *cryp, HMACSHA256Context *hmacsha256ctxp, uint8_t *out)
Hash finalization using HMAC.
cryerror_t cry_lld_HMACSHA256_update(CRYDriver *cryp, HMACSHA256Context *hmacsha256ctxp, size_t size, const uint8_t *in)
Hash update using HMAC.
cryerror_t cry_lld_hmac_loadkey(CRYDriver *cryp, size_t size, const uint8_t *keyp)
Initializes the HMAC transient key.
cryerror_t cry_lld_encrypt_AES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Encryption operation using AES-ECB.
CRYDriver CRYD1
CRY1 driver identifier.
cryerror_t cry_lld_decrypt_DES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using (T)DES-CBC.
cryerror_t cry_lld_encrypt_DES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Encryption operation using (T)DES-ECB.
cryerror_t cry_lld_decrypt_DES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Decryption of a single block using (T)DES.
cryerror_t cry_lld_HMACSHA512_final(CRYDriver *cryp, HMACSHA512Context *hmacsha512ctxp, uint8_t *out)
Hash finalization using HMAC.
cryerror_t cry_lld_encrypt_AES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Encryption of a single block using AES.
cryerror_t cry_lld_SHA512_update(CRYDriver *cryp, SHA512Context *sha512ctxp, size_t size, const uint8_t *in)
Hash update using SHA512.
USBInEndpointState in
IN EP0 state.
Definition: hal_usb_lld.c:57
cryerror_t cry_lld_SHA256_init(CRYDriver *cryp, SHA256Context *sha256ctxp)
Hash initialization using SHA256.
cryerror_t cry_lld_decrypt_AES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using AES-CBC.
crystate_t state
Driver state.
Type of a SHA1 context.
Definition: hal_crypto.h:171
USBOutEndpointState out
OUT EP0 state.
Definition: hal_usb_lld.c:61
cryerror_t cry_lld_encrypt_DES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Encryption of a single block using (T)DES.
cryerror_t cry_lld_HMACSHA512_init(CRYDriver *cryp, HMACSHA512Context *hmacsha512ctxp)
Hash initialization using HMAC_SHA512.
cryerror_t cry_lld_SHA256_update(CRYDriver *cryp, SHA256Context *sha256ctxp, size_t size, const uint8_t *in)
Hash update using SHA256.
Type of a SHA256 context.
Definition: hal_crypto.h:179
cryerror_t cry_lld_SHA256_final(CRYDriver *cryp, SHA256Context *sha256ctxp, uint8_t *out)
Hash finalization using SHA256.
cryerror_t cry_lld_encrypt_AES_CTR(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using AES-CTR.
cryerror_t cry_lld_aes_loadkey(CRYDriver *cryp, size_t size, const uint8_t *keyp)
Initializes the AES transient key.