2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Auth/Hmac.h"
20 #include "BigNumber.h"
24 uint8 temp
[SEED_KEY_SIZE
] = { 0x38, 0xA7, 0x83, 0x15, 0xF8, 0x92, 0x25, 0x30, 0x71, 0x98, 0x67, 0xB1, 0x8C, 0x4, 0xE2, 0xAA };
25 memcpy(&m_key
, &temp
, SEED_KEY_SIZE
);
26 HMAC_CTX_init(&m_ctx
);
27 HMAC_Init_ex(&m_ctx
, &m_key
, SEED_KEY_SIZE
, EVP_sha1(), NULL
);
32 memset(&m_key
, 0x00, SEED_KEY_SIZE
);
33 HMAC_CTX_cleanup(&m_ctx
);
36 void HmacHash::UpdateBigNumber(BigNumber
*bn
)
38 UpdateData(bn
->AsByteArray(), bn
->GetNumBytes());
41 void HmacHash::UpdateData(const uint8
*data
, int length
)
43 HMAC_Update(&m_ctx
, data
, length
);
46 void HmacHash::Initialize()
48 HMAC_Init_ex(&m_ctx
, &m_key
, SEED_KEY_SIZE
, EVP_sha1(), NULL
);
51 void HmacHash::Finalize()
54 HMAC_Final(&m_ctx
, m_digest
, &length
);
55 ASSERT(length
== SHA_DIGEST_LENGTH
)