Renamed HMACSHA1 to something that will not conflict with feature HMACSHA256 and HMACSHA512.

This commit is contained in:
tomrus88 2010-04-04 17:57:06 +04:00
parent 9a0545cd05
commit 4e2c42799c
8 changed files with 36 additions and 24 deletions

12
src/.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git-ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
#
# Doxygen generic files
#
bnetd

View file

@ -17,7 +17,7 @@
*/
#include "AuthCrypt.h"
#include "Hmac.h"
#include "HMACSHA1.h"
#include "Log.h"
#include "BigNumber.h"
@ -35,12 +35,12 @@ void AuthCrypt::Init(BigNumber *K)
{
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);
HMACSHA1 serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
uint8 *encryptHash = serverEncryptHmac.ComputeHash(K);
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);
HMACSHA1 clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
uint8 *decryptHash = clientDecryptHmac.ComputeHash(K);
//SARC4 _serverDecrypt(encryptHash);

View file

@ -16,43 +16,43 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Auth/Hmac.h"
#include "Auth/HMACSHA1.h"
#include "BigNumber.h"
HmacHash::HmacHash(uint32 len, uint8 *seed)
HMACSHA1::HMACSHA1(uint32 len, uint8 *seed)
{
HMAC_CTX_init(&m_ctx);
HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL);
}
HmacHash::~HmacHash()
HMACSHA1::~HMACSHA1()
{
HMAC_CTX_cleanup(&m_ctx);
}
void HmacHash::UpdateBigNumber(BigNumber *bn)
void HMACSHA1::UpdateBigNumber(BigNumber *bn)
{
UpdateData(bn->AsByteArray(), bn->GetNumBytes());
}
void HmacHash::UpdateData(const uint8 *data, int length)
void HMACSHA1::UpdateData(const uint8 *data, int length)
{
HMAC_Update(&m_ctx, data, length);
}
void HmacHash::UpdateData(const std::string &str)
void HMACSHA1::UpdateData(const std::string &str)
{
UpdateData((uint8 const*)str.c_str(), str.length());
}
void HmacHash::Finalize()
void HMACSHA1::Finalize()
{
uint32 length = 0;
HMAC_Final(&m_ctx, (uint8*)m_digest, &length);
ASSERT(length == SHA_DIGEST_LENGTH);
}
uint8 *HmacHash::ComputeHash(BigNumber *bn)
uint8 *HMACSHA1::ComputeHash(BigNumber *bn)
{
HMAC_Update(&m_ctx, bn->AsByteArray(), bn->GetNumBytes());
Finalize();

View file

@ -16,8 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _AUTH_HMAC_H
#define _AUTH_HMAC_H
#ifndef _AUTH_HMACSHA1_H
#define _AUTH_HMACSHA1_H
#include "Common.h"
#include <openssl/hmac.h>
@ -27,11 +27,11 @@ class BigNumber;
#define SEED_KEY_SIZE 16
class HmacHash
class HMACSHA1
{
public:
HmacHash(uint32 len, uint8 *seed);
~HmacHash();
HMACSHA1(uint32 len, uint8 *seed);
~HMACSHA1();
void UpdateBigNumber(BigNumber *bn);
void UpdateData(const uint8 *data, int length);
void UpdateData(const std::string &str);

View file

@ -31,8 +31,8 @@ libmangosauth_a_SOURCES = \
AuthCrypt.h \
BigNumber.cpp \
BigNumber.h \
Hmac.cpp \
Hmac.h \
HMACSHA1.cpp \
HMACSHA1.h \
SARC4.cpp \
SARC4.h \
Sha1.cpp \

View file

@ -432,7 +432,7 @@
<ItemGroup>
<ClCompile Include="..\..\src\shared\Auth\AuthCrypt.cpp" />
<ClCompile Include="..\..\src\shared\Auth\BigNumber.cpp" />
<ClCompile Include="..\..\src\shared\Auth\Hmac.cpp" />
<ClCompile Include="..\..\src\shared\Auth\HMACSHA1.cpp" />
<ClCompile Include="..\..\src\shared\Auth\SARC4.cpp" />
<ClCompile Include="..\..\src\shared\Auth\Sha1.cpp" />
<ClCompile Include="..\..\src\shared\Common.cpp" />
@ -468,7 +468,7 @@
<ClInclude Include="..\..\dep\include\mersennetwister\MersenneTwister.h" />
<ClInclude Include="..\..\src\shared\Auth\AuthCrypt.h" />
<ClInclude Include="..\..\src\shared\Auth\BigNumber.h" />
<ClInclude Include="..\..\src\shared\Auth\Hmac.h" />
<ClInclude Include="..\..\src\shared\Auth\HMACSHA1.h" />
<ClInclude Include="..\..\src\shared\Auth\SARC4.h" />
<ClInclude Include="..\..\src\shared\Auth\Sha1.h" />
<ClInclude Include="..\..\src\shared\ByteBuffer.h" />

View file

@ -717,11 +717,11 @@
>
</File>
<File
RelativePath="..\..\src\shared\Auth\Hmac.cpp"
RelativePath="..\..\src\shared\Auth\HMACSHA1.cpp"
>
</File>
<File
RelativePath="..\..\src\shared\Auth\Hmac.h"
RelativePath="..\..\src\shared\Auth\HMACSHA1.h"
>
</File>
<File

View file

@ -723,11 +723,11 @@
>
</File>
<File
RelativePath="..\..\src\shared\Auth\Hmac.cpp"
RelativePath="..\..\src\shared\Auth\HMACSHA1.cpp"
>
</File>
<File
RelativePath="..\..\src\shared\Auth\Hmac.h"
RelativePath="..\..\src\shared\Auth\HMACSHA1.h"
>
</File>
<File