gf256.h

00001 #ifndef CRYPTOPP_GF256_H
00002 #define CRYPTOPP_GF256_H
00003 
00004 #include "cryptlib.h"
00005 
00006 NAMESPACE_BEGIN(CryptoPP)
00007 
00008 //! GF(256) with polynomial basis
00009 class GF256
00010 {
00011 public:
00012         typedef byte Element;
00013         typedef int RandomizationParameter;
00014 
00015         GF256(byte modulus) : m_modulus(modulus) {}
00016 
00017         Element RandomElement(RandomNumberGenerator &rng, int ignored = 0) const
00018                 {return rng.GenerateByte();}
00019 
00020         bool Equal(Element a, Element b) const
00021                 {return a==b;}
00022 
00023         Element Zero() const
00024                 {return 0;}
00025 
00026         Element Add(Element a, Element b) const
00027                 {return a^b;}
00028 
00029         Element& Accumulate(Element &a, Element b) const
00030                 {return a^=b;}
00031 
00032         Element Inverse(Element a) const
00033                 {return a;}
00034 
00035         Element Subtract(Element a, Element b) const
00036                 {return a^b;}
00037 
00038         Element& Reduce(Element &a, Element b) const
00039                 {return a^=b;}
00040 
00041         Element Double(Element a) const
00042                 {return 0;}
00043 
00044         Element One() const
00045                 {return 1;}
00046 
00047         Element Multiply(Element a, Element b) const;
00048 
00049         Element Square(Element a) const
00050                 {return Multiply(a, a);}
00051 
00052         bool IsUnit(Element a) const
00053                 {return a != 0;}
00054 
00055         Element MultiplicativeInverse(Element a) const;
00056 
00057         Element Divide(Element a, Element b) const
00058                 {return Multiply(a, MultiplicativeInverse(b));}
00059 
00060 private:
00061         word m_modulus;
00062 };
00063 
00064 NAMESPACE_END
00065 
00066 #endif

Generated on Sat Dec 23 02:07:07 2006 for Crypto++ by  doxygen 1.5.1-p1