des.h

Go to the documentation of this file.
00001 
00023 #ifndef MBEDTLS_DES_H
00024 #define MBEDTLS_DES_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 #define MBEDTLS_DES_ENCRYPT     1
00036 #define MBEDTLS_DES_DECRYPT     0
00037 
00038 #define MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH              -0x0032  
00040 #define MBEDTLS_DES_KEY_SIZE    8
00041 
00042 #if !defined(MBEDTLS_DES_ALT)
00043 // Regular implementation
00044 //
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049 
00053 typedef struct
00054 {
00055     uint32_t sk[32];            
00056 }
00057 mbedtls_des_context;
00058 
00062 typedef struct
00063 {
00064     uint32_t sk[96];            
00065 }
00066 mbedtls_des3_context;
00067 
00073 void mbedtls_des_init( mbedtls_des_context *ctx );
00074 
00080 void mbedtls_des_free( mbedtls_des_context *ctx );
00081 
00087 void mbedtls_des3_init( mbedtls_des3_context *ctx );
00088 
00094 void mbedtls_des3_free( mbedtls_des3_context *ctx );
00095 
00104 void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] );
00105 
00116 int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
00117 
00125 int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
00126 
00135 int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
00136 
00145 int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
00146 
00155 int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx,
00156                       const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] );
00157 
00166 int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx,
00167                       const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] );
00168 
00177 int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx,
00178                       const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] );
00179 
00188 int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx,
00189                       const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] );
00190 
00200 int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx,
00201                     const unsigned char input[8],
00202                     unsigned char output[8] );
00203 
00204 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00205 
00223 int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx,
00224                     int mode,
00225                     size_t length,
00226                     unsigned char iv[8],
00227                     const unsigned char *input,
00228                     unsigned char *output );
00229 #endif /* MBEDTLS_CIPHER_MODE_CBC */
00230 
00240 int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx,
00241                      const unsigned char input[8],
00242                      unsigned char output[8] );
00243 
00244 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00245 
00265 int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx,
00266                      int mode,
00267                      size_t length,
00268                      unsigned char iv[8],
00269                      const unsigned char *input,
00270                      unsigned char *output );
00271 #endif /* MBEDTLS_CIPHER_MODE_CBC */
00272 
00281 void mbedtls_des_setkey( uint32_t SK[32],
00282                          const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
00283 #ifdef __cplusplus
00284 }
00285 #endif
00286 
00287 #else  /* MBEDTLS_DES_ALT */
00288 #include "des_alt.h"
00289 #endif /* MBEDTLS_DES_ALT */
00290 
00291 #ifdef __cplusplus
00292 extern "C" {
00293 #endif
00294 
00300 int mbedtls_des_self_test( int verbose );
00301 
00302 #ifdef __cplusplus
00303 }
00304 #endif
00305 
00306 #endif /* des.h */

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