From 29c1c6412bb7ea7e96b5692c0e254b11edb25355 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 19 Dec 2005 14:51:40 +0000 Subject: Encryption debug git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2570 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 568dbf310..49493b423 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -578,6 +578,7 @@ class TreeSocket : public InspSocket return; ctx = new AES(); + 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)) @@ -1164,6 +1165,7 @@ class TreeSocket : public InspSocket { char out[1024]; char result[1024]; + log(DEBUG,"Original string '%s'",ret.c_str()); int nbytes = from64tobits(out, ret.c_str(), 1024); log(DEBUG,"m_spanningtree: decrypt %d bytes",nbytes); ctx->Decrypt(out, result, nbytes, 0); @@ -1181,14 +1183,18 @@ class TreeSocket : public InspSocket int WriteLine(std::string line) { log(DEBUG,"OUT: %s",line.c_str()); - if (ctx) + if (this->ctx) { + log(DEBUG,"AES context"); char result[1024]; char result64[1024]; - while (line.length() % this->keylength != 0) + if (this->keylength) { - // pad it to be a multiple of the key length - line = line + "\0"; + while (line.length() % this->keylength != 0) + { + // pad it to be a multiple of the key length + line = line + "\0"; + } } ctx->Encrypt(line.c_str(), result, line.length(),0); to64frombits((unsigned char*)result64, -- cgit v1.2.3