Updated documentation

pull/65/head
Jeffrey Walton 2015-12-16 23:10:07 -05:00
parent 17ead160bf
commit 36dc30286b
1 changed files with 15 additions and 4 deletions

19
hmac.h
View File

@ -1,6 +1,6 @@
// hmac.h - written and placed in the public domain by Wei Dai // hmac.h - written and placed in the public domain by Wei Dai
//! \file //! \file hmac.h
//! \brief Classes for HMAC message authentication codes //! \brief Classes for HMAC message authentication codes
#ifndef CRYPTOPP_HMAC_H #ifndef CRYPTOPP_HMAC_H
@ -11,10 +11,13 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
//! _ //! \class HMAC_Base
//! \brief HMAC information
//! \details HMAC_Base derives from VariableKeyLength and MessageAuthenticationCode
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE HMAC_Base : public VariableKeyLength<16, 0, INT_MAX>, public MessageAuthenticationCode class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE HMAC_Base : public VariableKeyLength<16, 0, INT_MAX>, public MessageAuthenticationCode
{ {
public: public:
//! \brief Construct a HMAC_Base
HMAC_Base() : m_innerHashKeyed(false) {} HMAC_Base() : m_innerHashKeyed(false) {}
void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &params); void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &params);
@ -37,8 +40,12 @@ private:
bool m_innerHashKeyed; bool m_innerHashKeyed;
}; };
//! <a href="http://www.weidai.com/scan-mirror/mac.html#HMAC">HMAC</a> //! \class HMAC
/*! HMAC(K, text) = H(K XOR opad, H(K XOR ipad, text)) */ //! \brief HMAC
//! \tparam T HashTransformation derived class
//! \details HMAC derives from MessageAuthenticationCodeImpl. It calculates the HMAC using
//! <tt>HMAC(K, text) = H(K XOR opad, H(K XOR ipad, text))</tt>.
//! \sa <a href="http://www.weidai.com/scan-mirror/mac.html#HMAC">HMAC</a>
template <class T> template <class T>
class HMAC : public MessageAuthenticationCodeImpl<HMAC_Base, HMAC<T> > class HMAC : public MessageAuthenticationCodeImpl<HMAC_Base, HMAC<T> >
{ {
@ -46,7 +53,11 @@ public:
CRYPTOPP_CONSTANT(DIGESTSIZE=T::DIGESTSIZE) CRYPTOPP_CONSTANT(DIGESTSIZE=T::DIGESTSIZE)
CRYPTOPP_CONSTANT(BLOCKSIZE=T::BLOCKSIZE) CRYPTOPP_CONSTANT(BLOCKSIZE=T::BLOCKSIZE)
//! \brief Construct a HMAC
HMAC() {} HMAC() {}
//! \brief Construct a HMAC
//! \param key the HMAC key
//! \param length the size of the HMAC key
HMAC(const byte *key, size_t length=HMAC_Base::DEFAULT_KEYLENGTH) HMAC(const byte *key, size_t length=HMAC_Base::DEFAULT_KEYLENGTH)
{this->SetKey(key, length);} {this->SetKey(key, length);}