PolarSSL v1.1.4
des.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_DES_H
28 #define POLARSSL_DES_H
29 
30 #include <string.h>
31 
32 #define DES_ENCRYPT 1
33 #define DES_DECRYPT 0
34 
35 #define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH -0x0032
37 #define DES_KEY_SIZE 8
38 
42 typedef struct
43 {
44  int mode;
45  unsigned long sk[32];
46 }
48 
52 typedef struct
53 {
54  int mode;
55  unsigned long sk[96];
56 }
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
71 void des_key_set_parity( unsigned char key[DES_KEY_SIZE] );
72 
83 int des_key_check_key_parity( const unsigned char key[DES_KEY_SIZE] );
84 
92 int des_key_check_weak( const unsigned char key[DES_KEY_SIZE] );
93 
102 int des_setkey_enc( des_context *ctx, const unsigned char key[DES_KEY_SIZE] );
103 
112 int des_setkey_dec( des_context *ctx, const unsigned char key[DES_KEY_SIZE] );
113 
122 int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] );
123 
132 int des3_set2key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] );
133 
142 int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] );
143 
152 int des3_set3key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] );
153 
163 int des_crypt_ecb( des_context *ctx,
164  const unsigned char input[8],
165  unsigned char output[8] );
166 
177 int des_crypt_cbc( des_context *ctx,
178  int mode,
179  size_t length,
180  unsigned char iv[8],
181  const unsigned char *input,
182  unsigned char *output );
183 
193 int des3_crypt_ecb( des3_context *ctx,
194  const unsigned char input[8],
195  unsigned char output[8] );
196 
209 int des3_crypt_cbc( des3_context *ctx,
210  int mode,
211  size_t length,
212  unsigned char iv[8],
213  const unsigned char *input,
214  unsigned char *output );
215 
216 /*
217  * \brief Checkup routine
218  *
219  * \return 0 if successful, or 1 if the test failed
220  */
221 int des_self_test( int verbose );
222 
223 #ifdef __cplusplus
224 }
225 #endif
226 
227 #endif /* des.h */