keylength = key.length();
if (!(keylength == 16 || keylength == 24 || keylength == 32))
{
+ WriteOpers("\2ERROR\2: Key length for encryptionkey is not 16, 24 or 32 bytes in length!");
log(DEBUG,"Key length not 16, 24 or 32 characters!");
}
else
{
+ std::string SName = myhost;
+ if (InboundServerName != "")
+ {
+ SName = InboundServerName;
+ }
+ WriteOpers("\2AES\2: Initialized %d bit encryption to server %s",keylength*8,SName.c_str());
ctx->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);
}
{
if (x->Name == this->myhost)
{
+ if (x->EncryptionKey != "")
+ {
+ this->WriteLine("AES "+Srv->GetServerName());
+ this->InitAES(x->EncryptionKey);
+ }
/* found who we're supposed to be connecting to, send the neccessary gubbins. */
this->WriteLine("SERVER "+Srv->GetServerName()+" "+x->SendPass+" 0 :"+Srv->GetServerDescription());
return true;
char* data = this->Read();
if (data)
{
- Srv->Log(DEBUG,"m_spanningtree: READ");
this->in_buffer += data;
/* While there is at least one new line in the buffer,
* do something useful (we hope!) with it.
int nbytes = from64tobits(out, ret.c_str(), 1024);
log(DEBUG,"m_spanningtree: decrypt %d bytes",nbytes);
ctx->Decrypt(out, result, nbytes, 0);
+ for (int t = 0; t < nbytes; t++)
+ if (result[t] == '\7') result[t] = 0;
ret = result;
}
if (!this->ProcessLine(ret))
while (line.length() % this->keylength != 0)
{
// pad it to be a multiple of the key length
- line = line + "\n";
+ line = line + "\7";
}
}
ctx->Encrypt(line.c_str(), result, line.length(),0);
command = params[0];
params.pop_front();
}
+
+ if ((!this->ctx) && (command == "AES"))
+ {
+ std::string sserv = params[0];
+ for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
+ {
+ if ((x->EncryptionKey != "") && (x->Name == sserv))
+ {
+ this->InitAES(x->EncryptionKey);
+ }
+ }
+ return true;
+ }
switch (this->LinkState)
{
else if (command == "ENDBURST")
{
this->bursting = false;
- std::string sserv = this->myhost;
- if (this->InboundServerName != "")
- sserv = this->InboundServerName;
- for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
- {
- if ((x->EncryptionKey != "") && (x->Name == sserv))
- {
- this->InitAES(x->EncryptionKey);
- }
- }
return true;
}
else