namespace
{
PLUGIN_CREATOR<AUTH_IA> iac;
-
-void InitEncrypt(BLOWFISH_CTX * ctx, const std::string & password);
-void Decrypt(BLOWFISH_CTX * ctx, void * dst, const void * src, size_t len8);
-void Encrypt(BLOWFISH_CTX * ctx, void * dst, const void * src, size_t len8);
}
extern "C" PLUGIN * GetPlugin();
userTimeout(0),
port(0),
errorStr(),
- freeMbShowType(freeMbCash)
+ freeMbShowType(freeMbCash),
+ logProtocolErrors(false)
{
}
//-----------------------------------------------------------------------------
printfd(__FILE__, "Cannot parse parameter 'UserTimeout'\n");
return -1;
}
+///////////////////////////
+pv.param = "LogProtocolErrors";
+pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
+if (pvi == s.moduleParams.end())
+ logProtocolErrors = false;
+else if (ParseYesNo(pvi->value[0], &logProtocolErrors))
+ {
+ errorStr = "Cannot parse parameter \'LogProtocolErrors\': " + errorStr;
+ printfd(__FILE__, "Cannot parse parameter 'LogProtocolErrors'\n");
+ return -1;
+ }
/////////////////////////////////////////////////////////////
std::string freeMbType;
int n = 0;
gettimeofday(&phaseTime, NULL);
}
//-----------------------------------------------------------------------------
-void IA_PHASE::SetPhase5()
-{
-#ifdef IA_PHASE_DEBUG
-WritePhaseChange(5);
-#endif
-phase = 5;
-gettimeofday(&phaseTime, NULL);
-}
-//-----------------------------------------------------------------------------
int IA_PHASE::GetPhase() const
{
return phase;
onDelUserNotifier(*this),
logger(GetPluginLogger(GetStgLogger(), "auth_ia"))
{
-InitEncrypt(&ctxS, "pr7Hhen");
+InitContext("pr7Hhen", 7, &ctxS);
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
if (dataLen > 256)
return -1;
+uint32_t sip = outerAddr.sin_addr.s_addr;
+uint16_t sport = htons(outerAddr.sin_port);
+
int protoVer;
-if (CheckHeader(buffer, &protoVer))
+if (CheckHeader(buffer, sip, &protoVer))
return -1;
char login[PASSWD_LEN]; //TODO why PASSWD_LEN ?
memset(login, 0, PASSWD_LEN);
-Decrypt(&ctxS, login, buffer + 8, PASSWD_LEN / 8);
-
-uint32_t sip = outerAddr.sin_addr.s_addr;
-uint16_t sport = htons(outerAddr.sin_port);
+DecryptString(login, buffer + 8, PASSWD_LEN, &ctxS);
USER_PTR user;
if (users->FindByName(login, &user))
login,
inet_ntostring(sip).c_str());
printfd(__FILE__, "User '%s' NOT found!\n", login);
- SendError(sip, sport, protoVer, "îÅÐÒÁ×ÉÌØÎÙÊ ÌÏÇÉÎ!");
+ SendError(sip, sport, protoVer, IconvString("Неправильный логин.", "utf8", "koi8-ru"));
return -1;
}
if (user->GetProperty().disabled.Get())
{
logger("Cannont authorize '%s', user is disabled.", login);
- SendError(sip, sport, protoVer, "õÞÅÔÎÁÑ ÚÁÐÉÓØ ÚÁÂÌÏËÉÒÏ×ÁÎÁ");
+ SendError(sip, sport, protoVer, IconvString("Учетная запись заблокирована.", "utf8", "koi8-ru"));
return 0;
}
if (user->GetProperty().passive.Get())
{
logger("Cannont authorize '%s', user is passive.", login);
- SendError(sip, sport, protoVer, "õÞÅÔÎÁÑ ÚÁÐÉÓØ ÚÁÍÏÒÏÖÅÎÁ");
+ SendError(sip, sport, protoVer, IconvString("Учетная запись заморожена.", "utf8", "koi8-ru"));
return 0;
}
user->GetLogin().c_str(), inet_ntostring(sip).c_str());
logger("User %s. IP address is incorrect. IP %s",
user->GetLogin().c_str(), inet_ntostring(sip).c_str());
- SendError(sip, sport, protoVer, "ðÏÌØÚÏ×ÁÔÅÌØ ÎÅ ÏÐÏÚÎÁÎ! ðÒÏ×ÅÒØÔÅ IP ÁÄÒÅÓ.");
+ SendError(sip, sport, protoVer, IconvString("Пользователь не опознан. Проверьте IP-адрес.", "utf8", "koi8-ru"));
return 0;
}
return PacketProcessor(buffer, dataLen, sip, sport, protoVer, user);
}
//-----------------------------------------------------------------------------
-int AUTH_IA::CheckHeader(const char * buffer, int * protoVer)
+int AUTH_IA::CheckHeader(const char * buffer, uint32_t sip, int * protoVer)
{
if (strncmp(IA_ID, buffer, strlen(IA_ID)) != 0)
{
- //SendError(userIP, updateMsg);
printfd(__FILE__, "update needed - IA_ID\n");
- //SendError(userIP, "Incorrect header!");
+ if (iaSettings.LogProtocolErrors())
+ logger("IP: %s. Header: invalid packed signature.", inet_ntostring(sip).c_str());
return -1;
}
if (buffer[6] != 0) //proto[0] shoud be 0
{
printfd(__FILE__, "update needed - PROTO major: %d\n", buffer[6]);
- //SendError(userIP, updateMsg);
+ if (iaSettings.LogProtocolErrors())
+ logger("IP: %s. Header: invalid protocol major version: %d.", inet_ntostring(sip).c_str(), buffer[6]);
return -1;
}
if (buffer[7] < 6)
{
// need update
- //SendError(userIP, updateMsg);
printfd(__FILE__, "update needed - PROTO minor: %d\n", buffer[7]);
+ if (iaSettings.LogProtocolErrors())
+ logger("IP: %s. Header: invalid protocol minor version: %d.", inet_ntostring(sip).c_str(), buffer[7]);
return -1;
}
else
//-----------------------------------------------------------------------------
int AUTH_IA::Timeouter()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::map<uint32_t, IA_USER>::iterator it;
it = ip2user.begin();
-uint32_t sip;
while (it != ip2user.end())
{
- sip = it->first;
+ uint32_t sip = it->first;
static UTIME currTime;
gettimeofday(&currTime, NULL);
if ((it->second.phase.GetPhase() == 2)
&& (currTime - it->second.phase.GetTime()) > iaSettings.GetUserDelay())
{
+ if (iaSettings.LogProtocolErrors())
+ logger("User '%s'. Protocol version: %d. Phase 2: connect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay());
it->second.phase.SetPhase1();
printfd(__FILE__, "Phase changed from 2 to 1. Reason: timeout\n");
ip2user.erase(it++);
if ((currTime - it->second.phase.GetTime()) > iaSettings.GetUserTimeout())
{
+ if (iaSettings.LogProtocolErrors())
+ logger("User '%s'. Protocol version: %d. Phase 3: alive timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserTimeout());
users->Unauthorize(it->second.user->GetLogin(), this);
ip2user.erase(it++);
continue;
if ((it->second.phase.GetPhase() == 4)
&& ((currTime - it->second.phase.GetTime()) > iaSettings.GetUserDelay()))
{
+ if (iaSettings.LogProtocolErrors())
+ logger("User '%s'. Protocol version: %d. Phase 4: disconnect request timeout (%f > %d).", it->second.login.c_str(), it->second.protoVer, (currTime - it->second.phase.GetTime()).AsDouble(), iaSettings.GetUserDelay());
it->second.phase.SetPhase3();
printfd(__FILE__, "Phase changed from 4 to 3. Reason: timeout\n");
}
std::string login(user->GetLogin());
const size_t offset = LOGIN_LEN + 2 + 6; // LOGIN_LEN + sizeOfMagic + sizeOfVer;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::map<uint32_t, IA_USER>::iterator it(ip2user.find(sip));
if (it == ip2user.end())
userPtr->GetLogin().c_str(),
inet_ntostring(sip).c_str(),
login.c_str());
- SendError(sip, sport, protoVer, "÷ÁÛ IP ÁÄÒÅÓ ÕÖÅ ÉÓÐÏÌØÚÕÅÔÓÑ!");
+ SendError(sip, sport, protoVer, IconvString("IP-адрес уже сипользуется.", "utf8", "koi8-ru"));
return 0;
}
}
it->second.user->GetLogin().c_str(),
inet_ntostring(sip).c_str(),
user->GetLogin().c_str());
- SendError(sip, sport, protoVer, "÷ÁÛ IP ÁÄÒÅÓ ÕÖÅ ÉÓÐÏÌØÚÕÅÔÓÑ!");
+ SendError(sip, sport, protoVer, IconvString("IP-адрес уже используется.", "utf8", "koi8-ru"));
return 0;
}
if (iaUser->password != user->GetProperty().password.Get())
{
- InitEncrypt(&iaUser->ctx, user->GetProperty().password.Get());
+ const std::string & password = user->GetProperty().password.Get();
+ InitContext(password.c_str(), password.length(), &iaUser->ctx);
iaUser->password = user->GetProperty().password.Get();
}
-Decrypt(&iaUser->ctx, static_cast<char *>(buff) + offset, static_cast<char *>(buff) + offset, (dataLen - offset) / 8);
+DecryptString(static_cast<char *>(buff) + offset, static_cast<char *>(buff) + offset, (dataLen - offset), &iaUser->ctx);
char packetName[IA_MAX_TYPE_LEN];
strncpy(packetName, static_cast<char *>(buff) + offset + 4, IA_MAX_TYPE_LEN);
std::map<std::string, int>::iterator pi(packetTypes.find(packetName));
if (pi == packetTypes.end())
{
- SendError(sip, sport, protoVer, "îÅÐÒÁ×ÉÌØÎÙÊ ÌÏÇÉÎ ÉÌÉ ÐÁÒÏÌØ!");
+ SendError(sip, sport, protoVer, IconvString("Неправильный логин или пароль.", "utf8", "koi8-ru"));
printfd(__FILE__, "Login or password is wrong!\n");
logger("User's connect failed. User: '%s', ip %s. Wrong login or password",
login.c_str(),
login.c_str(),
inet_ntostring(user->GetCurrIP()).c_str(),
inet_ntostring(sip).c_str());
- SendError(sip, sport, protoVer, "÷ÁÛ ÌÏÇÉÎ ÕÖÅ ÉÓÐÏÌØÚÕÅÔÓÑ!");
+ SendError(sip, sport, protoVer, IconvString("Логин уже используется.", "utf8", "koi8-ru"));
ip2user.erase(it);
return 0;
}
std::map<uint32_t, IA_USER>::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = ip2user.find(ip);
if (it == ip2user.end())
{
std::map<uint32_t, IA_USER>::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = ip2user.find(ip);
if (it == ip2user.end())
{
char buffer[256];
memcpy(buffer, &info, sizeof(INFO_6));
-Encrypt(&user.ctx, buffer, buffer, len / 8);
+EncryptString(buffer, buffer, len, &user.ctx);
return Send(ip, iaSettings.GetUserPort(), buffer, len);
}
//-----------------------------------------------------------------------------
char buffer[300];
memcpy(buffer, &info, sizeof(INFO_7));
-Encrypt(&user.ctx, buffer, buffer, len / 8);
+EncryptString(buffer, buffer, len, &user.ctx);
return Send(ip, iaSettings.GetUserPort(), buffer, len);
}
//-----------------------------------------------------------------------------
char buffer[1500];
memcpy(buffer, &info, sizeof(INFO_8));
-Encrypt(&user.ctx, buffer, buffer, len / 8);
+EncryptString(buffer, buffer, len, &user.ctx);
return Send(ip, user.port, buffer, len);
}
//-----------------------------------------------------------------------------
#ifdef ARCH_BE
SwapBytes(connSyn->dirs);
#endif
-int ret = Process_CONN_SYN_6((CONN_SYN_6*)connSyn, iaUser, sip);
+int ret = Process_CONN_SYN_6(reinterpret_cast<CONN_SYN_6 *>(connSyn), iaUser, sip);
enabledDirs = connSyn->dirs;
return ret;
}
else
{
errorStr = iaUser->user->GetStrError();
+ if (iaSettings.LogProtocolErrors())
+ logger("IP: %s. User '%s'. Protocol version: %d. CONN_ACK: phase 2, authorization error ('%s').", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, errorStr.c_str());
iaUser->phase.SetPhase1();
ip2user.erase(sip);
printfd(__FILE__, "Phase changed from 2 to 1. Reason: failed to authorize user\n");
}
}
printfd(__FILE__, "Invalid phase or control number. Phase: %d. Control number: %d\n", iaUser->phase.GetPhase(), connAck->rnd);
+if (iaSettings.LogProtocolErrors())
+ {
+ if (iaUser->phase.GetPhase() != 2)
+ logger("IP: %s. User '%s'. Protocol version: %d. CONN_ACK: invalid phase, expected 2, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, iaUser->phase.GetPhase());
+ if (connAck->rnd != iaUser->rnd + 1)
+ logger("IP: %s. User '%s'. Protocol version: %d. CONN_ACK: invalid control number, expected %d, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, (iaUser->rnd + 1), connAck->rnd);
+ }
return -1;
}
//-----------------------------------------------------------------------------
else
{
errorStr = iaUser->user->GetStrError();
+ if (iaSettings.LogProtocolErrors())
+ logger("IP: %s. User '%s'. Protocol version: %d. CONN_ACK: phase 2, authorization error ('%s').", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, errorStr.c_str());
iaUser->phase.SetPhase1();
ip2user.erase(sip);
printfd(__FILE__, "Phase changed from 2 to 1. Reason: failed to authorize user\n");
}
}
printfd(__FILE__, "Invalid phase or control number. Phase: %d. Control number: %d\n", iaUser->phase.GetPhase(), connAck->rnd);
+if (iaSettings.LogProtocolErrors())
+ {
+ if (iaUser->phase.GetPhase() != 2)
+ logger("IP: %s. User '%s'. Protocol version: %d. CONN_ACK: invalid phase, expected 2, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, iaUser->phase.GetPhase());
+ if (connAck->rnd != iaUser->rnd + 1)
+ logger("IP: %s. User '%s'. Protocol version: %d. CONN_ACK: invalid control number, expected %d, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, (iaUser->rnd + 1), connAck->rnd);
+ }
return -1;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
-int AUTH_IA::Process_DISCONN_SYN_6(DISCONN_SYN_6 *, IA_USER * iaUser, uint32_t)
+int AUTH_IA::Process_DISCONN_SYN_6(DISCONN_SYN_6 *, IA_USER * iaUser, uint32_t sip)
{
printfd(__FILE__, "DISCONN_SYN_6\n");
if (iaUser->phase.GetPhase() != 3)
{
+ if (iaSettings.LogProtocolErrors())
+ logger("IP: %s. User '%s'. Protocol version: %d. DISCONN_SYN: invalid phase, expected 3, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, iaUser->phase.GetPhase());
printfd(__FILE__, "Invalid phase. Expected 3, actual %d\n", iaUser->phase.GetPhase());
errorStr = "Incorrect request DISCONN_SYN";
return -1;
return Process_DISCONN_SYN_6(disconnSyn, iaUser, sip);
}
//-----------------------------------------------------------------------------
-int AUTH_IA::Process_DISCONN_SYN_8(DISCONN_SYN_8 *, IA_USER * iaUser, uint32_t)
+int AUTH_IA::Process_DISCONN_SYN_8(DISCONN_SYN_8 *, IA_USER * iaUser, uint32_t sip)
{
if (iaUser->phase.GetPhase() != 3)
{
+ if (iaSettings.LogProtocolErrors())
+ logger("IP: %s. User '%s'. Protocol version: %d. DISCONN_SYN: invalid phase, expected 3, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, iaUser->phase.GetPhase());
errorStr = "Incorrect request DISCONN_SYN";
printfd(__FILE__, "Invalid phase. Expected 3, actual %d\n", iaUser->phase.GetPhase());
return -1;
//-----------------------------------------------------------------------------
int AUTH_IA::Process_DISCONN_ACK_6(DISCONN_ACK_6 * disconnAck,
IA_USER * iaUser,
- uint32_t,
+ uint32_t sip,
std::map<uint32_t, IA_USER>::iterator)
{
#ifdef ARCH_BE
printfd(__FILE__, "DISCONN_ACK_6\n");
if (!((iaUser->phase.GetPhase() == 4) && (disconnAck->rnd == iaUser->rnd + 1)))
{
+ if (iaSettings.LogProtocolErrors())
+ {
+ if (iaUser->phase.GetPhase() != 4)
+ logger("IP: %s. User '%s'. Protocol version: %d. DISCONN_ACK: invalid phase, expected 4, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, iaUser->phase.GetPhase());
+ if (disconnAck->rnd != iaUser->rnd + 1)
+ logger("IP: %s. User '%s'. Protocol version: %d. DISCONN_ACK: invalid control number, expected %d, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, (iaUser->rnd + 1), disconnAck->rnd);
+ }
printfd(__FILE__, "Invalid phase or control number. Phase: %d. Control number: %d\n", iaUser->phase.GetPhase(), disconnAck->rnd);
return -1;
}
return Process_DISCONN_ACK_6(disconnAck, iaUser, sip, it);
}
//-----------------------------------------------------------------------------
-int AUTH_IA::Process_DISCONN_ACK_8(DISCONN_ACK_8 * disconnAck, IA_USER * iaUser, uint32_t, std::map<uint32_t, IA_USER>::iterator)
+int AUTH_IA::Process_DISCONN_ACK_8(DISCONN_ACK_8 * disconnAck, IA_USER * iaUser, uint32_t sip, std::map<uint32_t, IA_USER>::iterator)
{
#ifdef ARCH_BE
SwapBytes(disconnAck->len);
printfd(__FILE__, "DISCONN_ACK_8\n");
if (!((iaUser->phase.GetPhase() == 4) && (disconnAck->rnd == iaUser->rnd + 1)))
{
+ if (iaSettings.LogProtocolErrors())
+ {
+ if (iaUser->phase.GetPhase() != 4)
+ logger("IP: %s. User '%s'. Protocol version: %d. DISCONN_ACK: invalid phase, expected 4, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, iaUser->phase.GetPhase());
+ if (disconnAck->rnd != iaUser->rnd + 1)
+ logger("IP: %s. User '%s'. Protocol version: %d. DISCONN_ACK: invalid control number, expected %d, got %d.", inet_ntostring(sip).c_str(), iaUser->login.c_str(), iaUser->protoVer, (iaUser->rnd + 1), disconnAck->rnd);
+ }
printfd(__FILE__, "Invalid phase or control number. Phase: %d. Control number: %d\n", iaUser->phase.GetPhase(), disconnAck->rnd);
return -1;
}
SwapBytes(connSynAck6.aliveDelay);
#endif
-Encrypt(&iaUser->ctx, (char*)&connSynAck6, (char*)&connSynAck6, Min8(sizeof(CONN_SYN_ACK_6))/8);
+EncryptString((char*)&connSynAck6, (char*)&connSynAck6, Min8(sizeof(CONN_SYN_ACK_6)), &iaUser->ctx);
return Send(sip, iaSettings.GetUserPort(), (char*)&connSynAck6, Min8(sizeof(CONN_SYN_ACK_6)));;
}
//-----------------------------------------------------------------------------
SwapBytes(connSynAck8.aliveDelay);
#endif
-Encrypt(&iaUser->ctx, (char*)&connSynAck8, (char*)&connSynAck8, Min8(sizeof(CONN_SYN_ACK_8))/8);
+EncryptString((char*)&connSynAck8, (char*)&connSynAck8, Min8(sizeof(CONN_SYN_ACK_8)), &iaUser->ctx);
return Send(sip, iaUser->port, (char*)&connSynAck8, Min8(sizeof(CONN_SYN_ACK_8)));
}
//-----------------------------------------------------------------------------
}
#endif
-Encrypt(&(iaUser->ctx), (char*)&aliveSyn6, (char*)&aliveSyn6, Min8(sizeof(aliveSyn6))/8);
+EncryptString((char*)&aliveSyn6, (char*)&aliveSyn6, Min8(sizeof(aliveSyn6)), &iaUser->ctx);
return Send(sip, iaSettings.GetUserPort(), (char*)&aliveSyn6, Min8(sizeof(aliveSyn6)));
}
//-----------------------------------------------------------------------------
}
#endif
-Encrypt(&(iaUser->ctx), (char*)&aliveSyn8, (char*)&aliveSyn8, Min8(sizeof(aliveSyn8))/8);
+EncryptString((char*)&aliveSyn8, (char*)&aliveSyn8, Min8(sizeof(aliveSyn8)), &iaUser->ctx);
return Send(sip, iaUser->port, (char*)&aliveSyn8, Min8(sizeof(aliveSyn8)));
}
//-----------------------------------------------------------------------------
SwapBytes(disconnSynAck6.rnd);
#endif
-Encrypt(&iaUser->ctx, (char*)&disconnSynAck6, (char*)&disconnSynAck6, Min8(sizeof(disconnSynAck6))/8);
+EncryptString((char*)&disconnSynAck6, (char*)&disconnSynAck6, Min8(sizeof(disconnSynAck6)), &iaUser->ctx);
return Send(sip, iaSettings.GetUserPort(), (char*)&disconnSynAck6, Min8(sizeof(disconnSynAck6)));
}
//-----------------------------------------------------------------------------
SwapBytes(disconnSynAck8.rnd);
#endif
-Encrypt(&iaUser->ctx, (char*)&disconnSynAck8, (char*)&disconnSynAck8, Min8(sizeof(disconnSynAck8))/8);
+EncryptString((char*)&disconnSynAck8, (char*)&disconnSynAck8, Min8(sizeof(disconnSynAck8)), &iaUser->ctx);
return Send(sip, iaUser->port, (char*)&disconnSynAck8, Min8(sizeof(disconnSynAck8)));
}
//-----------------------------------------------------------------------------
SwapBytes(fin6.len);
#endif
-Encrypt(&iaUser->ctx, (char*)&fin6, (char*)&fin6, Min8(sizeof(fin6))/8);
+EncryptString((char*)&fin6, (char*)&fin6, Min8(sizeof(fin6)), &iaUser->ctx);
users->Unauthorize(iaUser->login, this);
SwapBytes(fin8.len);
#endif
-Encrypt(&iaUser->ctx, (char*)&fin8, (char*)&fin8, Min8(sizeof(fin8))/8);
+EncryptString((char*)&fin8, (char*)&fin8, Min8(sizeof(fin8)), &iaUser->ctx);
users->Unauthorize(iaUser->login, this);
return res;
}
-namespace
-{
-//-----------------------------------------------------------------------------
-inline
-void InitEncrypt(BLOWFISH_CTX * ctx, const std::string & password)
-{
-unsigned char keyL[PASSWD_LEN];
-memset(keyL, 0, PASSWD_LEN);
-strncpy((char *)keyL, password.c_str(), PASSWD_LEN);
-Blowfish_Init(ctx, keyL, PASSWD_LEN);
-}
-//-----------------------------------------------------------------------------
-inline
-void Decrypt(BLOWFISH_CTX * ctx, void * dst, const void * src, size_t len8)
-{
-for (size_t i = 0; i < len8; i++)
- DecodeString(static_cast<char *>(dst) + i * 8, static_cast<const char *>(src) + i * 8, ctx);
-}
-//-----------------------------------------------------------------------------
-inline
-void Encrypt(BLOWFISH_CTX * ctx, void * dst, const void * src, size_t len8)
-{
-for (size_t i = 0; i < len8; i++)
- EncodeString(static_cast<char *>(dst) + i * 8, static_cast<const char *>(src) + i * 8, ctx);
-}
-//-----------------------------------------------------------------------------
-}