From 061bcd669cf286d0043e1060bb36761df2df907e Mon Sep 17 00:00:00 2001 From: weidai Date: Fri, 4 May 2007 15:03:07 +0000 Subject: update to draft-01 git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@327 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- vmac.h | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'vmac.h') diff --git a/vmac.h b/vmac.h index 08284f4..9540617 100755 --- a/vmac.h +++ b/vmac.h @@ -14,19 +14,21 @@ NAMESPACE_BEGIN(CryptoPP) #define CRYPTOPP_BLOCK_6(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS5());} size_t SS6() {return SS5()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);} #define CRYPTOPP_BLOCK_7(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS6());} size_t SS7() {return SS6()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);} #define CRYPTOPP_BLOCK_8(n, t, s) t* m_##n() {return (t *)(m_aggregate+SS7());} size_t SS8() {return SS7()+sizeof(t)*(s);} size_t m_##n##Size() {return (s);} -#define CRYPTOPP_BLOCKS_END(i) size_t SST() {return SS##i();} void AllocateBlocks() {m_aggregate.New(SST());} SecByteBlock m_aggregate; +#define CRYPTOPP_BLOCKS_END(i) size_t SST() {return SS##i();} void AllocateBlocks() {m_aggregate.New(SST());} AlignedSecByteBlock m_aggregate; /// . -class VMAC_Base : public IteratedHash +class VMAC_Base : public IteratedHashBase { public: std::string AlgorithmName() const {return std::string("VMAC(") + GetCipher().AlgorithmName() + ")-" + IntToString(DigestSize()*8);} unsigned int IVSize() const {return GetCipher().BlockSize();} void Resynchronize(const byte *IV); - void GetNextIV(byte *IV); + void GetNextIV(RandomNumberGenerator &rng, byte *IV); unsigned int DigestSize() const {return m_is128 ? 16 : 8;}; void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs ¶ms); void TruncatedFinal(byte *mac, size_t size); + unsigned int BlockSize() const {return m_L1KeyLength;} + ByteOrder GetByteOrder() const {return LITTLE_ENDIAN_ORDER;} protected: virtual BlockCipher & AccessCipher() =0; @@ -34,21 +36,27 @@ protected: const BlockCipher & GetCipher() const {return const_cast(this)->AccessCipher();} void HashEndianCorrectedBlock(const word64 *data); size_t HashMultipleBlocks(const word64 *input, size_t length); - void Init(); + void Init() {} word64* StateBuf() {return NULL;} + word64* DataBuf() {return (word64 *)m_data();} - CRYPTOPP_BLOCK_1(polyKey, word64, 2) - CRYPTOPP_BLOCK_2(polyAccum, word64, 2) - CRYPTOPP_BLOCK_3(ipKey, word64, 2) - CRYPTOPP_BLOCK_4(nhAccum, word64, 2*(m_is128+1)) - CRYPTOPP_BLOCK_5(nhKey, word64, m_L1KeyLength/sizeof(word64) + 2*m_is128) - CRYPTOPP_BLOCK_6(nonce, byte, IVSize()) - CRYPTOPP_BLOCK_7(pad, byte, IVSize()) - CRYPTOPP_BLOCKS_END(7) + void VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, int tagPart); +#if !(defined(_MSC_VER) && _MSC_VER < 1300) // can't use function template here with VC6 + template +#endif + void VHASH_Update_Template(const word64 *data, size_t blockRemainingInWord128); + void VHASH_Update(const word64 *data, size_t blocksRemainingInWord128); + + CRYPTOPP_BLOCK_1(polyState, word64, 4*(m_is128+1)) + CRYPTOPP_BLOCK_2(nhKey, word64, m_L1KeyLength/sizeof(word64) + 2*m_is128) + CRYPTOPP_BLOCK_3(data, byte, m_L1KeyLength) + CRYPTOPP_BLOCK_4(l3Key, word64, 2*(m_is128+1)) + CRYPTOPP_BLOCK_5(nonce, byte, IVSize()) + CRYPTOPP_BLOCK_6(pad, byte, IVSize()) + CRYPTOPP_BLOCKS_END(6) + bool m_is128, m_padCached, m_isFirstBlock; int m_L1KeyLength; - size_t m_nhCount; - bool m_is128, m_padCached; }; /// VMAC -- cgit v1.2.1