MCPcopy Create free account
hub / github.com/crossuo/crossuo / reKey

Function reKey

src/Crypt/GameCrypt.cpp:679–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677}
678
679static void reKey(keyInstance *key)
680{
681 int keyLen = key->keyLen;
682 int subkeyCnt = 8 + 2 * key->numRounds;
683 unsigned int k32e[4], k32o[4];
684 unsigned int A = 0, B = 0;
685
686 int k64Cnt = (keyLen + 63) / 64;
687
688 for (int i = 0; i < k64Cnt; i++)
689 {
690 k32e[i] = key->key32[2 * i];
691 k32o[i] = key->key32[2 * i + 1];
692 key->sboxKeys[k64Cnt - 1 - i] = RS_MDS_Encode(k32e[i], k32o[i]);
693 }
694
695 for (int i = 0; i < subkeyCnt / 2; i++)
696 {
697 A = F32(i * 0x02020202u, k32e, keyLen);
698 B = F32(i * 0x02020202u + 0x01010101u, k32o, keyLen);
699 B = ROL(B, 8);
700 key->subKeys[2 * i] = A + B;
701 key->subKeys[2 * i + 1] = ROL(A + 2 * B, 9);
702 }
703}
704
705static void cipherInit(cipherInstance *cipher, unsigned char mode, char *IV)
706{

Callers 1

InitMethod · 0.85

Calls 2

RS_MDS_EncodeFunction · 0.85
F32Function · 0.85

Tested by

no test coverage detected