Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panama.h

00001 #ifndef CRYPTOPP_PANAMA_H
00002 #define CRYPTOPP_PANAMA_H
00003 
00004 #include "cryptlib.h"
00005 #include "misc.h"
00006 #include "iterhash.h"
00007 
00008 NAMESPACE_BEGIN(CryptoPP)
00009 
00011 class Panama
00012 {
00013 public:
00014         Panama();
00015         void Reset();
00016         void Iterate(unsigned int count, const word32 *p=NULL, word32 *z=NULL, const word32 *y=NULL);
00017 
00018 protected:
00019         typedef word32 Stage[8];
00020         SecBlock<word32> m_state;
00021         unsigned int m_bstart;
00022 };
00023 
00025 template <bool H = false>       // default to little endian
00026 class PanamaHash : protected Panama, public IteratedHash<word32, H, 32>
00027 {
00028 public:
00029         enum {DIGESTSIZE = 32};
00030         PanamaHash() : IteratedHash<word32, H, 32>(0) {}
00031         unsigned int DigestSize() const {return DIGESTSIZE;}
00032         void Final(byte *hash);
00033 
00034 protected:
00035         void Init() {Panama::Reset();}
00036         void vTransform(const word32 *data) {Iterate(1, data);} // push
00037         unsigned int HashMultipleBlocks(const word32 *input, unsigned int length);
00038 };
00039 
00041 template <bool H = false>       // default to little endian
00042 class PanamaMAC : public PanamaHash<H>, public MessageAuthenticationCode, public VariableKeyLength<32, 0, UINT_MAX>
00043 {
00044 public:
00045         PanamaMAC(const byte *key, unsigned int keylength=DEFAULT_KEYLENGTH) {Update(key, keylength);}
00046 };
00047 
00049 template <bool H = false>       // default to little endian
00050 class PanamaCipher : protected Panama, public StreamCipher, public FixedKeyLength<32>
00051 {
00052 public:
00053         enum {HIGHFIRST = H, IVLENGTH = 32};
00054         PanamaCipher(const byte *key, const byte *iv=NULL);
00055 
00056         byte ProcessByte(byte input)
00057                 {PanamaCipher::ProcessString(&input, &input, 1); return input;}
00058         void ProcessString(byte *inoutString, unsigned int length)
00059                 {PanamaCipher::ProcessString(inoutString, inoutString, length);}
00060         void ProcessString(byte *outString, const byte *inString, unsigned int length);
00061 
00062 protected:
00063         inline static void CorrectEndianess(word32 *out, const word32 *in, unsigned int byteCount)
00064         {
00065                 if (!CheckEndianess(HIGHFIRST))
00066                         byteReverse(out, in, byteCount);
00067                 else if (in!=out)
00068                         memcpy(out, in, byteCount);
00069         }
00070 
00071         SecBlock<word32> m_buf;
00072         unsigned int m_leftOver;
00073 };
00074 
00075 NAMESPACE_END
00076 
00077 #endif

Generated at Mon Jan 15 01:16:34 2001 for Crypto++ by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000