ce188d4d |
1 | /********************************************************************* |
2 | * Filename: des.h |
3 | * Author: Brad Conte (brad AT bradconte.com) |
4 | * Copyright: |
5 | * Disclaimer: This code is presented "as is" without any guarantees. |
6 | * Details: Defines the API for the corresponding DES implementation. |
7 | Note that encryption and decryption are defined by how |
8 | the key setup is performed, the actual en/de-cryption is |
9 | performed by the same function. |
10 | *********************************************************************/ |
11 | |
12 | #ifndef DES_H |
13 | #define DESH |
14 | |
15 | /*************************** HEADER FILES ***************************/ |
16 | #include <stddef.h> |
17 | |
18 | /****************************** MACROS ******************************/ |
19 | #define DES_BLOCK_SIZE 8 // DES operates on 8 bytes at a time |
20 | |
21 | /**************************** DATA TYPES ****************************/ |
22 | typedef unsigned char BYTE; // 8-bit byte |
23 | typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines |
24 | |
25 | typedef enum { |
26 | DES_ENCRYPT, |
27 | DES_DECRYPT |
28 | } DES_MODE; |
29 | |
30 | /*********************** FUNCTION DECLARATIONS **********************/ |
31 | void des_key_setup(const BYTE key[], BYTE schedule[][6], DES_MODE mode); |
32 | void des_crypt(const BYTE in[], BYTE out[], const BYTE key[][6]); |
33 | |
34 | void three_des_key_setup(const BYTE key[], BYTE schedule[][16][6], DES_MODE mode); |
35 | void three_des_crypt(const BYTE in[], BYTE out[], const BYTE key[][16][6]); |
36 | |
37 | #endif // DES_H |