aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn0n4m3 <none@none>2010-04-11 11:11:32 +0400
committern0n4m3 <none@none>2010-04-11 11:11:32 +0400
commit8db7c06e6b16728eca499d29bb136980d714313b (patch)
treea06f96173df6f3f23aa2c5a51effa1fd69bd3dcd
parent36e13c1d1c615d89c1e18add73411c0525ecbf08 (diff)
Fix Auth on server also some fixes and cleanups. Big thx to TOM_RUS.
--HG-- branch : trunk
-rw-r--r--src/game/BattleGroundMgr.cpp4
-rw-r--r--src/game/DBCEnums.h8
-rw-r--r--src/game/DBCStructure.h20
-rw-r--r--src/game/DBCfmt.h4
-rw-r--r--src/game/Item.cpp4
-rw-r--r--src/game/Mail.cpp2
-rw-r--r--src/game/MiscHandler.cpp21
-rw-r--r--src/game/Opcodes.h22
-rw-r--r--src/game/Player.cpp25
-rw-r--r--src/game/Player.h6
-rw-r--r--src/game/PlayerDump.cpp4
-rw-r--r--src/game/Unit.cpp8
-rw-r--r--src/shared/Auth/AuthCrypt.cpp6
-rw-r--r--src/shared/Auth/BigNumber.cpp5
-rw-r--r--src/shared/Auth/BigNumber.h2
-rw-r--r--src/shared/Auth/Hmac.cpp9
-rw-r--r--src/shared/Auth/Hmac.h1
-rw-r--r--src/shared/Auth/SARC4.cpp8
-rw-r--r--src/shared/Auth/SARC4.h4
19 files changed, 106 insertions, 57 deletions
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index 98feec46da0..831ceeef761 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -1705,8 +1705,8 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
//check values from DB
if (MaxPlayersPerTeam == 0 || MinPlayersPerTeam == 0 || MinPlayersPerTeam > MaxPlayersPerTeam)
{
- MaxPlayersPerTeam = bl->maxplayersperteam;
- MinPlayersPerTeam = bl->maxplayersperteam / 2;
+ MinPlayersPerTeam = 0; // by default now expected strong full bg requirement
+ MaxPlayersPerTeam = 40;
}
if (MinLvl == 0 || MaxLvl == 0 || MinLvl > MaxLvl)
{
diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h
index 3a3a46fdfaa..ba38e63fb5d 100644
--- a/src/game/DBCEnums.h
+++ b/src/game/DBCEnums.h
@@ -209,8 +209,12 @@ enum AchievementCriteriaTypes
// 0..115 => 116 criteria types total
ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115,
ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS = 119,
- // 0..119 => 120 criteria types total
- ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 120,
+ // 120
+ // 121
+ // 122
+ // 123
+ // 0..123 => 124 criteria types total
+ ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 124,
};
enum AreaFlags
diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h
index 1e6a349c2ea..66a049b4c49 100644
--- a/src/game/DBCStructure.h
+++ b/src/game/DBCStructure.h
@@ -596,13 +596,13 @@ struct BattlemasterListEntry
uint32 id; // 0
int32 mapid[8]; // 1-8 mapid
uint32 type; // 9 (3 - BG, 4 - arena)
- uint32 maxplayersperteam; // 10
- //uint32 unk1; // 11 (0 or 1)
- char* name[16]; // 12-27
- // 28 string flag, unused
- // 29 unused
- //uint32 unk2; // 30 new 3.1
-
+ //uint32 canJoinAsGroup; // 10 (0 or 1)
+ char* name[16]; // 11-26
+ //uint32 nameFlags // 27 string flag, unused
+ //uint32 maxGroupSize // 28 maxGroupSize, used for checking if queue as group
+ //uint32 HolidayWorldStateId; // 29 new 3.1
+ //uint32 MinLevel; // 30
+ //uint32 SomeLevel; // 31, may be max level
};
#define MAX_OUTFIT_ITEMS 24
@@ -1434,8 +1434,8 @@ struct SpellEntry
int32 EquippedItemInventoryTypeMask; // 70 m_equippedItemInvTypes (mask)
uint32 Effect[MAX_SPELL_EFFECTS]; // 71-73 m_effect
int32 EffectDieSides[MAX_SPELL_EFFECTS]; // 74-76 m_effectDieSides
- int32 EffectBaseDice[MAX_SPELL_EFFECTS]; // 77-79 m_effectBaseDice
- float EffectDicePerLevel[MAX_SPELL_EFFECTS]; // 80-82 m_effectDicePerLevel
+ //int32 EffectBaseDice[MAX_SPELL_EFFECTS]; // 77-79 m_effectBaseDice
+ //float EffectDicePerLevel[MAX_SPELL_EFFECTS]; // 80-82 m_effectDicePerLevel
float EffectRealPointsPerLevel[MAX_SPELL_EFFECTS]; // 83-85 m_effectRealPointsPerLevel
int32 EffectBasePoints[MAX_SPELL_EFFECTS]; // 86-88 m_effectBasePoints (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints)
uint32 EffectMechanic[MAX_SPELL_EFFECTS]; // 89-91 m_effectMechanic
@@ -1525,7 +1525,7 @@ struct SpellEntry
//uint32 spellDescriptionVariableID; // 238 3.2.0
*/
// helpers
- int32 CalculateSimpleValue(uint8 eff) const { return EffectBasePoints[eff]+int32(EffectBaseDice[eff]); }
+ int32 CalculateSimpleValue(uint8 eff) const { return EffectBasePoints[eff]+int32(1); }
private:
// prevent creating custom entries (copy data from original in fact)
diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h
index 104099e83d9..98a71f3bbce 100644
--- a/src/game/DBCfmt.h
+++ b/src/game/DBCfmt.h
@@ -30,7 +30,7 @@ const char AreaTriggerEntryfmt[]="niffffffff";
const char AuctionHouseEntryfmt[]="niiixxxxxxxxxxxxxxxxx";
const char BankBagSlotPricesEntryfmt[]="ni";
const char BarberShopStyleEntryfmt[]="nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii";
-const char BattlemasterListEntryfmt[]="niiiiiiiiiixssssssssssssssssxxx";
+const char BattlemasterListEntryfmt[]="niiiiiiiiixssssssssssssssssxxxxx";
const char CharStartOutfitEntryfmt[]="diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char CharTitlesEntryfmt[]="nxssssssssssssssssxxxxxxxxxxxxxxxxxxi";
const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx";
@@ -93,7 +93,7 @@ const char SpellDifficultyfmt[]="niiii";
const std::string CustomSpellDifficultyfmt="ppppp";
const std::string CustomSpellDifficultyIndex="id";
const char SpellDurationfmt[]="niii";
-const char SpellEntryfmt[]="niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxx";
+const char SpellEntryfmt[]="niiiiiiiiiixixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxx";
const std::string CustomSpellEntryfmt="pappppppppaaaaaapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppppppppaaaaaapppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaaaaaa";
const std::string CustomSpellEntryIndex = "Id";
const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index 76f1e3363c0..8a20fa91973 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -330,8 +330,8 @@ void Item::SaveToDB()
}break;
case ITEM_REMOVED:
{
- if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0)
- CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
+ //if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0)
+ // CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
index 580da280a2a..448a90cd582 100644
--- a/src/game/Mail.cpp
+++ b/src/game/Mail.cpp
@@ -717,7 +717,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data)
return;
}
- bodyItem->SetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID , itemTextId);
+ //bodyItem->SetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID , itemTextId);
bodyItem->SetUInt32Value(ITEM_FIELD_CREATOR, m->sender);
sLog.outDetail("HandleMailCreateTextItem mailid=%u",mailId);
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
index 1e8e0e7ea3b..a6d4452df32 100644
--- a/src/game/MiscHandler.cpp
+++ b/src/game/MiscHandler.cpp
@@ -1443,13 +1443,20 @@ void WorldSession::HandleTimeSyncResp(WorldPacket & recv_data)
{
sLog.outDebug("CMSG_TIME_SYNC_RESP");
- uint32 counter, time_;
- recv_data >> counter >> time_;
-
- // time_ seems always more than getMSTime()
- uint32 diff = getMSTimeDiff(getMSTime(),time_);
-
- sLog.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter, time_, time_, getMSTime(), diff);
+ uint32 counter, clientTicks;
+ recv_data >> counter >> clientTicks;
+
+ if (counter != _player->m_timeSyncCounter - 1)
+ sLog.outDebug("Wrong time sync counter from player %s (cheater?)", _player->GetName());
+
+ sLog.outDebug("Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient);
+
+ uint32 ourTicks = clientTicks + (getMSTime() - _player->m_timeSyncServer);
+
+ // diff should be small
+ sLog.outDebug("Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - clientTicks, GetLatency());
+
+ _player->m_timeSyncClient = clientTicks;
}
void WorldSession::HandleResetInstancesOpcode(WorldPacket & /*recv_data*/)
diff --git a/src/game/Opcodes.h b/src/game/Opcodes.h
index 32949eb4731..99817661b91 100644
--- a/src/game/Opcodes.h
+++ b/src/game/Opcodes.h
@@ -1322,8 +1322,26 @@ enum Opcodes
UMSG_UNKNOWN_1283 = 0x503,
UMSG_UNKNOWN_1284 = 0x504,
UMSG_UNKNOWN_1285 = 0x505,
- UMSG_UNKNOWN_1286 = 0x506,
- NUM_MSG_TYPES = 0x507
+ SMSG_UNKNOWN_1286 = 0x506, // ERR_CORPSE_IS_NOT_IN_INSTANCE = 0x1A8,
+ UMSG_UNKNOWN_1287 = 0x507, // not found
+ CMSG_UNKNOWN_1288 = 0x508, // lua: SetAllowLowLevelRaid
+ CMSG_UNKNOWN_1289 = 0x509, // lua: SetAllowLowLevelRaid
+ SMSG_UNKNOWN_1290 = 0x50A, // camera shake?
+ SMSG_UNKNOWN_1291 = 0x50B, // some item update packet?
+ UMSG_UNKNOWN_1292 = 0x50C, // not found
+ UMSG_UNKNOWN_1293 = 0x50D, // not found - disconnect
+ CMSG_UNKNOWN_1294 = 0x50E, // something with networking
+ UMSG_UNKNOWN_1295 = 0x50F, // not found - disconnect
+ CMSG_UNKNOWN_1296 = 0x510, // something with networking
+ UMSG_UNKNOWN_1297 = 0x511, // not found - crash
+ CMSG_UNKNOWN_1298 = 0x512, // something with networking
+ UMSG_UNKNOWN_1299 = 0x513, // not found
+ SMSG_UNKNOWN_1300 = 0x514, // SMSG
+ SMSG_UNKNOWN_1301 = 0x515, // event 0x204 (opens dungeon finder, probably for outdoor bosses)
+ SMSG_UNKNOWN_1302 = 0x516, // something with player movement (move event 58?)
+ CMSG_UNKNOWN_1303 = 0x517, // something with player movement (move event 58?)
+ SMSG_UNKNOWN_1304 = 0x518, // something with player movement (move event 58?), speed packet
+ NUM_MSG_TYPES = 0x519
};
/// Player state
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index a8d719b25da..b092a2b6a20 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -1607,8 +1607,18 @@ bool Player::BuildEnumData(QueryResult_AutoPtr result, WorldPacket * p_data)
*p_data << uint8(proto->InventoryType);
*p_data << uint32(enchant ? enchant->aura_id : 0);
}
- *p_data << uint32(0); // first bag display id
- *p_data << uint8(0); // first bag inventory type
+
+ *p_data << uint32(0); // bag 1 display id
+ *p_data << uint8(0); // bag 1 inventory type
+ *p_data << uint32(0); // enchant?
+ *p_data << uint32(0); // bag 2 display id
+ *p_data << uint8(0); // bag 2 inventory type
+ *p_data << uint32(0); // enchant?
+ *p_data << uint32(0); // bag 3 display id
+ *p_data << uint8(0); // bag 3 inventory type
+ *p_data << uint32(0); // enchant?
+ *p_data << uint32(0); // bag 4 display id
+ *p_data << uint8(0); // bag 4 inventory type
*p_data << uint32(0); // enchant?
return true;
@@ -23343,18 +23353,21 @@ void Player::ActivateSpec(uint8 spec)
void Player::ResetTimeSync()
{
- m_timeSyncCount = 0;
+ m_timeSyncCounter = 0;
m_timeSyncTimer = 0;
+ m_timeSyncClient = 0;
+ m_timeSyncServer = getMSTime();
}
void Player::SendTimeSync()
{
WorldPacket data(SMSG_TIME_SYNC_REQ, 4);
- data << uint32(m_timeSyncCount++);
+ data << uint32(m_timeSyncCounter++);
GetSession()->SendPacket(&data);
- // Send another opcode in 10s again
- m_timeSyncTimer = 10000;
+ // Schedule next sync in 10 sec
+ m_timeSyncTimer = 10000;
+ m_timeSyncServer = getMSTime();
}
void Player::SetReputation(uint32 factionentry, uint32 value)
diff --git a/src/game/Player.h b/src/game/Player.h
index 4e92c6e0774..93574049bad 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -2618,8 +2618,10 @@ class Player : public Unit, public GridObject<Player>
uint32 m_ChampioningFaction;
- uint32 m_timeSyncCount;
- uint32 m_timeSyncTimer;
+ uint32 m_timeSyncCounter;
+ uint32 m_timeSyncTimer;
+ uint32 m_timeSyncClient;
+ uint32 m_timeSyncServer;
};
void AddItemsSetItem(Player*player,Item *item);
diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp
index 2ec23b6bd05..e28f96c1267 100644
--- a/src/game/PlayerDump.cpp
+++ b/src/game/PlayerDump.cpp
@@ -312,8 +312,8 @@ void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl
{
case DTT_INVENTORY:
StoreGUID(result,3,items); break; // item guid collection
- case DTT_ITEM:
- StoreGUID(result,0,ITEM_FIELD_ITEM_TEXT_ID,texts); break;
+ //case DTT_ITEM:
+ //StoreGUID(result,0,ITEM_FIELD_ITEM_TEXT_ID,texts); break;
// item text id collection
case DTT_PET:
StoreGUID(result,0,pets); break; // pet guid collection
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index ef4d0994b70..4b57fcbb76e 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -12240,14 +12240,14 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
level -= int32(spellProto->spellLevel);
float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index];
- float randomPointsPerLevel = spellProto->EffectDicePerLevel[effect_index];
+ float randomPointsPerLevel = 1;
int32 basePoints = int32(effBasePoints + level * basePointsPerLevel);
int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel);
// range can have possitive and negative values, so order its for irand
- int32 randvalue = int32(spellProto->EffectBaseDice[effect_index]) >= randomPoints
- ? irand(randomPoints, int32(spellProto->EffectBaseDice[effect_index]))
- : irand(int32(spellProto->EffectBaseDice[effect_index]), randomPoints);
+ int32 randvalue = int32(1) >= randomPoints
+ ? irand(randomPoints, int32(1))
+ : irand(int32(1), randomPoints);
int32 value = basePoints + randvalue;
//random damage
diff --git a/src/shared/Auth/AuthCrypt.cpp b/src/shared/Auth/AuthCrypt.cpp
index 26dc24ec5f6..b34b922b16a 100644
--- a/src/shared/Auth/AuthCrypt.cpp
+++ b/src/shared/Auth/AuthCrypt.cpp
@@ -23,7 +23,7 @@
#include "Log.h"
#include "BigNumber.h"
-AuthCrypt::AuthCrypt()
+AuthCrypt::AuthCrypt() : _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH)
{
_initialized = false;
}
@@ -35,11 +35,11 @@ AuthCrypt::~AuthCrypt()
void AuthCrypt::Init(BigNumber *K)
{
- uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0x22, 0xBE, 0xE5, 0xCF, 0xBB, 0x07, 0x64, 0xD9, 0x00, 0x45, 0x1B, 0xD0, 0x24, 0xB8, 0xD5, 0x45 };
+ uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 };
HmacHash serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
uint8 *encryptHash = serverEncryptHmac.ComputeHash(K);
- uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xF4, 0x66, 0x31, 0x59, 0xFC, 0x83, 0x6E, 0x31, 0x31, 0x02, 0x51, 0xD5, 0x44, 0x31, 0x67, 0x98 };
+ uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE };
HmacHash clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
uint8 *decryptHash = clientDecryptHmac.ComputeHash(K);
diff --git a/src/shared/Auth/BigNumber.cpp b/src/shared/Auth/BigNumber.cpp
index 930622c54c3..c4811d2b95f 100644
--- a/src/shared/Auth/BigNumber.cpp
+++ b/src/shared/Auth/BigNumber.cpp
@@ -166,7 +166,7 @@ bool BigNumber::isZero() const
return BN_is_zero(_bn)!=0;
}
-uint8 *BigNumber::AsByteArray(int minSize)
+uint8 *BigNumber::AsByteArray(int minSize, bool reverse)
{
int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes();
@@ -183,7 +183,8 @@ uint8 *BigNumber::AsByteArray(int minSize)
BN_bn2bin(_bn, (unsigned char *)_array);
- std::reverse(_array, _array + length);
+ if (reverse)
+ std::reverse(_array, _array + length);
return _array;
}
diff --git a/src/shared/Auth/BigNumber.h b/src/shared/Auth/BigNumber.h
index 1e31951f93c..1dd43c83fc7 100644
--- a/src/shared/Auth/BigNumber.h
+++ b/src/shared/Auth/BigNumber.h
@@ -83,7 +83,7 @@ class BigNumber
struct bignum_st *BN() { return _bn; }
uint32 AsDword();
- uint8* AsByteArray(int minSize = 0);
+ uint8* AsByteArray(int minSize = 0, bool reverse = true);
const char *AsHexStr();
const char *AsDecStr();
diff --git a/src/shared/Auth/Hmac.cpp b/src/shared/Auth/Hmac.cpp
index 4446bdb38ce..07fbd4821fb 100644
--- a/src/shared/Auth/Hmac.cpp
+++ b/src/shared/Auth/Hmac.cpp
@@ -23,10 +23,8 @@
HmacHash::HmacHash(uint32 len, uint8 *seed)
{
- ASSERT(len == SEED_KEY_SIZE);
-
HMAC_CTX_init(&m_ctx);
- HMAC_Init_ex(&m_ctx, seed, SEED_KEY_SIZE, EVP_sha1(), NULL);
+ HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL);
}
HmacHash::~HmacHash()
@@ -44,6 +42,11 @@ void HmacHash::UpdateData(const uint8 *data, int length)
HMAC_Update(&m_ctx, data, length);
}
+void HmacHash::UpdateData(const std::string &str)
+{
+ UpdateData((uint8 const*)str.c_str(), str.length());
+}
+
void HmacHash::Finalize()
{
uint32 length = 0;
diff --git a/src/shared/Auth/Hmac.h b/src/shared/Auth/Hmac.h
index 147b7106f8e..845d6e84802 100644
--- a/src/shared/Auth/Hmac.h
+++ b/src/shared/Auth/Hmac.h
@@ -36,6 +36,7 @@ class HmacHash
~HmacHash();
void UpdateBigNumber(BigNumber *bn);
void UpdateData(const uint8 *data, int length);
+ void UpdateData(const std::string &str);
void Finalize();
uint8 *ComputeHash(BigNumber *bn);
uint8 *GetDigest() { return (uint8*)m_digest; }
diff --git a/src/shared/Auth/SARC4.cpp b/src/shared/Auth/SARC4.cpp
index f59bb7f0c53..80cad4991e9 100644
--- a/src/shared/Auth/SARC4.cpp
+++ b/src/shared/Auth/SARC4.cpp
@@ -19,18 +19,18 @@
#include "Auth/SARC4.h"
#include <openssl/sha.h>
-SARC4::SARC4()
+SARC4::SARC4(uint8 len)
{
EVP_CIPHER_CTX_init(&m_ctx);
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
- EVP_CIPHER_CTX_set_key_length(&m_ctx, SHA_DIGEST_LENGTH);
+ EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
}
-SARC4::SARC4(uint8 *seed)
+SARC4::SARC4(uint8 *seed, uint8 len)
{
EVP_CIPHER_CTX_init(&m_ctx);
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
- EVP_CIPHER_CTX_set_key_length(&m_ctx, SHA_DIGEST_LENGTH);
+ EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
}
diff --git a/src/shared/Auth/SARC4.h b/src/shared/Auth/SARC4.h
index 3f15328d6cb..768856c7fe7 100644
--- a/src/shared/Auth/SARC4.h
+++ b/src/shared/Auth/SARC4.h
@@ -25,8 +25,8 @@
class SARC4
{
public:
- SARC4();
- SARC4(uint8 *seed);
+ SARC4(uint8 len);
+ SARC4(uint8 *seed, uint8 len);
~SARC4();
void Init(uint8 *seed);
void UpdateData(int len, uint8 *data);