aes.h

Go to the documentation of this file.
00001 
00023 #ifndef MBEDTLS_AES_H
00024 #define MBEDTLS_AES_H
00025 
00026 #if !defined(MBEDTLS_CONFIG_FILE)
00027 #include "config.h"
00028 #else
00029 #include MBEDTLS_CONFIG_FILE
00030 #endif
00031 
00032 #include <stddef.h>
00033 #include <stdint.h>
00034 
00035 /* padlock.c and aesni.c rely on these values! */
00036 #define MBEDTLS_AES_ENCRYPT     1
00037 #define MBEDTLS_AES_DECRYPT     0
00038 
00039 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH                -0x0020  
00040 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH              -0x0022  
00042 #if !defined(MBEDTLS_AES_ALT)
00043 // Regular implementation
00044 //
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049 
00058 typedef struct
00059 {
00060     int nr;                     
00061     uint32_t *rk;               
00062     uint32_t buf[68];           
00063 }
00064 mbedtls_aes_context;
00065 
00071 void mbedtls_aes_init( mbedtls_aes_context *ctx );
00072 
00078 void mbedtls_aes_free( mbedtls_aes_context *ctx );
00079 
00089 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
00090                     unsigned int keybits );
00091 
00101 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
00102                     unsigned int keybits );
00103 
00114 int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
00115                     int mode,
00116                     const unsigned char input[16],
00117                     unsigned char output[16] );
00118 
00119 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00120 
00142 int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
00143                     int mode,
00144                     size_t length,
00145                     unsigned char iv[16],
00146                     const unsigned char *input,
00147                     unsigned char *output );
00148 #endif /* MBEDTLS_CIPHER_MODE_CBC */
00149 
00150 #if defined(MBEDTLS_CIPHER_MODE_CFB)
00151 
00176 int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
00177                        int mode,
00178                        size_t length,
00179                        size_t *iv_off,
00180                        unsigned char iv[16],
00181                        const unsigned char *input,
00182                        unsigned char *output );
00183 
00208 int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
00209                     int mode,
00210                     size_t length,
00211                     unsigned char iv[16],
00212                     const unsigned char *input,
00213                     unsigned char *output );
00214 #endif /*MBEDTLS_CIPHER_MODE_CFB */
00215 
00216 #if defined(MBEDTLS_CIPHER_MODE_CTR)
00217 
00239 int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
00240                        size_t length,
00241                        size_t *nc_off,
00242                        unsigned char nonce_counter[16],
00243                        unsigned char stream_block[16],
00244                        const unsigned char *input,
00245                        unsigned char *output );
00246 #endif /* MBEDTLS_CIPHER_MODE_CTR */
00247 
00257 void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
00258                           const unsigned char input[16],
00259                           unsigned char output[16] );
00260 
00270 void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
00271                           const unsigned char input[16],
00272                           unsigned char output[16] );
00273 
00274 #ifdef __cplusplus
00275 }
00276 #endif
00277 
00278 #else  /* MBEDTLS_AES_ALT */
00279 #include "aes_alt.h"
00280 #endif /* MBEDTLS_AES_ALT */
00281 
00282 #ifdef __cplusplus
00283 extern "C" {
00284 #endif
00285 
00291 int mbedtls_aes_self_test( int verbose );
00292 
00293 #ifdef __cplusplus
00294 }
00295 #endif
00296 
00297 #endif /* aes.h */

Generated on 11 Mar 2017 for mbed TLS v2.4.2 by  doxygen 1.4.7