summaryrefslogtreecommitdiff
path: root/modarith.h
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2005-01-20 04:19:35 +0000
committerweidai <weidai11@users.noreply.github.com>2005-01-20 04:19:35 +0000
commitb3924f2108c0b0825060e91f6fde8202ce35624d (patch)
tree1f61e8bf59450a028415e5a3f08565a6ceb86afe /modarith.h
parent79e29d0de49969af44474cc890cffd7b1d6b1a4b (diff)
downloadcryptopp-git-b3924f2108c0b0825060e91f6fde8202ce35624d.tar.gz
changes done for FIPS-140 lab code drop
Diffstat (limited to 'modarith.h')
-rw-r--r--modarith.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/modarith.h b/modarith.h
index f7cb6be7..4375c9f4 100644
--- a/modarith.h
+++ b/modarith.h
@@ -24,10 +24,10 @@ public:
typedef Integer Element;
ModularArithmetic(const Integer &modulus = Integer::One())
- : modulus(modulus), result((word)0, modulus.reg.size()) {}
+ : m_modulus(modulus), m_result((word)0, modulus.reg.size()) {}
ModularArithmetic(const ModularArithmetic &ma)
- : modulus(ma.modulus), result((word)0, modulus.reg.size()) {}
+ : m_modulus(ma.m_modulus), m_result((word)0, m_modulus.reg.size()) {}
ModularArithmetic(BufferedTransformation &bt); // construct from BER encoded parameters
@@ -38,13 +38,13 @@ public:
void DEREncodeElement(BufferedTransformation &out, const Element &a) const;
void BERDecodeElement(BufferedTransformation &in, Element &a) const;
- const Integer& GetModulus() const {return modulus;}
- void SetModulus(const Integer &newModulus) {modulus = newModulus; result.reg.resize(modulus.reg.size());}
+ const Integer& GetModulus() const {return m_modulus;}
+ void SetModulus(const Integer &newModulus) {m_modulus = newModulus; m_result.reg.resize(m_modulus.reg.size());}
virtual bool IsMontgomeryRepresentation() const {return false;}
virtual Integer ConvertIn(const Integer &a) const
- {return a%modulus;}
+ {return a%m_modulus;}
virtual Integer ConvertOut(const Integer &a) const
{return a;}
@@ -74,16 +74,16 @@ public:
{return Integer::One();}
const Integer& Multiply(const Integer &a, const Integer &b) const
- {return result1 = a*b%modulus;}
+ {return m_result1 = a*b%m_modulus;}
const Integer& Square(const Integer &a) const
- {return result1 = a.Squared()%modulus;}
+ {return m_result1 = a.Squared()%m_modulus;}
bool IsUnit(const Integer &a) const
- {return Integer::Gcd(a, modulus).IsUnit();}
+ {return Integer::Gcd(a, m_modulus).IsUnit();}
const Integer& MultiplicativeInverse(const Integer &a) const
- {return result1 = a.InverseMod(modulus);}
+ {return m_result1 = a.InverseMod(m_modulus);}
const Integer& Divide(const Integer &a, const Integer &b) const
{return Multiply(a, MultiplicativeInverse(b));}
@@ -93,25 +93,25 @@ public:
void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const;
unsigned int MaxElementBitLength() const
- {return (modulus-1).BitCount();}
+ {return (m_modulus-1).BitCount();}
unsigned int MaxElementByteLength() const
- {return (modulus-1).ByteCount();}
+ {return (m_modulus-1).ByteCount();}
Element RandomElement( RandomNumberGenerator &rng , const RandomizationParameter &ignore_for_now = 0 ) const
// left RandomizationParameter arg as ref in case RandomizationParameter becomes a more complicated struct
{
- return Element( rng , Integer( (long) 0) , modulus - Integer( (long) 1 ) ) ;
+ return Element( rng , Integer( (long) 0) , m_modulus - Integer( (long) 1 ) ) ;
}
bool operator==(const ModularArithmetic &rhs) const
- {return modulus == rhs.modulus;}
+ {return m_modulus == rhs.m_modulus;}
static const RandomizationParameter DefaultRandomizationParameter ;
protected:
- Integer modulus;
- mutable Integer result, result1;
+ Integer m_modulus;
+ mutable Integer m_result, m_result1;
};
@@ -129,12 +129,12 @@ public:
bool IsMontgomeryRepresentation() const {return true;}
Integer ConvertIn(const Integer &a) const
- {return (a<<(WORD_BITS*modulus.reg.size()))%modulus;}
+ {return (a<<(WORD_BITS*m_modulus.reg.size()))%m_modulus;}
Integer ConvertOut(const Integer &a) const;
const Integer& MultiplicativeIdentity() const
- {return result1 = Integer::Power2(WORD_BITS*modulus.reg.size())%modulus;}
+ {return m_result1 = Integer::Power2(WORD_BITS*m_modulus.reg.size())%m_modulus;}
const Integer& Multiply(const Integer &a, const Integer &b) const;
@@ -149,8 +149,8 @@ public:
{AbstractRing<Integer>::SimultaneousExponentiate(results, base, exponents, exponentsCount);}
private:
- Integer u;
- mutable SecAlignedWordBlock workspace;
+ Integer m_u;
+ mutable SecAlignedWordBlock m_workspace;
};
NAMESPACE_END