Hi All (Wei),

It looked too simple (this is the first step in removing
Authentication Tag T from an ECIES CipherText Object)... enum
{DIGESTSIZE=0, BLOCKSIZE=T::BLOCKSIZE} caused compilation errors.
(Trying to change as few things as possible to achieve my goal).

Below is the code I've adapted from Crytpo++. Following the code is
the verbose Compilation Warning and Error (basically, 0 sized array
due to DIGESTSIZE=0).

The C2229 fix is easy enough for class FixedAllocatorWithCleanUP.
Member A m_fallbackAllocator; was moved to the last item declared.

However, template <class T, class A = AllocatorWithCleanup<T> > class
SecBlock is a different story. I can't Specialize a Template based on
a Value (0) - only a type (unsigned int).

Jeff

template <class T>
class Null_HMAC : public
CryptoPP::MessageAuthenticationCodeImpl<CryptoPP::HMAC_Base,
CryptoPP::HMAC<T> >
{
public:
        enum {DIGESTSIZE=0, BLOCKSIZE=T::BLOCKSIZE};
        // enum {DIGESTSIZE=T::DIGESTSIZE, BLOCKSIZE=T::BLOCKSIZE};

        Null_HMAC() {}
        Null_HMAC(const byte *key, unsigned int
length=CryptoPP::HMAC_Base::DEFAULT_KEYLENGTH)
       {this->SetKey(key, length);}

        static std::string StaticAlgorithmName() {return std::string("Null
HMAC(") + T::StaticAlgorithmName() + ")";}
        std::string AlgorithmName() const {return std::string("Null HMAC(") +
m_hash.AlgorithmName() + ")";}

private:
        CryptoPP::HashTransformation & AccessHash() {return m_hash;}
        byte * AccessIpad() {return m_ipad;}
        byte * AccessOpad() {return m_opad;}
        byte * AccessInnerHash() {return m_innerHash;}

        CryptoPP::FixedSizeSecBlock<byte, BLOCKSIZE> m_ipad, m_opad;
        CryptoPP::FixedSizeSecBlock<byte, DIGESTSIZE> m_innerHash;
        T m_hash;
};

// Crypto++ Includes
//   Template Specialization modification of
//   struct ECIES in ecccrypto.h
#include "pubkey.h"
#include "dh.h"
#include "sha.h"
#include "eccrypto.h"
#include "ecp.h"

template <class EC, class COFACTOR_OPTION =
CryptoPP::NoCofactorMultiplication, bool DHAES_MODE = false>
struct ECIESNullT
  : public CryptoPP::DL_ES<
                CryptoPP::DL_Keys_EC<EC>,
                CryptoPP::DL_KeyAgreementAlgorithm_DH<typename EC::Point, 
COFACTOR_OPTION>,
                CryptoPP::DL_KeyDerivationAlgorithm_P1363<typename EC::Point,
DHAES_MODE, CryptoPP::P1363_KDF2<CryptoPP::SHA1> >,
                CryptoPP::DL_EncryptionAlgorithm_Xor<Null_HMAC<CryptoPP::SHA1>, 
DHAES_MODE>,
                CryptoPP::ECIES<EC> >
{
  static std::string StaticAlgorithmName() {return "ECIES with NULL T";}
};

COMPILATION ERROR (Visual C++ 6.0, Enterprise Edition)

Compiling...
ecctest6.cpp
c:\cryptopp 5.2.1\secblock.h(196) : warning C4200: nonstandard
extension used : zero-sized array in struct/union
       c:\cryptopp 5.2.1\secblock.h(257) : see reference to class
template instantiation
'CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> >' being compiled
       c:\cryptopp 5.2.1\secblock.h(360) : see reference to class
template instantiation 'CryptoPP::SecBlock<unsigned char,class
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> > >' being compile
d
       C:\EC Product Key\ecctest6\ecctest6.cpp(64) : see reference to
class template instantiation 'CryptoPP::FixedSizeSecBlock<unsigned
char,0,class CryptoPP::FixedSizeAllocatorWithCleanup<unsigned
char,0,class CryptoPP::NullAllocator<unsigned cha
r> > >' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : see reference to class
template instantiation 'Null_HMAC<class CryptoPP::SHA>' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : while compiling
class-template member function 'unsigned int __thiscall
CryptoPP::DL_EncryptionAlgorithm_Xor<class Null_HMAC<class
CryptoPP::SHA>,0>::GetSymmetricKeyLength(unsigned int) const'
c:\cryptopp 5.2.1\secblock.h(197) : error C2229: class
'CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> >' has an illegal zero-sized
array
       c:\cryptopp 5.2.1\secblock.h(257) : see reference to class
template instantiation
'CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> >' being compiled
       c:\cryptopp 5.2.1\secblock.h(360) : see reference to class
template instantiation 'CryptoPP::SecBlock<unsigned char,class
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> > >' being compile
d
       C:\EC Product Key\ecctest6\ecctest6.cpp(64) : see reference to
class template instantiation 'CryptoPP::FixedSizeSecBlock<unsigned
char,0,class CryptoPP::FixedSizeAllocatorWithCleanup<unsigned
char,0,class CryptoPP::NullAllocator<unsigned cha
r> > >' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : see reference to class
template instantiation 'Null_HMAC<class CryptoPP::SHA>' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : while compiling
class-template member function 'unsigned int __thiscall
CryptoPP::DL_EncryptionAlgorithm_Xor<class Null_HMAC<class
CryptoPP::SHA>,0>::GetSymmetricKeyLength(unsigned int) const'
Error executing cl.exe.

Compiling...
ecctest6.cpp
c:\cryptopp 5.2.1\secblock.h(196) : warning C4200: nonstandard
extension used : zero-sized array in struct/union
       c:\cryptopp 5.2.1\secblock.h(257) : see reference to class
template instantiation
'CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> >' being compiled
       c:\cryptopp 5.2.1\secblock.h(360) : see reference to class
template instantiation 'CryptoPP::SecBlock<unsigned char,class
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> > >' being compile
d
       C:\EC Product Key\ecctest6\ecctest6.cpp(64) : see reference to
class template instantiation 'CryptoPP::FixedSizeSecBlock<unsigned
char,0,class CryptoPP::FixedSizeAllocatorWithCleanup<unsigned
char,0,class CryptoPP::NullAllocator<unsigned cha
r> > >' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : see reference to class
template instantiation 'Null_HMAC<class CryptoPP::SHA>' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : while compiling
class-template member function 'unsigned int __thiscall
CryptoPP::DL_EncryptionAlgorithm_Xor<class Null_HMAC<class
CryptoPP::SHA>,0>::GetSymmetricKeyLength(unsigned int) const'
c:\cryptopp 5.2.1\secblock.h(197) : error C2229: class
'CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> >' has an illegal zero-sized
array
       c:\cryptopp 5.2.1\secblock.h(257) : see reference to class
template instantiation
'CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> >' being compiled
       c:\cryptopp 5.2.1\secblock.h(360) : see reference to class
template instantiation 'CryptoPP::SecBlock<unsigned char,class
CryptoPP::FixedSizeAllocatorWithCleanup<unsigned char,0,class
CryptoPP::NullAllocator<unsigned char> > >' being compile
d
       C:\EC Product Key\ecctest6\ecctest6.cpp(64) : see reference to
class template instantiation 'CryptoPP::FixedSizeSecBlock<unsigned
char,0,class CryptoPP::FixedSizeAllocatorWithCleanup<unsigned
char,0,class CryptoPP::NullAllocator<unsigned cha
r> > >' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : see reference to class
template instantiation 'Null_HMAC<class CryptoPP::SHA>' being compiled
       c:\cryptopp 5.2.1\gfpcrypt.h(425) : while compiling
class-template member function 'unsigned int __thiscall
CryptoPP::DL_EncryptionAlgorithm_Xor<class Null_HMAC<class
CryptoPP::SHA>,0>::GetSymmetricKeyLength(unsigned int) const'

Reply via email to