diff options
author | weidai <weidai11@users.noreply.github.com> | 2007-05-04 15:03:07 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2007-05-04 15:03:07 +0000 |
commit | c09618a557b50da44ddac06ccb3d24a71f9484f4 (patch) | |
tree | 86b3f78711704b94c0fa7b93cb5678c44338bdc5 /vmac.h | |
parent | deb3228e837c9f911bdb12bb116b56cc75d639df (diff) | |
download | cryptopp-git-c09618a557b50da44ddac06ccb3d24a71f9484f4.tar.gz |
update to draft-01
Diffstat (limited to 'vmac.h')
-rwxr-xr-x | vmac.h | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -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<word64, LittleEndian, 16, MessageAuthenticationCode> +class VMAC_Base : public IteratedHashBase<word64, MessageAuthenticationCode> { 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<VMAC_Base *>(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 <bool T_128BitTag> +#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; }; /// <a href="http://www.cryptolounge.org/wiki/VMAC">VMAC</a> |