Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
des.h
1 //
2 // Implementation of DES coded by:
3 // - David Wong, moi@davidwong.fr
4 // - Jacques Monin, jacques.monin@u-bordeaux.fr
5 // - Hugo Bonnin, hugo.bonnin@u-bordeaux.fr
6 //
7 
8 #ifndef DES_H
9 #define DES_H
10 
12 // USEFUL DEFINES //
14 
15 #define FIRSTBIT 0x8000000000000000 // 1000000000...
16 
18 // PROTOTYPES //
20 
21 // Addbit helper
22 // Takes the bit number "position_from" from "from"
23 // adds it to "block" in position "position_to"
24 void addbit(uint64_t *block, uint64_t from,
25  int position_from, int position_to);
26 
27 // Initial and Final Permutations
28 void Permutation(uint64_t* data, bool initial);
29 
30 // Verify if the parity bits are okay
31 bool key_parity_verify(uint64_t key);
32 
33 // Key Schedule ( http://en.wikipedia.org/wiki/File:DES-key-schedule.png )
34 // input :
35 // * encrypt : false if decryption
36 // * next_key : uint64_t next_key 0
37 // * round : [[0, 15]]
38 // changes :
39 // * [key] is good to be used in the XOR in the rounds
40 // * [next_key] is the combined leftkey+rightkey to be used
41 // in the key_schedule for next round
42 void key_schedule(uint64_t* key, uint64_t* next_key, int round);
43 
44 void rounds(uint64_t *data, uint64_t key);
45 
46 void genkey(uint64_t *key);
47 void des_encrypt(char *in, int isize, char *out, uint64_t key);
48 void des_decrypt(char *in, int isize, char *out, uint64_t key);
49 
50 
51 #endif