PolarSSL v1.2.5
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 #ifdef _MSC_VER
33 #include <basetsd.h>
34 typedef UINT32 uint32_t;
35 #else
36 #include <inttypes.h>
37 #endif
38 
39 #define DES_ENCRYPT 1
40 #define DES_DECRYPT 0
41 
42 #define POLARSSL_ERR_DES_INVALID_INPUT_LENGTH -0x0032
44 #define DES_KEY_SIZE 8
45 
49 typedef struct
50 {
51  int mode;
52  uint32_t sk[32];
53 }
55 
59 typedef struct
60 {
61  int mode;
62  uint32_t sk[96];
63 }
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
78 void des_key_set_parity( unsigned char key[DES_KEY_SIZE] );
79 
90 int des_key_check_key_parity( const unsigned char key[DES_KEY_SIZE] );
91 
99 int des_key_check_weak( const unsigned char key[DES_KEY_SIZE] );
100 
109 int des_setkey_enc( des_context *ctx, const unsigned char key[DES_KEY_SIZE] );
110 
119 int des_setkey_dec( des_context *ctx, const unsigned char key[DES_KEY_SIZE] );
120 
129 int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] );
130 
139 int des3_set2key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] );
140 
149 int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] );
150 
159 int des3_set3key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] );
160 
170 int des_crypt_ecb( des_context *ctx,
171  const unsigned char input[8],
172  unsigned char output[8] );
173 
184 int des_crypt_cbc( des_context *ctx,
185  int mode,
186  size_t length,
187  unsigned char iv[8],
188  const unsigned char *input,
189  unsigned char *output );
190 
200 int des3_crypt_ecb( des3_context *ctx,
201  const unsigned char input[8],
202  unsigned char output[8] );
203 
216 int des3_crypt_cbc( des3_context *ctx,
217  int mode,
218  size_t length,
219  unsigned char iv[8],
220  const unsigned char *input,
221  unsigned char *output );
222 
228 int des_self_test( int verbose );
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 
234 #endif /* des.h */