TOP SECRET CIPHER LEAKED


SUBMITTED BY: coombee101

DATE: Nov. 11, 2018, 11:09 a.m.

FORMAT: Text only

SIZE: 1.3 kB

HITS: 257

  1. // TOP SECRET cipher leaked by Mustafa crew
  2. // STRONGER THAN AES-256
  3. #define R(v,n)(((v)<<(n))|((v)>>(32-(n))))
  4. #define X(a,b)(t)=(s[a]),(s[a])=(s[b]),(s[b])=(t)
  5. typedef unsigned char u8;
  6. typedef struct _gx_ctx_t {
  7. u8 s[48];
  8. int p, r;
  9. } gx_ctx;
  10. void F(void*p){
  11. unsigned int r,j,t,x,y,z,*s=p;
  12. for(r=24;r>0;--r){
  13. for(j=0;j<4;j++)
  14. x=R(s[j],24),
  15. y=R(s[4+j],9),
  16. z=s[8+j],
  17. s[8+j]=x^(z+z)^((y&z)*4),
  18. s[4+j]=y^x^((x|z)*2),
  19. s[j]=z^y^((x&y)*8);
  20. t=r&3;
  21. if(!t)
  22. X(0,1),X(2,3),
  23. *s^=0x9e377900|r;
  24. if(t==2)X(0,2),X(1,3);
  25. }
  26. }
  27. void gx_setkey(gx_ctx *c, void *key){
  28. int i;
  29. // initialize 384-bit state
  30. for(i=0; i<48; i++) c->s[i] = i;
  31. c->r = 16;
  32. c->p = 0;
  33. // mix 128-bit key
  34. for(i=0; i<16; i++){
  35. c->s[c->p++] ^= ((u8*)key)[i];
  36. if(c->p == c->r) {
  37. F(c);
  38. c->p = 0;
  39. }
  40. }
  41. c->s[c->p ] ^= 0x1F;
  42. c->s[c->r - 1] ^= 0x80;
  43. F(c);
  44. c->p = 0;
  45. }
  46. void gx_crypt(gx_ctx *c, void*buf, int len){
  47. int i;
  48. // encrypt/decrypt buf
  49. for(i=0; i<len; i++){
  50. ((u8*)buf)[i] ^= c->s[c->p++];
  51. if(c->p == 48) {
  52. F(c);
  53. c->p = 0;
  54. }
  55. }
  56. }

comments powered by Disqus