Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

gf256.cpp

00001 // gf256.cpp - written and placed in the public domain by Wei Dai 00002 00003 #include "pch.h" 00004 #include "gf256.h" 00005 00006 NAMESPACE_BEGIN(CryptoPP) 00007 00008 GF256::Element GF256::Multiply(Element a, Element b) const 00009 { 00010 word result = 0, t = b; 00011 00012 for (unsigned int i=0; i<8; i++) 00013 { 00014 result <<= 1; 00015 if (result & 0x100) 00016 result ^= m_modulus; 00017 00018 t <<= 1; 00019 if (t & 0x100) 00020 result ^= a; 00021 } 00022 00023 return (GF256::Element) result; 00024 } 00025 00026 GF256::Element GF256::MultiplicativeInverse(Element a) const 00027 { 00028 Element result = a; 00029 for (int i=1; i<7; i++) 00030 result = Multiply(Square(result), a); 00031 return Square(result); 00032 } 00033 00034 NAMESPACE_END

Generated on Fri Aug 27 11:32:36 2004 for Crypto++ by doxygen 1.3.8