/* PKEP ( Pukall Key Exchange Protocol (c) Alexander PUKALL 1997 */ /* end at July 7, 1997 */ /* can be freely use */ /* but the name of the author must be included in the final software */ /* this algorithm allows to exchange securly a random password */ /* use the PC3 cipher for random number generation based on a 160-bit seed */ /* run the Phase 1 */ /* send the SEND.BIN file to your correspondent over the internet */ /* keep the LOCAL.BIN file secret on your harddisk */ /* your correspondent run Phase 1 too, and send you his SEND.BIN file */ /* you erase your own SEND.BIN file and replace it with the SEND.BIN file*/ /* of your correspondent */ /* your correspondent erase his own SEND.BIN file and replace it with your*/ /* SEND.BIN file */ /* Both run Phase 2*/ /* You will obtain a common random password, impossible to intercept over the*/ /* internet */ /* you can use this password with an other soft to exchange messages */ /* NOT FOR EXPORT */ #include #include #include #include #include unsigned long a1,b1[128],index; unsigned int r1,cle; typedef unsigned char u; unsigned char expo2[64]; u m[1024],g[1024],e[1024],b[1024]; int n,v,d,z,S=65; stream(unsigned int *r1,unsigned long *index,unsigned long *a1,unsigned long *b1) { b1[*index] = ( b1[*index] * (*a1) ) + 1; *r1 = _rotl( (*r1 + (( b1[*index] >> 16 ) & 0x7fff)), ((*r1)%16) ); } unsigned char pc3stream(unsigned char byte) { unsigned short d; for (index=0;index<=(cle-1);index++) { stream(&r1,&index,&a1,b1); } d=byte; byte=byte^(r1&255); r1=r1+d; b1[cle-1]=b1[cle-1]+d; return(byte); } pc3init(unsigned int lngkey,unsigned char key[258]) { unsigned int z,y,x,i; unsigned char tab[258],plain; div_t reste; if (lngkey>256) lngkey=256; if (lngkey<1) { lngkey=1; strcpy(key,"a"); } x=lngkey; for (i=0;i=x) i=0; } reste=div(lngkey,2); cle=reste.quot; if (reste.rem!=0) cle=cle+1; for (z=0;z<128;z++) { b1[z]=0; } y=0; for (z=0;z<=(cle-1);z++) { if ( (z==(cle-1))&&(reste.rem!=0) ) { b1[z]=tab[y]*256; } else { b1[z]=(tab[y]*256)+tab[y+1]; y=y+1; } y=y+1; } for (z=0;z>8; } } s(u *x) { for(v=0;(v=m[v])a(x,m,-1); } r(u *x) { d=0; for(v=0;v