From: hackbard Date: Mon, 29 Sep 2003 07:35:13 +0000 (+0000) Subject: - X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d84dd2104da5556056f6f9fd53dfcbd672d8f8a;p=my-code%2Fcrypto.git - --- diff --git a/des.c b/des.c index 04951d6..db0aba8 100644 --- a/des.c +++ b/des.c @@ -27,16 +27,16 @@ u8 subkey_perm_table[DES_PERMC_LEN]={ int rotate_right(u8 *obj,int len) { u8 tmp=obj[len-1]; - while(--len) obj[len]=obj[len-1]; - obj[0]=tmp; + while(--len) obj[len]=obj[len]>>1|((obj[len-1]&1)<<7); + obj[0]=obj[0]>>1|((tmp&1)<<7);; 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; + for(i=0;i>7); + obj[len-1]=obj[len-1]<<1|(tmp>>7); return 1; } @@ -53,17 +53,19 @@ key_perm(u8 *key) { int subkey_trans(u8 *key,int round) { int i; for(i=0;i>((8-subkey_perm_table[i]%8)&7)&1))<<(7-i%8)); + return 1; }