#include #include #define u uint8_t #define c uint16_t #define t uint32_t #define o putchar u r[16]={0}; c m[256]={ 0x0082, 0x1945, 0x1f55, 0x060f, 0x00f7, 0x05f2, 0x04f3, 0x01f5, 0x061f, 0x1f53, 0x0b4f, 0x0722, 0x0231, 0x0877, 0x1f03, 0x00e7, 0x0aef, 0x1f05, 0x00d6, 0x09df, 0x04de, 0x015d, 0x1f4b, 0x034f, 0x241c, 0x1f41, 0x0bf4, 0x066f, 0x1f4c, 0x010f, 0x00f0, 0x0001, 0x0012, 0x0023, 0x0034, 0x0045, 0x0056, 0x0067, 0x007f, 0x1f01, 0x029f, 0x1f00, 0x039f, 0x2202, 0x1fc8, 0x03f0, 0x2252, 0x1fb6, 0x03f1, 0x2252, 0x1f0f, 0x03f2, 0x2252, 0x1fec, 0x03f3, 0x2252, 0x1f6c, 0x03f4, 0x2252, 0x1f94, 0x03f5, 0x2252, 0x1fad, 0x03f6, 0x2252, 0x1f5d, 0x03f7, 0x2252, 0x383a, 0x381c, 0x380a, 0x380a, 0x380c, 0x381a, 0x381a, 0x3848, 0x3849, 0x3853, 0x3844, 0x382d, 0x3863, 0xffff, 0x1fa9, 0x3fef, 0x3fc8, 0x3fc0, 0x3fc5, 0x3fdc, 0x3fdb, 0x3fcc, 0x3f89, 0x3f93, 0x3f84, 0x3ff9, 0x3fa3, 0xffff, }; u p; u s[7]; void test(t h, t l) { p=0; s[0]=1; r[0]=h>>24;r[1]=h>>16;r[2]=h>>8;r[3]=h; r[4]=l>>24;r[5]=l>>16;r[6]=l>>8;r[7]=l; while(1) { u w = m[p]>>12, x = (m[p]>>8)&0xf, y=(m[p]>>4)&0xf, z=m[p]&0xf; if(w==0) switch(x) { case 0: r[y]=r[z]; break; case 1: r[y]+=r[z]; break; case 2: r[y]-=r[z]; break; case 3: s[1]=r[y]==r[z];s[2]=r[y]!=r[z];s[3]=r[y]r[z];s[5]=r[y]<=r[z];s[6]=r[y]>=r[z]; break; case 4: r[y]|=r[z]; break; case 5: r[y]&=r[z]; break; case 6: r[y]^=r[z]; break; case 7: r[y]=~r[z]; break; case 8: r[y]=-r[z]; break; case 9: r[y]<<=r[z]; break; case 10: r[y]>>=r[z]; break; case 11: r[y]*=r[z]; break; } else if (w==1) r[x]=m[p]; else if (w==2&&s[x]) p=m[p]-1; else if (w==3) o(m[p]^r[x]); else if (w==15) break; p++; } } int main(int argc, char **argv) { uint32_t khi, klo; printf("Enter 64bit key (hex): "); scanf("%8x%8x", &khi, &klo); test(khi, klo); return 0; }