-
- void InitAES(std::string key,std::string SName)
- {
- if (key == "")
- return;
-
- ctx_in = new AES();
- ctx_out = new AES();
- Instance->Log(DEBUG,"Initialized AES key %s",key.c_str());
- // key must be 16, 24, 32 etc bytes (multiple of 8)
- keylength = key.length();
- if (!(keylength == 16 || keylength == 24 || keylength == 32))
- {
- this->Instance->SNO->WriteToSnoMask('l',"\2ERROR\2: Key length for encryptionkey is not 16, 24 or 32 bytes in length!");
- Instance->Log(DEBUG,"Key length not 16, 24 or 32 characters!");
- }
- else
- {
- if (this->GetState() != I_ERROR)
- {
- this->Instance->SNO->WriteToSnoMask('l',"\2AES\2: Initialized %d bit encryption to server %s",keylength*8,SName.c_str());
- ctx_in->MakeKey(key.c_str(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
- \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", keylength, keylength);
- ctx_out->MakeKey(key.c_str(), "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
- \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", keylength, keylength);
- }
- }
- }