summaryrefslogtreecommitdiff
path: root/gf2n.h
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2005-07-12 04:23:32 +0000
committerweidai <weidai11@users.noreply.github.com>2005-07-12 04:23:32 +0000
commit1db8ea50840eb47f0f7d8f3c30d8e0916932ce90 (patch)
tree4b03760892a97a9bc452ebe8b7793bbebd402ad4 /gf2n.h
parent31068bd68590654dc218bbb183a2ca71bb4af08b (diff)
downloadcryptopp-git-1db8ea50840eb47f0f7d8f3c30d8e0916932ce90.tar.gz
port to MSVC .NET 2005 beta 2
Diffstat (limited to 'gf2n.h')
-rw-r--r--gf2n.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/gf2n.h b/gf2n.h
index 4ffa1458..6567928f 100644
--- a/gf2n.h
+++ b/gf2n.h
@@ -41,28 +41,28 @@ public:
and most significant bit as coefficient to x^(WORD_BITS-1)
bitLength denotes how much memory to allocate initially
*/
- PolynomialMod2(word value, unsigned int bitLength=WORD_BITS);
+ PolynomialMod2(word value, size_t bitLength=WORD_BITS);
//! convert from big-endian byte array
- PolynomialMod2(const byte *encodedPoly, unsigned int byteCount)
+ PolynomialMod2(const byte *encodedPoly, size_t byteCount)
{Decode(encodedPoly, byteCount);}
//! convert from big-endian form stored in a BufferedTransformation
- PolynomialMod2(BufferedTransformation &encodedPoly, unsigned int byteCount)
+ PolynomialMod2(BufferedTransformation &encodedPoly, size_t byteCount)
{Decode(encodedPoly, byteCount);}
//! create a random polynomial uniformly distributed over all polynomials with degree less than bitcount
- PolynomialMod2(RandomNumberGenerator &rng, unsigned int bitcount)
+ PolynomialMod2(RandomNumberGenerator &rng, size_t bitcount)
{Randomize(rng, bitcount);}
//! return x^i
- static PolynomialMod2 Monomial(unsigned i);
+ static PolynomialMod2 Monomial(size_t i);
//! return x^t0 + x^t1 + x^t2
- static PolynomialMod2 Trinomial(unsigned t0, unsigned t1, unsigned t2);
+ static PolynomialMod2 Trinomial(size_t t0, size_t t1, size_t t2);
//! return x^t0 + x^t1 + x^t2 + x^t3 + x^t4
- static PolynomialMod2 Pentanomial(unsigned t0, unsigned t1, unsigned t2, unsigned int t3, unsigned int t4);
+ static PolynomialMod2 Pentanomial(size_t t0, size_t t1, size_t t2, size_t t3, size_t t4);
//! return x^(n-1) + ... + x + 1
- static PolynomialMod2 AllOnes(unsigned n);
+ static PolynomialMod2 AllOnes(size_t n);
//!
static const PolynomialMod2 &Zero();
@@ -80,20 +80,20 @@ public:
/*! if outputLen < MinEncodedSize, the most significant bytes will be dropped
if outputLen > MinEncodedSize, the most significant bytes will be padded
*/
- unsigned int Encode(byte *output, unsigned int outputLen) const;
+ void Encode(byte *output, size_t outputLen) const;
//!
- unsigned int Encode(BufferedTransformation &bt, unsigned int outputLen) const;
+ void Encode(BufferedTransformation &bt, size_t outputLen) const;
//!
- void Decode(const byte *input, unsigned int inputLen);
+ void Decode(const byte *input, size_t inputLen);
//!
//* Precondition: bt.MaxRetrievable() >= inputLen
- void Decode(BufferedTransformation &bt, unsigned int inputLen);
+ void Decode(BufferedTransformation &bt, size_t inputLen);
//! encode value as big-endian octet string
- void DEREncodeAsOctetString(BufferedTransformation &bt, unsigned int length) const;
+ void DEREncodeAsOctetString(BufferedTransformation &bt, size_t length) const;
//! decode value as big-endian octet string
- void BERDecodeAsOctetString(BufferedTransformation &bt, unsigned int length);
+ void BERDecodeAsOctetString(BufferedTransformation &bt, size_t length);
//@}
//! \name ACCESSORS
@@ -106,16 +106,16 @@ public:
unsigned int WordCount() const;
//! return the n-th bit, n=0 being the least significant bit
- bool GetBit(unsigned int n) const {return GetCoefficient(n)!=0;}
+ bool GetBit(size_t n) const {return GetCoefficient(n)!=0;}
//! return the n-th byte
- byte GetByte(unsigned int n) const;
+ byte GetByte(size_t n) const;
//! the zero polynomial will return a degree of -1
signed int Degree() const {return BitCount()-1;}
//! degree + 1
unsigned int CoefficientCount() const {return BitCount();}
//! return coefficient for x^i
- int GetCoefficient(unsigned int i) const
+ int GetCoefficient(size_t i) const
{return (i/WORD_BITS < reg.size()) ? int(reg[i/WORD_BITS] >> (i % WORD_BITS)) & 1 : 0;}
//! return coefficient for x^i
int operator[](unsigned int i) const {return GetCoefficient(i);}
@@ -150,15 +150,15 @@ public:
PolynomialMod2& operator>>=(unsigned int);
//!
- void Randomize(RandomNumberGenerator &rng, unsigned int bitcount);
+ void Randomize(RandomNumberGenerator &rng, size_t bitcount);
//!
- void SetBit(unsigned int i, int value = 1);
+ void SetBit(size_t i, int value = 1);
//! set the n-th byte to value
- void SetByte(unsigned int n, byte value);
+ void SetByte(size_t n, byte value);
//!
- void SetCoefficient(unsigned int i, int value) {SetBit(i, value);}
+ void SetCoefficient(size_t i, int value) {SetBit(i, value);}
//!
void swap(PolynomialMod2 &a) {reg.swap(a.reg);}
@@ -300,7 +300,7 @@ public:
{return m;}
unsigned int MaxElementByteLength() const
- {return BitsToBytes(MaxElementBitLength());}
+ {return (unsigned int)BitsToBytes(MaxElementBitLength());}
Element SquareRoot(const Element &a) const;