mbed TLS v2.2.0
aes_alt.h
Go to the documentation of this file.
1 
21 #ifndef MBEDTLS_AES_ALT_H
22 #define MBEDTLS_AES_ALT_H
23 
24 #if !defined(MBEDTLS_CONFIG_FILE)
25 #include "config.h"
26 #else
27 #include MBEDTLS_CONFIG_FILE
28 #endif
29 
30 /***************************************************************************/
35 /***************************************************************************/
41 #if defined( MBEDTLS_SLCL_PLUGINS )
42 #include "aesdrv.h"
43 #include "sl_crypto.h"
44 #endif
45 
46 #include <stddef.h>
47 #include <stdint.h>
48 
49 #define MBEDTLS_AES_ENCRYPT 1
50 #define MBEDTLS_AES_DECRYPT 0
51 
52 /* Silicon Labs specific error codes: */
53 #define MBEDTLS_ERR_AES_NOT_SUPPORTED ((int)MBEDTLS_ECODE_AESDRV_NOT_SUPPORTED)
54 #define MBEDTLS_ERR_AES_AUTHENTICATION_FAILED ((int)MBEDTLS_ECODE_AESDRV_AUTHENTICATION_FAILED)
55 #define MBEDTLS_ERR_AES_OUT_OF_RESOURCES ((int)MBEDTLS_ECODE_AESDRV_OUT_OF_RESOURCES)
56 #define MBEDTLS_ERR_AES_INVALID_PARAM ((int)MBEDTLS_ECODE_AESDRV_INVALID_PARAM)
57 
58 #if defined(MBEDTLS_AES_ALT)
59 /* SiliconLabs CRYPTO hardware acceleration implementation */
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
68 typedef struct
69 {
70 #if defined( MBEDTLS_SLCL_PLUGINS )
71  AESDRV_Context_t aesdrv_ctx;
72  mbedtls_device_io_mode io_mode;
73  mbedtls_device_io_mode_specific io_mode_specific;
75 #endif
76  unsigned int keybits;
77  uint32_t key[8];
78 }
80 
87 
94 
95 #if defined( MBEDTLS_SLCL_PLUGINS )
96 
114 int mbedtls_aes_set_device_instance(mbedtls_aes_context *ctx,
115  unsigned int devno);
116 
134 int mbedtls_aes_set_device_lock_wait_ticks(mbedtls_aes_context *ctx,
135  int ticks);
136 
162 int mbedtls_aes_set_device_io_mode( mbedtls_aes_context *ctx,
165 
166 #endif
167 
177 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
178  unsigned int keybits );
179 
189 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
190  unsigned int keybits );
191 
203  int mode,
204  const unsigned char input[16],
205  unsigned char output[16] );
206 
207 #if defined(MBEDTLS_CIPHER_MODE_CBC)
208 
230 int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
231  int mode,
232  size_t length,
233  unsigned char iv[16],
234  const unsigned char *input,
235  unsigned char *output );
236 #endif /* MBEDTLS_CIPHER_MODE_CBC */
237 
238 #if defined(MBEDTLS_CIPHER_MODE_CFB)
239 
264 int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
265  int mode,
266  size_t length,
267  size_t *iv_off,
268  unsigned char iv[16],
269  const unsigned char *input,
270  unsigned char *output );
271 
296 int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
297  int mode,
298  size_t length,
299  unsigned char iv[16],
300  const unsigned char *input,
301  unsigned char *output );
302 #endif /*MBEDTLS_CIPHER_MODE_CFB */
303 
304 #if defined(MBEDTLS_CIPHER_MODE_CTR)
305 
327 int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
328  size_t length,
329  size_t *nc_off,
330  unsigned char nonce_counter[16],
331  unsigned char stream_block[16],
332  const unsigned char *input,
333  unsigned char *output );
334 #endif /* MBEDTLS_CIPHER_MODE_CTR */
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
340 #endif /* MBEDTLS_AES_ALT */
341 
342 #ifdef __cplusplus
343 extern "C" {
344 #endif
345 
351 int mbedtls_aes_self_test( int verbose );
352 
353 #ifdef __cplusplus
354 }
355 #endif
356 
360 #endif /* MBEDTLS_AES_ALT_H */
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
AES-ECB block encryption/decryption.
int mbedtls_aes_self_test(int verbose)
Checkup routine.
Compatibility names (set of defines)
Definitions for AES based ciphers with CRYPTO hw acceleration.
void mbedtls_aes_init(mbedtls_aes_context *ctx)
Initialize AES context.
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
AES key schedule (encryption)
void mbedtls_aes_free(mbedtls_aes_context *ctx)
Clear AES context.
unsigned int keybits
Definition: aes_alt.h:76
mbedtls_device_io_mode
Enum defines which data I/O mode to use for moving data to/from the AES/CRYPTO hardware module...
Definition: sl_crypto.h:58
Silicon Labs specific mbedTLS defintitions.
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
AES key schedule (decryption)
AES context structure.
Definition: aes_alt.h:68
Data I/O mode specific configuration structure.
Definition: sl_crypto.h:79