~zooko/cryptopp/trunk

« back to all changes in this revision

Viewing changes to hmac.cpp

  • Committer: weidai
  • Date: 2009-03-02 02:39:17 UTC
  • Revision ID: svn-v4:57ff6487-cd31-0410-9ec3-f628ee90f5f0:trunk/c5:433
changes for 5.6: 
    - added AuthenticatedSymmetricCipher interface class and Filter wrappers
    - added CCM, GCM (with SSE2 assembly), CMAC, and SEED
    - improved AES speed on x86 and x64
    - removed WORD64_AVAILABLE; compiler 64-bit int support is now required

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
NAMESPACE_BEGIN(CryptoPP)
10
10
 
11
 
void HMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength)
 
11
void HMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &)
12
12
{
13
13
        AssertValidKeyLength(keylength);
14
14
 
20
20
        if (!blockSize)
21
21
                throw InvalidArgument("HMAC: can only be used with a block-based hash function");
22
22
 
 
23
        m_buf.resize(2*AccessHash().BlockSize() + AccessHash().DigestSize());
 
24
 
23
25
        if (keylength <= blockSize)
24
26
                memcpy(AccessIpad(), userKey, keylength);
25
27
        else
33
35
 
34
36
        for (unsigned int i=0; i<blockSize; i++)
35
37
        {
36
 
                AccessOpad()[i] = AccessIpad()[i] ^ OPAD;
37
 
                AccessIpad()[i] ^= IPAD;
 
38
                AccessOpad()[i] = AccessIpad()[i] ^ 0x5c;
 
39
                AccessIpad()[i] ^= 0x36;
38
40
        }
39
41
}
40
42