TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HmacHash< HashCreator, DigestLength > Class Template Reference

#include <HmacHash.h>

Public Member Functions

 HmacHash (uint32 len, uint8 const *seed)
 
 ~HmacHash ()
 
void UpdateData (std::string const &str)
 
void UpdateData (uint8 const *data, size_t len)
 
void Finalize ()
 
uint8ComputeHash (BigNumber *bn)
 
uint8GetDigest ()
 
uint32 GetLength () const
 

Private Attributes

HMAC_CTX _ctx
 
uint8 _digest [DigestLength]
 

Constructor & Destructor Documentation

template<HashCreateFn HashCreator, uint32 DigestLength>
HmacHash< HashCreator, DigestLength >::HmacHash ( uint32  len,
uint8 const seed 
)
25 {
26  HMAC_CTX_init(&_ctx);
27  HMAC_Init_ex(&_ctx, seed, len, HashCreator(), NULL);
28  memset(_digest, 0, DigestLength);
29 }
uint8 _digest[DigestLength]
Definition: HmacHash.h:47
arena_t NULL
Definition: jemalloc_internal.h:624
HMAC_CTX _ctx
Definition: HmacHash.h:46
template<HashCreateFn HashCreator, uint32 DigestLength>
HmacHash< HashCreator, DigestLength >::~HmacHash ( )
33 {
34  HMAC_CTX_cleanup(&_ctx);
35 }
HMAC_CTX _ctx
Definition: HmacHash.h:46

Member Function Documentation

template<HashCreateFn HashCreator, uint32 DigestLength>
uint8 * HmacHash< HashCreator, DigestLength >::ComputeHash ( BigNumber bn)
59 {
60  HMAC_Update(&_ctx, bn->AsByteArray().get(), bn->GetNumBytes());
61  Finalize();
62  return _digest;
63 }
uint8 _digest[DigestLength]
Definition: HmacHash.h:47
HMAC_CTX _ctx
Definition: HmacHash.h:46
int32 GetNumBytes(void)
Definition: BigNumber.cpp:157
std::unique_ptr< uint8[]> AsByteArray(int32 minSize=0, bool littleEndian=true)
Definition: BigNumber.cpp:177
void Finalize()
Definition: HmacHash.cpp:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<HashCreateFn HashCreator, uint32 DigestLength>
void HmacHash< HashCreator, DigestLength >::Finalize ( )
51 {
52  uint32 length = 0;
53  HMAC_Final(&_ctx, _digest, &length);
54  ASSERT(length == DigestLength);
55 }
uint8 _digest[DigestLength]
Definition: HmacHash.h:47
HMAC_CTX _ctx
Definition: HmacHash.h:46
uint32_t uint32
Definition: Define.h:150
float length(float v)
Definition: vectorMath.h:208
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<HashCreateFn HashCreator, uint32 DigestLength>
uint8* HmacHash< HashCreator, DigestLength >::GetDigest ( )
inline
43 { return _digest; }
uint8 _digest[DigestLength]
Definition: HmacHash.h:47

+ Here is the caller graph for this function:

template<HashCreateFn HashCreator, uint32 DigestLength>
uint32 HmacHash< HashCreator, DigestLength >::GetLength ( ) const
inline
44 { return DigestLength; }

+ Here is the caller graph for this function:

template<HashCreateFn HashCreator, uint32 DigestLength>
void HmacHash< HashCreator, DigestLength >::UpdateData ( std::string const str)
39 {
40  HMAC_Update(&_ctx, (uint8 const*)str.c_str(), str.length());
41 }
HMAC_CTX _ctx
Definition: HmacHash.h:46
uint8_t uint8
Definition: Define.h:152

+ Here is the caller graph for this function:

template<HashCreateFn HashCreator, uint32 DigestLength>
void HmacHash< HashCreator, DigestLength >::UpdateData ( uint8 const data,
size_t  len 
)
45 {
46  HMAC_Update(&_ctx, data, len);
47 }
HMAC_CTX _ctx
Definition: HmacHash.h:46

Member Data Documentation

template<HashCreateFn HashCreator, uint32 DigestLength>
HMAC_CTX HmacHash< HashCreator, DigestLength >::_ctx
private
template<HashCreateFn HashCreator, uint32 DigestLength>
uint8 HmacHash< HashCreator, DigestLength >::_digest[DigestLength]
private

The documentation for this class was generated from the following files: