Skip to content

Commit

Permalink
Renamed HMACSHA1 to something that will not conflict with feature HMA…
Browse files Browse the repository at this point in the history
…CSHA256 and HMACSHA512.

Conflicts:

	src/shared/Auth/AuthCrypt.cpp
	src/shared/Auth/HMACSHA1.cpp
  • Loading branch information
tomrus88 committed Apr 5, 2010
1 parent 1ce477c commit 65f5490
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 26 deletions.
12 changes: 12 additions & 0 deletions src/.gitignore
@@ -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
6 changes: 3 additions & 3 deletions src/shared/Auth/AuthCrypt.cpp
Expand Up @@ -17,7 +17,7 @@
*/

#include "AuthCrypt.h"
#include "Hmac.h"
#include "HMACSHA1.h"
#include "Log.h"
#include "BigNumber.h"

Expand All @@ -34,11 +34,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 };
HmacHash serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
HMACSHA1 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 };
HmacHash clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
HMACSHA1 clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
uint8 *decryptHash = clientDecryptHmac.ComputeHash(K);

//SARC4 _serverDecrypt(encryptHash);
Expand Down
22 changes: 12 additions & 10 deletions src/shared/Auth/Hmac.cpp → src/shared/Auth/HMACSHA1.cpp
Expand Up @@ -16,40 +16,42 @@
* 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)
{
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()
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::Finalize()
void HMACSHA1::UpdateData(const std::string &str)
{
UpdateData((uint8 const*)str.c_str(), str.length());
}
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();
Expand Down
10 changes: 5 additions & 5 deletions src/shared/Auth/Hmac.h → src/shared/Auth/HMACSHA1.h
Expand Up @@ -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>
Expand All @@ -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 Finalize();
Expand Down
4 changes: 2 additions & 2 deletions src/shared/Auth/Makefile.am
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions win/VC100/shared.vcxproj
Expand Up @@ -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" />
Expand Down Expand Up @@ -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" />
Expand Down
4 changes: 2 additions & 2 deletions win/VC80/shared.vcproj
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions win/VC90/shared.vcproj
Expand Up @@ -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
Expand Down

0 comments on commit 65f5490

Please sign in to comment.