TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SHA256.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef SHA256_h__
19 #define SHA256_h__
20 
21 #include "Define.h"
22 #include <string>
23 #include <type_traits>
24 #include <openssl/sha.h>
25 
26 class BigNumber;
27 
29 {
30  public:
31  typedef std::integral_constant<uint32, SHA256_DIGEST_LENGTH> DigestLength;
32 
33  SHA256Hash();
34  ~SHA256Hash();
35 
36  void UpdateBigNumbers(BigNumber* bn0, ...);
37 
38  void UpdateData(const uint8 *dta, int len);
39  void UpdateData(const std::string &str);
40 
41  void Initialize();
42  void Finalize();
43 
44  uint8 *GetDigest(void) { return mDigest; }
45  int GetLength(void) const { return SHA256_DIGEST_LENGTH; }
46 
47  private:
48  SHA256_CTX mC;
49  uint8 mDigest[SHA256_DIGEST_LENGTH];
50 };
51 
52 #endif // SHA256_h__
Definition: BigNumber.h:28
std::integral_constant< uint32, SHA256_DIGEST_LENGTH > DigestLength
Definition: SHA256.h:31
SHA256_CTX mC
Definition: SHA256.h:48
Definition: SHA256.h:28
Definition: UpdateData.h:59
uint8 * GetDigest(void)
Definition: SHA256.h:44
static void Initialize(PCASC_SALSA20 pState, LPBYTE pbKey, DWORD cbKeyLength, LPBYTE pbVector)
Definition: CascDecrypt.cpp:81
#define TC_COMMON_API
Definition: Define.h:116
uint8_t uint8
Definition: Define.h:152
int GetLength(void) const
Definition: SHA256.h:45