diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-07-20 16:21:49 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-07-20 16:21:49 +0000 |
commit | f424a18112032cf61d2871a6b91a5af607c171ae (patch) | |
tree | 88fedc4e28941ceecda7026f0b06eba6271f91d5 /plugins/CryptoPP/crypto/src/gf256.h | |
parent | bfe1bd0fc087be44c70904aee0fe4276643d206d (diff) |
CryptoPP:
changed folder structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@1083 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP/crypto/src/gf256.h')
-rw-r--r-- | plugins/CryptoPP/crypto/src/gf256.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/CryptoPP/crypto/src/gf256.h b/plugins/CryptoPP/crypto/src/gf256.h new file mode 100644 index 0000000000..24a86f5cd2 --- /dev/null +++ b/plugins/CryptoPP/crypto/src/gf256.h @@ -0,0 +1,66 @@ +#ifndef CRYPTOPP_GF256_H
+#define CRYPTOPP_GF256_H
+
+#include "cryptlib.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! GF(256) with polynomial basis
+class GF256
+{
+public:
+ typedef byte Element;
+ typedef int RandomizationParameter;
+
+ GF256(byte modulus) : m_modulus(modulus) {}
+
+ Element RandomElement(RandomNumberGenerator &rng, int ignored = 0) const
+ {return rng.GenerateByte();}
+
+ bool Equal(Element a, Element b) const
+ {return a==b;}
+
+ Element Zero() const
+ {return 0;}
+
+ Element Add(Element a, Element b) const
+ {return a^b;}
+
+ Element& Accumulate(Element &a, Element b) const
+ {return a^=b;}
+
+ Element Inverse(Element a) const
+ {return a;}
+
+ Element Subtract(Element a, Element b) const
+ {return a^b;}
+
+ Element& Reduce(Element &a, Element b) const
+ {return a^=b;}
+
+ Element Double(Element a) const
+ {return 0;}
+
+ Element One() const
+ {return 1;}
+
+ Element Multiply(Element a, Element b) const;
+
+ Element Square(Element a) const
+ {return Multiply(a, a);}
+
+ bool IsUnit(Element a) const
+ {return a != 0;}
+
+ Element MultiplicativeInverse(Element a) const;
+
+ Element Divide(Element a, Element b) const
+ {return Multiply(a, MultiplicativeInverse(b));}
+
+private:
+ word m_modulus;
+};
+
+NAMESPACE_END
+
+#endif
|