aboutsummaryrefslogtreecommitdiff
path: root/src/shared/Auth/Hmac.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-11 00:45:59 -0500
committermegamage <none@none>2009-06-11 00:45:59 -0500
commit9d670fe6f5757430d575081db9a6e5273400330d (patch)
tree9148b75f310fda0bf082be70731abfca03e84f20 /src/shared/Auth/Hmac.cpp
parent9c70e3d89bbace30bfabcf8c42323472ad1e4c4d (diff)
*Switch to support client version 3.1.3
*I strongly recommend you not to use this until you get the 313 db. Now all destructible buildings cause client crash. Source: Mangos Thanks to TOM_RUS for most work to make this switch possible ;) --HG-- branch : trunk
Diffstat (limited to 'src/shared/Auth/Hmac.cpp')
-rw-r--r--src/shared/Auth/Hmac.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/shared/Auth/Hmac.cpp b/src/shared/Auth/Hmac.cpp
index a8572f0e9f8..985b4fb9a56 100644
--- a/src/shared/Auth/Hmac.cpp
+++ b/src/shared/Auth/Hmac.cpp
@@ -21,17 +21,16 @@
#include "Auth/Hmac.h"
#include "BigNumber.h"
-HmacHash::HmacHash()
+HmacHash::HmacHash(uint32 len, uint8 *seed)
{
- uint8 temp[SEED_KEY_SIZE] = { 0x38, 0xA7, 0x83, 0x15, 0xF8, 0x92, 0x25, 0x30, 0x71, 0x98, 0x67, 0xB1, 0x8C, 0x4, 0xE2, 0xAA };
- memcpy(&m_key, &temp, SEED_KEY_SIZE);
+ ASSERT(len == SEED_KEY_SIZE);
+
HMAC_CTX_init(&m_ctx);
- HMAC_Init_ex(&m_ctx, &m_key, SEED_KEY_SIZE, EVP_sha1(), NULL);
+ HMAC_Init_ex(&m_ctx, seed, SEED_KEY_SIZE, EVP_sha1(), NULL);
}
HmacHash::~HmacHash()
{
- memset(&m_key, 0x00, SEED_KEY_SIZE);
HMAC_CTX_cleanup(&m_ctx);
}
@@ -45,15 +44,16 @@ void HmacHash::UpdateData(const uint8 *data, int length)
HMAC_Update(&m_ctx, data, length);
}
-void HmacHash::Initialize()
-{
- HMAC_Init_ex(&m_ctx, &m_key, SEED_KEY_SIZE, EVP_sha1(), NULL);
-}
-
void HmacHash::Finalize()
{
uint32 length = 0;
- HMAC_Final(&m_ctx, m_digest, &length);
+ HMAC_Final(&m_ctx, (uint8*)m_digest, &length);
ASSERT(length == SHA_DIGEST_LENGTH)
}
+uint8 *HmacHash::ComputeHash(BigNumber *bn)
+{
+ HMAC_Update(&m_ctx, bn->AsByteArray(), bn->GetNumBytes());
+ Finalize();
+ return (uint8*)m_digest;
+}