From e59123a3a13f9ffb3af28e85295b6a14c5c8aaca Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sat, 18 Dec 2010 16:14:27 +0200 Subject: [PATCH] =?utf8?q?=D0=A3=20=D0=BF=D0=BB=D0=B0=D0=B3=D1=96=D0=BD?= =?utf8?q?=D1=96=20=D0=BF=D1=96=D0=B4=D1=82=D1=80=D0=B8=D0=BC=D0=BA=D0=B8?= =?utf8?q?=20rlm=5Fstg=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B8=20=D1=88?= =?utf8?q?=D0=B8=D1=84=D1=80=D1=83=D0=B2=D0=B0=D0=BD=D0=BD=D1=8F=20=D0=B2?= =?utf8?q?=D0=B8=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=96=20=D1=83=20=D0=B7?= =?utf8?q?=D0=B2=D0=B8=D1=87=D0=B0=D0=B9=D0=BD=D1=96=20=D1=84=D1=83=D0=BD?= =?utf8?q?=D0=BA=D1=86=D1=96=D1=97,=20=D0=BF=D1=80=D0=B8=D0=B1=D1=80=D0=B0?= =?utf8?q?=D0=BD=D0=BE=20=D0=BC=D1=83=D1=81=D1=82=D1=96=20=D0=BC=D0=B5?= =?utf8?q?=D1=82=D0=BE=D0=B4=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../stargazer/plugins/other/radius/radius.cpp | 71 +++++++++---------- .../stargazer/plugins/other/radius/radius.h | 7 -- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/projects/stargazer/plugins/other/radius/radius.cpp b/projects/stargazer/plugins/other/radius/radius.cpp index 4dd18c46..c0b70e72 100644 --- a/projects/stargazer/plugins/other/radius/radius.cpp +++ b/projects/stargazer/plugins/other/radius/radius.cpp @@ -34,6 +34,10 @@ extern volatile const time_t stgTime; +void InitEncrypt(BLOWFISH_CTX * ctx, const string & password); +void Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8); +void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8); + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -208,14 +212,6 @@ uint16_t RADIUS::GetStopPosition() const return 20; } //----------------------------------------------------------------------------- -void RADIUS::SetUserNotifier(user_iter) -{ -} -//----------------------------------------------------------------------------- -void RADIUS::UnSetUserNotifier(user_iter) -{ -} -//----------------------------------------------------------------------------- int RADIUS::PrepareNet() { sock = socket(AF_INET, SOCK_DGRAM, 0); @@ -595,34 +591,6 @@ packet->packetType = RAD_ACCEPT_PACKET; return 0; } //----------------------------------------------------------------------------- -void RADIUS::InitEncrypt(BLOWFISH_CTX * ctx, const string & password) -{ -unsigned char keyL[RAD_PASSWORD_LEN]; // Пароль для шифровки -memset(keyL, 0, RAD_PASSWORD_LEN); -strncpy((char *)keyL, password.c_str(), RAD_PASSWORD_LEN); -Blowfish_Init(ctx, keyL, RAD_PASSWORD_LEN); -} -//----------------------------------------------------------------------------- -void RADIUS::Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8) -{ -// len8 - длина в 8-ми байтовых блоках -if (dst != src) - memcpy(dst, src, len8 * 8); - -for (int i = 0; i < len8; i++) - Blowfish_Encrypt(ctx, (uint32_t *)(dst + i*8), (uint32_t *)(dst + i*8 + 4)); -} -//----------------------------------------------------------------------------- -void RADIUS::Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8) -{ -// len8 - длина в 8-ми байтовых блоках -if (dst != src) - memcpy(dst, src, len8 * 8); - -for (int i = 0; i < len8; i++) - Blowfish_Decrypt(ctx, (uint32_t *)(dst + i*8), (uint32_t *)(dst + i*8 + 4)); -} -//----------------------------------------------------------------------------- void RADIUS::PrintServices(const list & svcs) { for_each(svcs.begin(), svcs.end(), Printer()); @@ -679,3 +647,34 @@ if (res == 0) // Timeout return true; } +//----------------------------------------------------------------------------- +inline +void InitEncrypt(BLOWFISH_CTX * ctx, const string & password) +{ +unsigned char keyL[RAD_PASSWORD_LEN]; // Пароль для шифровки +memset(keyL, 0, RAD_PASSWORD_LEN); +strncpy((char *)keyL, password.c_str(), RAD_PASSWORD_LEN); +Blowfish_Init(ctx, keyL, RAD_PASSWORD_LEN); +} +//----------------------------------------------------------------------------- +inline +void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8) +{ +// len8 - длина в 8-ми байтовых блоках +if (dst != src) + memcpy(dst, src, len8 * 8); + +for (int i = 0; i < len8; i++) + Blowfish_Encrypt(ctx, (uint32_t *)(dst + i*8), (uint32_t *)(dst + i*8 + 4)); +} +//----------------------------------------------------------------------------- +inline +void Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8) +{ +// len8 - длина в 8-ми байтовых блоках +if (dst != src) + memcpy(dst, src, len8 * 8); + +for (int i = 0; i < len8; i++) + Blowfish_Decrypt(ctx, (uint32_t *)(dst + i*8), (uint32_t *)(dst + i*8 + 4)); +} diff --git a/projects/stargazer/plugins/other/radius/radius.h b/projects/stargazer/plugins/other/radius/radius.h index e13a7a7f..69d3b9d9 100644 --- a/projects/stargazer/plugins/other/radius/radius.h +++ b/projects/stargazer/plugins/other/radius/radius.h @@ -113,10 +113,6 @@ private: int PrepareNet(); int FinalizeNet(); - void InitEncrypt(BLOWFISH_CTX * ctx, const string & password); - void Decrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8); - void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8); - int Send(const RAD_PACKET & packet, struct sockaddr_in * outerAddr); int RecvData(RAD_PACKET * packet, struct sockaddr_in * outerAddr); int ProcessData(RAD_PACKET * packet); @@ -134,9 +130,6 @@ private: bool CanAcctService(const std::string & svc) const; bool IsAllowedService(const std::string & svc) const; - void SetUserNotifier(user_iter u); - void UnSetUserNotifier(user_iter u); - bool WaitPackets(int sd) const; void PrintServices(const std::list & svcs); -- 2.44.2