MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / GenerateTables

Method GenerateTables

Libraries/unrar/rijndael.cpp:436–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434 (w = (uint)x, w = (w<<1)^(w<<3)^(w<<6), (byte)(0x05^(w^(w>>8))))
435
436void Rijndael::GenerateTables()
437{
438 unsigned char pow[512],log[256];
439 int i = 0, w = 1;
440 do
441 {
442 pow[i] = (byte)w;
443 pow[i + 255] = (byte)w;
444 log[w] = (byte)i++;
445 w ^= (w << 1) ^ (w & ff_hi ? ff_poly : 0);
446 } while (w != 1);
447
448 for (int i = 0,w = 1; i < sizeof(rcon)/sizeof(rcon[0]); i++)
449 {
450 rcon[i] = w;
451 w = (w << 1) ^ (w & ff_hi ? ff_poly : 0);
452 }
453 for(int i = 0; i < 256; ++i)
454 {
455 unsigned char b=S[i]=fwd_affine(FFinv((byte)i));
456 T1[i][1]=T1[i][2]=T2[i][2]=T2[i][3]=T3[i][0]=T3[i][3]=T4[i][0]=T4[i][1]=b;
457 T1[i][0]=T2[i][1]=T3[i][2]=T4[i][3]=FFmul02(b);
458 T1[i][3]=T2[i][0]=T3[i][1]=T4[i][2]=FFmul03(b);
459 S5[i] = b = FFinv(inv_affine((byte)i));
460 U1[b][3]=U2[b][0]=U3[b][1]=U4[b][2]=T5[i][3]=T6[i][0]=T7[i][1]=T8[i][2]=FFmul0b(b);
461 U1[b][1]=U2[b][2]=U3[b][3]=U4[b][0]=T5[i][1]=T6[i][2]=T7[i][3]=T8[i][0]=FFmul09(b);
462 U1[b][2]=U2[b][3]=U3[b][0]=U4[b][1]=T5[i][2]=T6[i][3]=T7[i][0]=T8[i][1]=FFmul0d(b);
463 U1[b][0]=U2[b][1]=U3[b][2]=U4[b][3]=T5[i][0]=T6[i][1]=T7[i][2]=T8[i][3]=FFmul0e(b);
464 }
465}
466
467
468#if 0

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected