• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

authenc.h

00001 #ifndef CRYPTOPP_AUTHENC_H
00002 #define CRYPTOPP_AUTHENC_H
00003 
00004 #include "cryptlib.h"
00005 #include "secblock.h"
00006 
00007 NAMESPACE_BEGIN(CryptoPP)
00008 
00009 //! .
00010 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AuthenticatedSymmetricCipherBase : public AuthenticatedSymmetricCipher
00011 {
00012 public:
00013         AuthenticatedSymmetricCipherBase() : m_state(State_Start) {}
00014 
00015         bool IsRandomAccess() const {return false;}
00016         bool IsSelfInverting() const {return true;}
00017         void UncheckedSetKey(const byte *,unsigned int,const CryptoPP::NameValuePairs &) {assert(false);}
00018 
00019         void SetKey(const byte *userKey, size_t keylength, const NameValuePairs &params);
00020         void Restart() {if (m_state > State_KeySet) m_state = State_KeySet;}
00021         void Resynchronize(const byte *iv, int length=-1);
00022         void Update(const byte *input, size_t length);
00023         void ProcessData(byte *outString, const byte *inString, size_t length);
00024         void TruncatedFinal(byte *mac, size_t macSize);
00025 
00026 protected:
00027         void AuthenticateData(const byte *data, size_t len);
00028         const SymmetricCipher & GetSymmetricCipher() const {return const_cast<AuthenticatedSymmetricCipherBase *>(this)->AccessSymmetricCipher();};
00029 
00030         virtual SymmetricCipher & AccessSymmetricCipher() =0;
00031         virtual bool AuthenticationIsOnPlaintext() const =0;
00032         virtual unsigned int AuthenticationBlockSize() const =0;
00033         virtual void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs &params) =0;
00034         virtual void Resync(const byte *iv, size_t len) =0;
00035         virtual size_t AuthenticateBlocks(const byte *data, size_t len) =0;
00036         virtual void AuthenticateLastHeaderBlock() =0;
00037         virtual void AuthenticateLastConfidentialBlock() {}
00038         virtual void AuthenticateLastFooterBlock(byte *mac, size_t macSize) =0;
00039 
00040         enum State {State_Start, State_KeySet, State_IVSet, State_AuthUntransformed, State_AuthTransformed, State_AuthFooter};
00041         State m_state;
00042         unsigned int m_bufferedDataLength;
00043         lword m_totalHeaderLength, m_totalMessageLength, m_totalFooterLength;
00044         AlignedSecByteBlock m_buffer;
00045 };
00046 
00047 NAMESPACE_END
00048 
00049 #endif

Generated on Mon Aug 9 2010 15:56:32 for Crypto++ by  doxygen 1.7.1