9 #ifndef BOTAN_BIGINT_H__    10 #define BOTAN_BIGINT_H__    12 #include <botan/rng.h>    13 #include <botan/secmem.h>    14 #include <botan/mp_types.h>    28      enum Base { Octal = 8, Decimal = 10, Hexadecimal = 16, Binary = 256 };
    33      enum Sign { Negative = 0, Positive = 1 };
    80      word    operator%=(word y);
    86      BigInt& operator<<=(
size_t shift);
    92      BigInt& operator>>=(
size_t shift);
   124      bool operator !()
 const { 
return (!is_nonzero()); }
   152      s32bit cmp(
const BigInt& n, 
bool check_signs = 
true) 
const;
   158      bool is_even()
 const { 
return (get_bit(0) == 0); }
   164      bool is_odd()
  const { 
return (get_bit(0) == 1); }
   178         const size_t sw = sig_words();
   180         for(
size_t i = 0; i != sw; ++i)
   190      void set_bit(
size_t n);
   196      void clear_bit(
size_t n);
   202      void mask_bits(
size_t n);
   209      bool get_bit(
size_t n) 
const;
   218      u32bit get_substring(
size_t offset, 
size_t length) 
const;
   231      byte byte_at(
size_t n) 
const;
   239         { 
return ((n < size()) ? reg[n] : 0); }
   262      Sign reverse_sign() 
const;
   273      void set_sign(
Sign sign);
   284      size_t size()
 const { 
return get_reg().size(); }
   292         const word* x = ®[0];
   293         size_t sig = reg.size();
   295         while(sig && (x[sig-1] == 0))
   304      size_t bytes() 
const;
   317      const word* 
data()
 const { 
return ®[0]; }
   337      void assign(
const word x[], 
size_t length)
   347      void grow_reg(
size_t n);
   349      void grow_to(
size_t n);
   362      void binary_encode(
byte buf[]) 
const;
   369      void binary_decode(
const byte buf[], 
size_t length);
   381      size_t encoded_size(
Base base = Binary) 
const;
   470      BigInt(
const std::string& str);
   524    { 
return (a.
cmp(b) == 0); }
   526    { 
return (a.
cmp(b) != 0); }
   528    { 
return (a.
cmp(b) <= 0); }
   530    { 
return (a.
cmp(b) >= 0); }
   532    { 
return (a.
cmp(b) < 0); }
   534    { 
return (a.
cmp(b) > 0); }
 const SecureVector< word > & get_reg() const
bool operator!=(const OctetString &s1, const OctetString &s2)
void assign(const word x[], size_t length)
bool BOTAN_DLL operator>=(const X509_Time &, const X509_Time &)
s32bit cmp(const BigInt &n, bool check_signs=true) const
SecureVector< word > & get_reg()
bool operator==(const OctetString &s1, const OctetString &s2)
word word_at(size_t n) const
int operator>>(int fd, Pipe &pipe)
const word * data() const
SecureVector< byte > decode(DataSource &source, std::string &label)
BigInt operator%(const BigInt &n, const BigInt &mod)
unsigned long long u64bit
int operator<<(int fd, Pipe &pipe)
BigInt abs(const BigInt &n)
OctetString operator+(const OctetString &k1, const OctetString &k2)
bool BOTAN_DLL operator>(const X509_Time &, const X509_Time &)
word & operator[](size_t i)
const word & operator[](size_t i) const
BigInt operator*(const BigInt &x, const BigInt &y)
std::runtime_error Exception
void copy_mem(T *out, const T *in, size_t n)
MemoryRegion< T > & operator+=(MemoryRegion< T > &out, const MemoryRegion< T > &in)
std::string encode(const byte der[], size_t length, const std::string &label, size_t width)
bool BOTAN_DLL operator<(const X509_Time &, const X509_Time &)
void swap(Botan::BigInt &x, Botan::BigInt &y)
BigInt operator-(const BigInt &x, const BigInt &y)
bool BOTAN_DLL operator<=(const X509_Time &, const X509_Time &)
u32bit to_u32bit(const std::string &number)
void zeroise(MemoryRegion< T > &vec)
BigInt operator/(const BigInt &x, const BigInt &y)