desmodes.c (647B)
1 #include "os.h" 2 #include "libsec.h" 3 4 /* 5 * these routines use the 64bit format for 6 * DES keys. 7 */ 8 9 void 10 setupDESstate(DESstate *s, uchar key[8], uchar *ivec) 11 { 12 memset(s, 0, sizeof(*s)); 13 memmove(s->key, key, sizeof(s->key)); 14 des_key_setup(key, s->expanded); 15 if(ivec) 16 memmove(s->ivec, ivec, 8); 17 s->setup = 0xdeadbeef; 18 } 19 20 void 21 setupDES3state(DES3state *s, uchar key[3][8], uchar *ivec) 22 { 23 memset(s, 0, sizeof(*s)); 24 memmove(s->key, key, sizeof(s->key)); 25 des_key_setup(key[0], s->expanded[0]); 26 des_key_setup(key[1], s->expanded[1]); 27 des_key_setup(key[2], s->expanded[2]); 28 if(ivec) 29 memmove(s->ivec, ivec, 8); 30 s->setup = 0xdeadbeef; 31 }