From 5f1af2c96edd4318d5589ea840d865cad58b6235 Mon Sep 17 00:00:00 2001 From: weidai Date: Sat, 9 Dec 2006 17:16:05 +0000 Subject: [PATCH] VC2005 workaround --- des.cpp | 7 +++++-- des.h | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/des.cpp b/des.cpp index 3afe0b31..af9308c1 100644 --- a/des.cpp +++ b/des.cpp @@ -424,15 +424,18 @@ void DES_XEX3::Base::UncheckedSetKey(CipherDir dir, const byte *key, unsigned in { AssertValidKeyLength(length); + if (!m_des.get()) + m_des.reset(new DES::Encryption); + memcpy(m_x1, key+(dir==ENCRYPTION?0:2*8), BLOCKSIZE); - m_des.UncheckedSetKey(dir, key+8); + m_des->UncheckedSetKey(dir, key+8); memcpy(m_x3, key+(dir==DECRYPTION?0:2*8), BLOCKSIZE); } void DES_XEX3::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { xorbuf(outBlock, inBlock, m_x1, BLOCKSIZE); - m_des.ProcessAndXorBlock(outBlock, xorBlock, outBlock); + m_des->ProcessAndXorBlock(outBlock, xorBlock, outBlock); xorbuf(outBlock, m_x3, BLOCKSIZE); } diff --git a/des.h b/des.h index 272bc53e..8400fa1b 100644 --- a/des.h +++ b/des.h @@ -116,7 +116,9 @@ class DES_XEX3 : public DES_XEX3_Info, public BlockCipherDocumentation protected: FixedSizeSecBlock m_x1, m_x3; - DES::Encryption m_des; + // VS2005 workaround: calling modules compiled with /clr gets unresolved external symbol DES::Base::ProcessAndXorBlock + // if we use DES::Encryption here directly without value_ptr. + value_ptr m_des; }; public: