2010-10-07 15:54:07 +02:00
|
|
|
/*
|
2018-01-01 00:40:17 +01:00
|
|
|
* Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
2010-10-07 15:54:07 +02:00
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#ifndef _AUTH_SHA1_H
|
|
|
|
|
#define _AUTH_SHA1_H
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-10-18 14:59:23 +02:00
|
|
|
#include "Define.h"
|
|
|
|
|
#include <string>
|
2016-03-19 23:15:54 +01:00
|
|
|
#include <type_traits>
|
2008-10-02 16:23:55 -05:00
|
|
|
#include <openssl/sha.h>
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-09-18 14:10:37 -07:00
|
|
|
class BigNumber;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2016-03-22 19:58:32 +01:00
|
|
|
class TC_COMMON_API SHA1Hash
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
public:
|
2016-03-19 23:15:54 +01:00
|
|
|
typedef std::integral_constant<uint32, SHA_DIGEST_LENGTH> DigestLength;
|
|
|
|
|
|
2010-08-08 04:49:04 +02:00
|
|
|
SHA1Hash();
|
|
|
|
|
~SHA1Hash();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-15 14:08:17 +02:00
|
|
|
void UpdateBigNumbers(BigNumber* bn0, ...);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
void UpdateData(const uint8 *dta, int len);
|
|
|
|
|
void UpdateData(const std::string &str);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
void Initialize();
|
|
|
|
|
void Finalize();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2015-05-27 21:16:06 -04:00
|
|
|
uint8 *GetDigest(void) { return mDigest; }
|
|
|
|
|
int GetLength(void) const { return SHA_DIGEST_LENGTH; }
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
private:
|
|
|
|
|
SHA_CTX mC;
|
|
|
|
|
uint8 mDigest[SHA_DIGEST_LENGTH];
|
|
|
|
|
};
|
2009-02-17 20:07:49 -06:00
|
|
|
|
2016-04-17 19:30:13 +02:00
|
|
|
/// Returns the SHA1 hash of the given content as hex string.
|
|
|
|
|
TC_COMMON_API std::string CalculateSHA1Hash(std::string const& content);
|
|
|
|
|
|
|
|
|
|
#endif
|