void Blowfish_Key_Setup (UINT8 key[], short keybytes, BLOWFISH_KEYSCHED *keytab) { extern BLOWFISH_KEYSCHED Blowfish_Init_Key; memcpy (keytab, &Blowfish_Init_Key, sizeof (Blowfish_Init_Key)); /* Call InitializeBlowfish to stir up the P and S tables */ InitializeBlowfish (key, keybytes, keytab); /* now call it again to stir them up some more */ InitializeBlowfish (key, keybytes, keytab); }
BlowFish::BlowFish(const unsigned char *key, int keylen) { /* bf_P and bf_S, *were* static global variables (for speed?). the temp... versions never are changed and are copied to the real" ones used by the actual algorithm. These can change, as they are dependent on passkeys. The "real" (and the temp - why?? - stopped for now) are trashed in ~BlowFish(), because after that they are surely not needed. */ int x, y; for (x = 0; x < 18; x++) { bf_P[x] = tempbf_P[x]; } for (x = 0; x < 4; x++) { for (y = 0; y < 256; y++) { bf_S[x][y] = tempbf_S[x][y]; } } InitializeBlowfish(key, short(keylen)); }
void CLobbyServerPlayer::ProcessStartSession(const PacketData& packetData) { uint32 clientTime = *reinterpret_cast<const uint32*>(&packetData[0x84]); //We assume clientTime is 0x50E0E812, but we need to generate a proper key later uint8 blowfishKey[0x10] = { 0xB4, 0xEE, 0x3F, 0x6C, 0x01, 0x6F, 0x5B, 0xD9, 0x71, 0x50, 0x0D, 0xB1, 0x85, 0xA2, 0xAB, 0x43 }; InitializeBlowfish(reinterpret_cast<char*>(blowfishKey), 0x10); CLog::GetInstance().LogMessage(LOG_NAME, "Received encryption key: 0x%0.8X.\r\n", clientTime); //Respond with acknowledgment std::vector<uint8> outgoingPacket(std::begin(g_secureConnectionAcknowledgment), std::end(g_secureConnectionAcknowledgment)); CPacketUtils::EncryptPacket(outgoingPacket); QueuePacket(outgoingPacket); }
//Initialize with Key BlowFish::BlowFish(const TUint8 *key, TInt keylen) { /* bf_P and bf_S, for speed reasons, are static global variables. the temp... versions never are changed and are copied to the real" ones used by the actual algorithm. These can change, as they are dependent on passkeys. */ TInt x, y; for (x=0; x<bf_N + 2; x++) bf_P[x] = tempbf_P[x]; for (x=0; x<4; x++) { for (y=0; y<256; y++) { bf_S[x][y] = tempbf_S[x][y]; } } InitializeBlowfish(key, keylen); }
void blf_key (blf_ctx *c, unsigned char *k, int len) { InitializeBlowfish(c, k, len); }
void CCryptMgr::SetKey(const char* key) { InitializeBlowfish((UBYTE_08bits*)key, sizeof(key)); }
CCryptMgr::CCryptMgr(char* key) { InitializeBlowfish((UBYTE_08bits*)key, sizeof(key)); }