-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update v/s srp values in AccountMgr commands
to drop `sha_pass_hash` it is necesary to update the srp values 'v' and 's' in the AccountMgr commands otherwise modified/created accounts cannot login anymore this commit introduces a basic SRP class to handle the customized SRP calculation properly
- Loading branch information
Showing
5 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#include "Common.h" | ||
#include "Auth/HMACSHA1.h" | ||
#include "Auth/base32.h" | ||
#include "SRP6.h" | ||
|
||
SRP6::SRP6() | ||
{ | ||
N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); | ||
g.SetDword(7); | ||
v_hex = NULL; | ||
s_hex = NULL; | ||
} | ||
|
||
SRP6::~SRP6() | ||
{ | ||
if (v_hex != NULL) | ||
OPENSSL_free((void*)v_hex); | ||
if (s_hex != NULL) | ||
OPENSSL_free((void*)s_hex); | ||
} | ||
|
||
void SRP6::CalculateVerifier(const std::string& rI) | ||
{ | ||
s.SetRand(s_BYTE_SIZE * 8); | ||
|
||
BigNumber I; | ||
I.SetHexStr(rI.c_str()); | ||
|
||
// in case of leading zeros in the rI hash, restore them | ||
uint8 mDigest[SHA_DIGEST_LENGTH]; | ||
memset(mDigest, 0, SHA_DIGEST_LENGTH); | ||
if (I.GetNumBytes() <= SHA_DIGEST_LENGTH) | ||
memcpy(mDigest, I.AsByteArray(), I.GetNumBytes()); | ||
|
||
std::reverse(mDigest, mDigest + SHA_DIGEST_LENGTH); | ||
|
||
Sha1Hash sha; | ||
sha.UpdateData(s.AsByteArray(), s.GetNumBytes()); | ||
sha.UpdateData(mDigest, SHA_DIGEST_LENGTH); | ||
sha.Finalize(); | ||
BigNumber x; | ||
x.SetBinary(sha.GetDigest(), Sha1Hash::GetLength()); | ||
v = g.ModExp(x, N); | ||
v_hex = v.AsHexStr(); | ||
s_hex = s.AsHexStr(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#ifndef _SRP6_H | ||
#define _SRP6_H | ||
|
||
#include "Common.h" | ||
#include "Auth/BigNumber.h" | ||
#include "Auth/Sha1.h" | ||
#include "ByteBuffer.h" | ||
|
||
#define HMAC_RES_SIZE 20 | ||
|
||
class SRP6 | ||
{ | ||
public: | ||
const static int s_BYTE_SIZE = 32; | ||
|
||
SRP6(void); | ||
~SRP6(void); | ||
|
||
void CalculateVerifier(const std::string& rI); | ||
|
||
const char* GetSalt(void) { return s_hex; }; | ||
const char* GetVerifier(void) { return v_hex; }; | ||
|
||
private: | ||
BigNumber N, s, g, v; | ||
|
||
const char* v_hex; | ||
const char* s_hex; | ||
}; | ||
#endif |