PolarSSL
|
00001 00025 #ifndef POLARSSL_DES_H 00026 #define POLARSSL_DES_H 00027 00028 #define DES_ENCRYPT 1 00029 #define DES_DECRYPT 0 00030 00031 #define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH -0x0C00 00032 00036 typedef struct 00037 { 00038 int mode; 00039 unsigned long sk[32]; 00040 } 00041 des_context; 00042 00046 typedef struct 00047 { 00048 int mode; 00049 unsigned long sk[96]; 00050 } 00051 des3_context; 00052 00053 #ifdef __cplusplus 00054 extern "C" { 00055 #endif 00056 00063 void des_setkey_enc( des_context *ctx, const unsigned char key[8] ); 00064 00071 void des_setkey_dec( des_context *ctx, const unsigned char key[8] ); 00072 00079 void des3_set2key_enc( des3_context *ctx, const unsigned char key[16] ); 00080 00087 void des3_set2key_dec( des3_context *ctx, const unsigned char key[16] ); 00088 00095 void des3_set3key_enc( des3_context *ctx, const unsigned char key[24] ); 00096 00103 void des3_set3key_dec( des3_context *ctx, const unsigned char key[24] ); 00104 00114 int des_crypt_ecb( des_context *ctx, 00115 const unsigned char input[8], 00116 unsigned char output[8] ); 00117 00128 int des_crypt_cbc( des_context *ctx, 00129 int mode, 00130 int length, 00131 unsigned char iv[8], 00132 const unsigned char *input, 00133 unsigned char *output ); 00134 00144 int des3_crypt_ecb( des3_context *ctx, 00145 const unsigned char input[8], 00146 unsigned char output[8] ); 00147 00160 int des3_crypt_cbc( des3_context *ctx, 00161 int mode, 00162 int length, 00163 unsigned char iv[8], 00164 const unsigned char *input, 00165 unsigned char *output ); 00166 00167 /* 00168 * \brief Checkup routine 00169 * 00170 * \return 0 if successful, or 1 if the test failed 00171 */ 00172 int des_self_test( int verbose ); 00173 00174 #ifdef __cplusplus 00175 } 00176 #endif 00177 00178 #endif /* des.h */