--- /dev/null
+/*
+ * des.c - data encryption standard algo
+ *
+ * author: hackbard@hackdaworld.dyndns.org
+ *
+ */
+
+#include "des.h"
+
+u8 key_perm_table[DES_SUBKEY_LEN]={
+ 57,49,41,33,25,17,9,1,58,50,42,34,26,18,
+ 10,2,59,51,43,35,27,18,11,3,60,52,44,36,
+ 63,55,47,39,31,23,15,7,62,54,46,38,30,22,
+ 14,6,61,53,45,37,29,21,13,5,28,20,12,4
+};
+
+u8 rot_per_round_table[DES_ROUNDS]={
+ 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1
+};
+
+u8 subkey_perm_table[DES_PERMC_LEN]={
+ 14,17,11,24,1,5,3,28,15,6,21,10,
+ 23,19,12,4,26,8,16,7,27,20,13,2,
+ 41,52,31,37,47,55,30,40,51,45,33,48,
+ 44,49,39,56,34,53,46,42,50,36,29,32
+};
+
+int rotate_right(u8 *obj,int len) {
+ u8 tmp=obj[len-1];
+ while(--len) obj[len]=obj[len-1];
+ obj[0]=tmp;
+ return 1;
+}
+
+int rotate_left(u8 *obj,int len) {
+ int i=0;
+ u8 tmp=obj[0];
+ while(len-(i++)) obj[i-1]=obj[i];
+ obj[len-1]=tmp;
+ return 1;
+}
+
+key_perm(u8 *key) {
+ int i;
+ u8 *new[DES_SUBKEY_LEN];
+ for(i=0;i<DES_SUBKEY_LEN;i++)
+ new[i]=key[key_perm_table[i]];
+ memcpy(key,new,DES_SUBKEY_LEN);
+ return 1;
+}
+
+int subkey_trans(u8 *key,int round) {
+ int i;
+ for(i=0;i<rot_per_round_table[round];i++) {
+ rotate_left(key,DES_SUBKEY_LEN/2);
+ rotate_left(key+DES_SUBKEY_LEN/2,DES_SUBKEY_LEN/2);
+ }
+ return 1;
+}
+
+int des_crypt(u8 *plain,u8 *crypted,u8 *key) {
+ int round;
+
+ key_perm(key);
+ for(round=0;round<DES_ROUND;round++) {
+ subkey_trans(key,round);
+ // fuckup_data(key,round);
+ }
+
+ return 1;
+}
+
+int des_decrypt(u8 *crypted,u8 *plain,u8 *key) {
+
+
+ return 1;
+}