9#ifndef BOTAN_BIGINT_H__
10#define BOTAN_BIGINT_H__
13#include <botan/secmem.h>
14#include <botan/mp_types.h>
152 s32bit cmp(
const BigInt& n,
bool check_signs =
true)
const;
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);
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;
408 static void encode(
byte buf[],
const BigInt& n, Base base = Binary);
417 static BigInt decode(
const byte buf[],
size_t length,
470 BigInt(
const std::string& str);
478 BigInt(
const byte buf[],
size_t length, Base base = Binary);
492 BigInt(Sign sign,
size_t n);
501 BigInt(NumberType type,
size_t n);
503 void shrink_to_fit();
506 const std::vector<BigInt>& vec,
517BigInt BOTAN_DLL
operator+(
const BigInt& x,
const BigInt& y);
518BigInt BOTAN_DLL
operator-(
const BigInt& x,
const BigInt& y);
519BigInt BOTAN_DLL
operator*(
const BigInt& x,
const BigInt& y);
520BigInt BOTAN_DLL
operator/(
const BigInt& x,
const BigInt& d);
521BigInt BOTAN_DLL
operator%(
const BigInt& x,
const BigInt& m);
522word BOTAN_DLL
operator%(
const BigInt& x, word m);
523BigInt BOTAN_DLL
operator<<(
const BigInt& x,
size_t n);
524BigInt BOTAN_DLL
operator>>(
const BigInt& x,
size_t n);
530 {
return (a.
cmp(b) == 0); }
532 {
return (a.
cmp(b) != 0); }
534 {
return (a.
cmp(b) <= 0); }
536 {
return (a.
cmp(b) >= 0); }
538 {
return (a.
cmp(b) < 0); }
540 {
return (a.
cmp(b) > 0); }
545BOTAN_DLL std::ostream&
operator<<(std::ostream&,
const BigInt&);
546BOTAN_DLL std::istream&
operator>>(std::istream&, BigInt&);
BigInt & operator>>=(size_t shift)
BigInt & operator/=(const BigInt &y)
SecureVector< word > & get_reg()
BigInt & operator*=(const BigInt &y)
void assign(const word x[], size_t length)
const word * data() const
word word_at(size_t n) const
BigInt & operator-=(const BigInt &y)
s32bit cmp(const BigInt &n, bool check_signs=true) const
BigInt & operator+=(const BigInt &y)
BigInt & operator%=(const BigInt &y)
BigInt & operator<<=(size_t shift)
word & operator[](size_t i)
const word & operator[](size_t i) const
bool get_bit(size_t n) const
const SecureVector< word > & get_reg() const
bool BOTAN_DLL operator>(const X509_Time &, const X509_Time &)
void zeroise(MemoryRegion< T > &vec)
int operator>>(int fd, Pipe &pipe)
bool BOTAN_DLL operator<(const X509_Time &, const X509_Time &)
bool BOTAN_DLL operator>=(const X509_Time &, const X509_Time &)
BigInt operator/(const BigInt &x, const BigInt &y)
OctetString operator+(const OctetString &k1, const OctetString &k2)
BigInt abs(const BigInt &n)
unsigned long long u64bit
std::runtime_error Exception
void copy_mem(T *out, const T *in, size_t n)
u32bit to_u32bit(const std::string &number)
BigInt operator*(const BigInt &x, const BigInt &y)
bool operator!=(const OctetString &s1, const OctetString &s2)
bool BOTAN_DLL operator<=(const X509_Time &, const X509_Time &)
BigInt operator-(const BigInt &x, const BigInt &y)
int operator<<(int fd, Pipe &pipe)
BigInt operator%(const BigInt &n, const BigInt &mod)
bool operator==(const OctetString &s1, const OctetString &s2)
void swap(Botan::MemoryRegion< T > &x, Botan::MemoryRegion< T > &y)