libcryptosec
Public Member Functions | Protected Attributes | List of all members

Classe usada para representar números grandes. A limitação do tamanho do número depende da memória disponível. More...

#include <BigInteger.h>

Public Member Functions

 BigInteger () throw (BigIntegerException)
 
 BigInteger (BIGNUM const *bn) throw (BigIntegerException)
 
 BigInteger (long val) throw (BigIntegerException)
 
 BigInteger (ASN1_INTEGER *val) throw (BigIntegerException)
 
 BigInteger (ByteArray &b) throw (BigIntegerException)
 
 BigInteger (BigInteger const &b) throw (BigIntegerException)
 
 BigInteger (std::string dec) throw (BigIntegerException)
 
virtual ~BigInteger ()
 
void setValue (const long val=0) throw (BigIntegerException)
 
double getValue () const throw (BigIntegerException)
 
bool isNegative () const throw ()
 
ASN1_INTEGER * getASN1Value () const throw (BigIntegerException)
 
ByteArraygetBinValue () const throw (BigIntegerException)
 
BIGNUM const * getBIGNUM () const throw ()
 
std::string toHex () const throw ()
 
std::string toDec () const throw ()
 
void setHexValue (std::string hex) throw (BigIntegerException)
 
void setDecValue (std::string dec) throw (BigIntegerException)
 
void setRandValue (int numBits=64) throw (BigIntegerException)
 
void setNegative (bool neg=true) throw ()
 
int size () const throw ()
 
BigIntegeradd (BigInteger const &a) throw (BigIntegerException)
 
BigIntegeradd (long const a) throw (BigIntegerException)
 
BigIntegersub (BigInteger const &a) throw (BigIntegerException)
 
BigIntegersub (long const a) throw (BigIntegerException)
 
BigIntegermul (BigInteger const &a) throw (BigIntegerException)
 
BigIntegermul (long const a) throw (BigIntegerException)
 
BigInteger operator* (BigInteger const &a) const throw (BigIntegerException)
 
BigInteger operator* (long const c) const throw (BigIntegerException)
 
BigIntegerdiv (BigInteger const &a) throw (BigIntegerException)
 
BigIntegerdiv (long const a) throw (BigIntegerException)
 
BigInteger operator/ (BigInteger const &a) const throw (BigIntegerException)
 
BigInteger operator/ (long const c) const throw (BigIntegerException)
 
BigIntegermod (BigInteger const &a) throw (BigIntegerException)
 
BigIntegermod (long const a) throw (BigIntegerException)
 
BigInteger operator% (BigInteger const &a) const throw (BigIntegerException)
 
BigInteger operator% (long const c) const throw (BigIntegerException)
 
int compare (BigInteger const &a) const throw ()
 
BigInteger operator+ (BigInteger const &c) const throw (BigIntegerException)
 
BigInteger operator+ (long const c) const throw (BigIntegerException)
 
BigIntegeroperator+= (BigInteger const &c) throw (BigIntegerException)
 
BigIntegeroperator+= (long const c) throw (BigIntegerException)
 
BigInteger operator- (BigInteger const &c) const throw (BigIntegerException)
 
BigInteger operator- (long const c) const throw (BigIntegerException)
 
bool operator== (BigInteger const &c) const throw ()
 
bool operator== (long const c) const throw (BigIntegerException)
 
bool operator!= (BigInteger const &c) const throw ()
 
bool operator!= (long const c) const throw (BigIntegerException)
 
bool operator> (BigInteger const &c) const throw ()
 
bool operator> (long const c) const throw (BigIntegerException)
 
bool operator>= (BigInteger const &c) const throw ()
 
bool operator>= (long const c) const throw (BigIntegerException)
 
bool operator< (BigInteger const &c) const throw ()
 
bool operator< (long const c) const throw (BigIntegerException)
 
bool operator<= (BigInteger const &c) const throw ()
 
bool operator<= (long const c) const throw (BigIntegerException)
 
bool operator! () const throw ()
 
bool operator|| (BigInteger const &c) const throw ()
 
bool operator|| (long const c) const throw (BigIntegerException)
 
bool operator && (BigInteger const &c) const throw ()
 
bool operator && (long const c) const throw (BigIntegerException)
 
BigIntegeroperator= (BigInteger const &c) throw (BigIntegerException)
 
BigIntegeroperator= (long const c) throw (BigIntegerException)
 

Protected Attributes

BIGNUM * bigInt
 

Detailed Description

Classe usada para representar números grandes. A limitação do tamanho do número depende da memória disponível.

Constructor & Destructor Documentation

◆ BigInteger() [1/7]

BigInteger::BigInteger ( )
throw (BigIntegerException
)

Construtor padrão. Cria um objeto BigInteger com o valor inteiro 0.

Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o BigInteger.

◆ BigInteger() [2/7]

BigInteger::BigInteger ( BIGNUM const *  bn)
throw (BigIntegerException
)

BigInteger a partir de um estrutura BIGNUM do OpenSSL.

Parameters
bnponteiro para estrutra constante BIGNUM.
Exceptions
BigIntegerExceptionno caso de erro interno do OpenSSL ao criar o BigInteger.

◆ BigInteger() [3/7]

BigInteger::BigInteger ( long  val)
throw (BigIntegerException
)

BigInteger a partir de um tipo primitivo (unsigned long).

Parameters
valvalor inteiro.
Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o BigInteger.

◆ BigInteger() [4/7]

BigInteger::BigInteger ( ASN1_INTEGER *  val)
throw (BigIntegerException
)

BigInteger a partir de uma estrutura ASN1_INTEGER do OpenSSL.

Parameters
valponteiro para estrutura ASN1_INTEGER.
Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o BigInteger.

◆ BigInteger() [5/7]

BigInteger::BigInteger ( ByteArray b)
throw (BigIntegerException
)

BigInteger a partir de um objeto ByteArray.

Parameters
valreferência para objeto constante ByteArray.
Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o BigInteger ou devido a um erro interno do OpenSSL.

◆ BigInteger() [6/7]

BigInteger::BigInteger ( BigInteger const &  b)
throw (BigIntegerException
)

Construtor de cópia.

Parameters
breferência para um objeto constante BigInteger.
Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o BigInteger.

◆ BigInteger() [7/7]

BigInteger::BigInteger ( std::string  dec)
throw (BigIntegerException
)

BigInteger a partir do string de um número inteiro na base decimal.

Parameters
decstring contendo um número inteiro em base 10.
Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o BigInteger.

◆ ~BigInteger()

BigInteger::~BigInteger ( )
virtual

Destrutor padrão

Member Function Documentation

◆ add() [1/2]

BigInteger & BigInteger::add ( BigInteger const &  a)
throw (BigIntegerException
)

Soma os valores inteiros entre dois BigIntegers.

Parameters
areferência para objeto constante BigInteger.
Returns
referência para objeto BigInteger com o resultado da soma.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ add() [2/2]

BigInteger & BigInteger::add ( long const  a)
throw (BigIntegerException
)

◆ compare()

int BigInteger::compare ( BigInteger const &  a) const
throw (
)

◆ div() [1/2]

BigInteger & BigInteger::div ( BigInteger const &  a)
throw (BigIntegerException
)

◆ div() [2/2]

BigInteger & BigInteger::div ( long const  a)
throw (BigIntegerException
)

◆ getASN1Value()

ASN1_INTEGER * BigInteger::getASN1Value ( ) const
throw (BigIntegerException
)

Retorna estrutura ASN1_INTEGER com o valor do BigInteger.

Returns
estrutura ASN1_INTEGER.
Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o ASN1_INTEGER.

◆ getBIGNUM()

BIGNUM const * BigInteger::getBIGNUM ( ) const
throw (
)

Retorna ponteiro para estrutura constante BIGNUM membro de BigInteger.

Returns
ponteiro para estrutura constante BIGNUM.

◆ getBinValue()

ByteArray * BigInteger::getBinValue ( ) const
throw (BigIntegerException
)

Retorna ponteiro para um objeto ByteArray com o valor do BigInteger. O objeto ByteArray tem codificação mpi (inclui sinal) e deve ser deletado.

Returns
ponteiro para objeto ByteArray.
Exceptions
BigIntegerExceptionno caso de falta de memória ao criar o ByteArray.

◆ getValue()

double BigInteger::getValue ( ) const
throw (BigIntegerException
)

Retorna o valor inteiro correspondente do BigInteger.

Returns
valor inteiro do BigInteger.
Exceptions
BigIntegerExceptioncaso o valor do BigInteger não possa ser representado em um unsigned long (overflow).

◆ isNegative()

bool BigInteger::isNegative ( ) const
throw (
)

Retorna se o BigInteger é negativo.

Returns
true se o BigInteger é negativo, false caso contrário.

◆ mod() [1/2]

BigInteger & BigInteger::mod ( BigInteger const &  a)
throw (BigIntegerException
)

◆ mod() [2/2]

BigInteger & BigInteger::mod ( long const  a)
throw (BigIntegerException
)

◆ mul() [1/2]

BigInteger & BigInteger::mul ( BigInteger const &  a)
throw (BigIntegerException
)

◆ mul() [2/2]

BigInteger & BigInteger::mul ( long const  a)
throw (BigIntegerException
)

◆ operator &&() [1/2]

bool BigInteger::operator&& ( BigInteger const &  c) const
throw (
)

◆ operator &&() [2/2]

bool BigInteger::operator&& ( long const  c) const
throw (BigIntegerException
)

◆ operator!()

bool BigInteger::operator! ( ) const
throw (
)

◆ operator!=() [1/2]

bool BigInteger::operator!= ( BigInteger const &  c) const
throw (
)

◆ operator!=() [2/2]

bool BigInteger::operator!= ( long const  c) const
throw (BigIntegerException
)

◆ operator%() [1/2]

BigInteger BigInteger::operator% ( BigInteger const &  a) const
throw (BigIntegerException
)

◆ operator%() [2/2]

BigInteger BigInteger::operator% ( long const  c) const
throw (BigIntegerException
)

◆ operator*() [1/2]

BigInteger BigInteger::operator* ( BigInteger const &  a) const
throw (BigIntegerException
)

◆ operator*() [2/2]

BigInteger BigInteger::operator* ( long const  c) const
throw (BigIntegerException
)

◆ operator+() [1/2]

BigInteger BigInteger::operator+ ( BigInteger const &  c) const
throw (BigIntegerException
)

Operador de soma.

Parameters
creferência para objeto constante BigInteger.
Returns
referência para objeto BigInteger com o resultado da soma.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ operator+() [2/2]

BigInteger BigInteger::operator+ ( long const  c) const
throw (BigIntegerException
)

◆ operator+=() [1/2]

BigInteger & BigInteger::operator+= ( BigInteger const &  c)
throw (BigIntegerException
)

◆ operator+=() [2/2]

BigInteger & BigInteger::operator+= ( long const  c)
throw (BigIntegerException
)

◆ operator-() [1/2]

BigInteger BigInteger::operator- ( BigInteger const &  c) const
throw (BigIntegerException
)

Operador de subtração.

Parameters
creferência para objeto constante BigInteger.
Returns
referência para objeto BigInteger com o resultado da subtração.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ operator-() [2/2]

BigInteger BigInteger::operator- ( long const  c) const
throw (BigIntegerException
)

◆ operator/() [1/2]

BigInteger BigInteger::operator/ ( BigInteger const &  a) const
throw (BigIntegerException
)

◆ operator/() [2/2]

BigInteger BigInteger::operator/ ( long const  c) const
throw (BigIntegerException
)

◆ operator<() [1/2]

bool BigInteger::operator< ( BigInteger const &  c) const
throw (
)

◆ operator<() [2/2]

bool BigInteger::operator< ( long const  c) const
throw (BigIntegerException
)

◆ operator<=() [1/2]

bool BigInteger::operator<= ( BigInteger const &  c) const
throw (
)

◆ operator<=() [2/2]

bool BigInteger::operator<= ( long const  c) const
throw (BigIntegerException
)

◆ operator=() [1/2]

BigInteger & BigInteger::operator= ( BigInteger const &  c)
throw (BigIntegerException
)

Operador de atribuição.

Parameters
creferência para objeto constante BigInteger.
Returns
referência para objeto BigInteger.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ operator=() [2/2]

BigInteger & BigInteger::operator= ( long const  c)
throw (BigIntegerException
)

◆ operator==() [1/2]

bool BigInteger::operator== ( BigInteger const &  c) const
throw (
)

◆ operator==() [2/2]

bool BigInteger::operator== ( long const  c) const
throw (BigIntegerException
)

◆ operator>() [1/2]

bool BigInteger::operator> ( BigInteger const &  c) const
throw (
)

◆ operator>() [2/2]

bool BigInteger::operator> ( long const  c) const
throw (BigIntegerException
)

◆ operator>=() [1/2]

bool BigInteger::operator>= ( BigInteger const &  c) const
throw (
)

◆ operator>=() [2/2]

bool BigInteger::operator>= ( long const  c) const
throw (BigIntegerException
)

◆ operator||() [1/2]

bool BigInteger::operator|| ( BigInteger const &  c) const
throw (
)

◆ operator||() [2/2]

bool BigInteger::operator|| ( long const  c) const
throw (BigIntegerException
)

◆ setDecValue()

void BigInteger::setDecValue ( std::string  dec)
throw (BigIntegerException
)

Define o valor inteiro em base 10 de um BigInteger. Não utilizar string "0x" para identificar base 16.

Parameters
decvalor inteiro.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ setHexValue()

void BigInteger::setHexValue ( std::string  hex)
throw (BigIntegerException
)

Define o valor inteiro em base 16 de um BigInteger. Não utilizar string "0x" para identificar base 16.

Parameters
hexvalor inteiro.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ setNegative()

void BigInteger::setNegative ( bool  neg = true)
throw (
)

Define o sinal do BigInteger.

Parameters
booltrue se negativo, false se positivo. Se nenhum parâmetro é passado, assume-se negativo.

◆ setRandValue()

void BigInteger::setRandValue ( int  numBits = 64)
throw (BigIntegerException
)

Define um valor inteiro randômico (positivo ou negativo).

Parameters
numBitsnúmero de bits do BigInteger. Se nenhum parâmetro é passado, assume-se numBits = 64.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ setValue()

void BigInteger::setValue ( const long  val = 0)
throw (BigIntegerException
)

Define o valor inteiro de um BigInteger. Se nenhum valor é passado, define o valor zero.

Parameters
valvalor inteiro.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ size()

int BigInteger::size ( ) const
throw (
)

Retorna o tamanho do valor inteiro do BigInteger em bits.

Returns
tamanho do BigInteger

◆ sub() [1/2]

BigInteger & BigInteger::sub ( BigInteger const &  a)
throw (BigIntegerException
)

Subtração entre os valores inteiros de dois BigIntegers.

Parameters
areferência para objeto constante BigInteger.
Returns
referência para objeto BigInteger com o resultado da subtração.
Exceptions
BigIntegerExceptionno caso de um erro interno do OpenSSL.

◆ sub() [2/2]

BigInteger & BigInteger::sub ( long const  a)
throw (BigIntegerException
)

◆ toDec()

string BigInteger::toDec ( ) const
throw (
)

Retorna string com valor do BigInteger em base 10.

Returns
string com valor inteiro.

◆ toHex()

string BigInteger::toHex ( ) const
throw (
)

Retorna string com valor do BigInteger em base 16.

Returns
string com valor inteiro.

Member Data Documentation

◆ bigInt

BIGNUM* BigInteger::bigInt
protected

The documentation for this class was generated from the following files: