11 * \brief DES context structure
15 int mode
; /*!< encrypt/decrypt */
16 unsigned long sk
[32]; /*!< DES subkeys */
21 * \brief Triple-DES context structure
25 int mode
; /*!< encrypt/decrypt */
26 unsigned long sk
[96]; /*!< 3DES subkeys */
35 * \brief DES key schedule (56-bit, encryption)
37 * \param ctx DES context to be initialized
38 * \param key 8-byte secret key
40 void des_setkey_enc( des_context
*ctx
, unsigned char key
[8] );
43 * \brief DES key schedule (56-bit, decryption)
45 * \param ctx DES context to be initialized
46 * \param key 8-byte secret key
48 void des_setkey_dec( des_context
*ctx
, unsigned char key
[8] );
51 * \brief Triple-DES key schedule (112-bit, encryption)
53 * \param ctx 3DES context to be initialized
54 * \param key 16-byte secret key
56 void des3_set2key_enc( des3_context
*ctx
, unsigned char key
[16] );
59 * \brief Triple-DES key schedule (112-bit, decryption)
61 * \param ctx 3DES context to be initialized
62 * \param key 16-byte secret key
64 void des3_set2key_dec( des3_context
*ctx
, unsigned char key
[16] );
67 * \brief Triple-DES key schedule (168-bit, encryption)
69 * \param ctx 3DES context to be initialized
70 * \param key 24-byte secret key
72 void des3_set3key_enc( des3_context
*ctx
, unsigned char key
[24] );
75 * \brief Triple-DES key schedule (168-bit, decryption)
77 * \param ctx 3DES context to be initialized
78 * \param key 24-byte secret key
80 void des3_set3key_dec( des3_context
*ctx
, unsigned char key
[24] );
83 * \brief DES-ECB block encryption/decryption
85 * \param ctx DES context
86 * \param input 64-bit input block
87 * \param output 64-bit output block
89 void des_crypt_ecb( des_context
*ctx
,
90 unsigned char input
[8],
91 unsigned char output
[8] );
94 * \brief DES-CBC buffer encryption/decryption
96 * \param ctx DES context
97 * \param mode DES_ENCRYPT or DES_DECRYPT
98 * \param length length of the input data
99 * \param iv initialization vector (updated after use)
100 * \param input buffer holding the input data
101 * \param output buffer holding the output data
103 void des_crypt_cbc( des_context
*ctx
,
107 unsigned char *input
,
108 unsigned char *output
);
111 * \brief 3DES-ECB block encryption/decryption
113 * \param ctx 3DES context
114 * \param input 64-bit input block
115 * \param output 64-bit output block
117 void des3_crypt_ecb( des3_context
*ctx
,
118 unsigned char input
[8],
119 unsigned char output
[8] );
122 * \brief 3DES-CBC buffer encryption/decryption
124 * \param ctx 3DES context
125 * \param mode DES_ENCRYPT or DES_DECRYPT
126 * \param length length of the input data
127 * \param iv initialization vector (updated after use)
128 * \param input buffer holding the input data
129 * \param output buffer holding the output data
131 void des3_crypt_cbc( des3_context
*ctx
,
135 unsigned char *input
,
136 unsigned char *output
);
139 * \brief Checkup routine
141 * \return 0 if successful, or 1 if the test failed
143 int des_self_test( int verbose
);