mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-24 08:00:14 +00:00
Initial commit: wowee native WoW 3.3.5a client
This commit is contained in:
commit
ce6cb8f38e
147 changed files with 32347 additions and 0 deletions
33
src/auth/crypto.cpp
Normal file
33
src/auth/crypto.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "auth/crypto.hpp"
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
namespace wowee {
|
||||
namespace auth {
|
||||
|
||||
std::vector<uint8_t> Crypto::sha1(const std::vector<uint8_t>& data) {
|
||||
std::vector<uint8_t> hash(SHA_DIGEST_LENGTH);
|
||||
SHA1(data.data(), data.size(), hash.data());
|
||||
return hash;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Crypto::sha1(const std::string& data) {
|
||||
std::vector<uint8_t> bytes(data.begin(), data.end());
|
||||
return sha1(bytes);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Crypto::hmacSHA1(const std::vector<uint8_t>& key,
|
||||
const std::vector<uint8_t>& data) {
|
||||
std::vector<uint8_t> hash(SHA_DIGEST_LENGTH);
|
||||
unsigned int length = 0;
|
||||
|
||||
HMAC(EVP_sha1(),
|
||||
key.data(), key.size(),
|
||||
data.data(), data.size(),
|
||||
hash.data(), &length);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
} // namespace auth
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue