MCPcopy Create free account
hub / github.com/assaultcube/AC / gensboxes

Function gensboxes

source/src/crypto.cpp:90–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 }
89
90 void gensboxes()
91 {
92 const char *str = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham";
93 chunk state[3] = { 0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL, 0xF096A5B4C3B2E187ULL };
94
95 loopi(1024) loop(col, 8) ((uchar *)&sboxes[i])[col] = i&0xFF;
96
97 int abc = 2;
98 loop(pass, 5) loopi(256) for(int sb = 0; sb < 1024; sb += 256)
99 {
100 abc++;
101 if(abc >= 3) { abc = 0; compress((const chunk *)str, state); }
102 loop(col, 8)
103 {
104 uchar val = ((uchar *)&sboxes[sb+i])[col];
105 ((uchar *)&sboxes[sb+i])[col] = ((uchar *)&sboxes[sb + ((uchar *)&state[abc])[col]])[col];
106 ((uchar *)&sboxes[sb + ((uchar *)&state[abc])[col]])[col] = val;
107 }
108 }
109 }
110
111 struct incremental_buffer { int len, total; union { uchar u[64]; chunk c[8]; }; incremental_buffer() { len = total = 0; } };
112

Callers 1

hash_initFunction · 0.85

Calls 3

compressFunction · 0.85
loopiFunction · 0.70
loopFunction · 0.70

Tested by

no test coverage detected