projects
/
my-code
/
crypto.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
-
[my-code/crypto.git]
/
des.c
diff --git
a/des.c
b/des.c
index
a1cdbba
..
04951d6
100644
(file)
--- a/
des.c
+++ b/
des.c
@@
-42,9
+42,10
@@
int rotate_left(u8 *obj,int len) {
key_perm(u8 *key) {
int i;
key_perm(u8 *key) {
int i;
- u8 *new[DES_SUBKEY_LEN];
+ u8 *new[DES_SUBKEY_LEN/8];
+ memset(new,0,DES_SUBKEY_LEN/8];
for(i=0;i<DES_SUBKEY_LEN;i++)
for(i=0;i<DES_SUBKEY_LEN;i++)
- new[i
]=key[key_perm_table[i]]
;
+ new[i
/8]|=(((key[(key_perm_table[i]-1)/8)]>>((8-key_perm_table[i]%8)&7))&1)<<(7-i%8))
;
memcpy(key,new,DES_SUBKEY_LEN);
return 1;
}
memcpy(key,new,DES_SUBKEY_LEN);
return 1;
}
@@
-58,13
+59,22
@@
int subkey_trans(u8 *key,int round) {
return 1;
}
return 1;
}
+int fuckup_data(u8 *key,int round,u8 *plain,u8 *crypted) {
+ u8 permc[DES_PERMC_LEN];
+ int i;
+ for(i=0;i<DES_PERMC_LEN;i++)
+ permc[i]=key[subkey_perm_table[i]];
+
+ 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);
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);
+ // fuckup_data(key,round
,plain,crypted
);
}
return 1;
}
return 1;