13 #ifndef CRYPTOPP_INTEGER_H 14 #define CRYPTOPP_INTEGER_H 239 size_t OpenPGPEncode(
byte *output,
size_t bufferSize)
const;
264 void BERDecode(
const byte *input,
size_t inputLen);
285 void OpenPGPDecode(
const byte *input,
size_t inputLen);
293 bool IsConvertableToLong()
const;
300 signed long ConvertToLong()
const;
304 unsigned int BitCount()
const;
307 unsigned int ByteCount()
const;
310 unsigned int WordCount()
const;
314 bool GetBit(
size_t i)
const;
320 lword GetBits(
size_t i,
size_t n)
const;
342 bool IsEven()
const {
return GetBit(0) == 0;}
345 bool IsOdd()
const {
return GetBit(0) == 1;}
372 Integer& operator<<=(
size_t n);
374 Integer& operator>>=(
size_t n);
447 if (!GenerateRandomNoThrow(rng, params))
453 void SetBit(
size_t n,
bool value=1);
457 void SetByte(
size_t n,
byte value);
474 bool operator!()
const;
492 int Compare(
const Integer& a)
const;
575 bool IsSquare()
const;
580 Integer MultiplicativeInverse()
const;
620 #ifndef CRYPTOPP_DOXYGEN_PROCESSING 630 int PositiveCompare(
const Integer &t)
const;
635 #ifndef CRYPTOPP_DOXYGEN_PROCESSING 638 friend class HalfMontgomeryRepresentation;
648 inline bool operator==(
const CryptoPP::Integer&
a,
const CryptoPP::Integer&
b) {
return a.Compare(b)==0;}
650 inline bool operator!=(
const CryptoPP::Integer&
a,
const CryptoPP::Integer&
b) {
return a.Compare(b)!=0;}
652 inline bool operator> (
const CryptoPP::Integer&
a,
const CryptoPP::Integer&
b) {
return a.Compare(b)> 0;}
654 inline bool operator>=(
const CryptoPP::Integer&
a,
const CryptoPP::Integer&
b) {
return a.Compare(b)>=0;}
656 inline bool operator< (
const CryptoPP::Integer&
a,
const CryptoPP::Integer&
b) {
return a.Compare(b)< 0;}
658 inline bool operator<=(
const CryptoPP::Integer&
a,
const CryptoPP::Integer&
b) {
return a.Compare(b)<=0;}
660 inline CryptoPP::Integer
operator+(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.Plus(b);}
662 inline CryptoPP::Integer
operator-(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.Minus(b);}
665 inline CryptoPP::Integer
operator*(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.Times(b);}
667 inline CryptoPP::Integer
operator/(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.DividedBy(b);}
670 inline CryptoPP::Integer
operator%(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.Modulo(b);}
689 inline CryptoPP::Integer
operator&(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.And(b);}
703 inline CryptoPP::Integer
operator|(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.Or(b);}
717 inline CryptoPP::Integer
operator^(
const CryptoPP::Integer &
a,
const CryptoPP::Integer &
b) {
return a.Xor(b);}
Base class for all exceptions thrown by the library.
CryptoPP::Integer operator-(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Subtraction.
SecBlock< word, AllocatorWithCleanup< word, true > > IntegerSecBlock
void SetNegative()
Sets the Integer to negative.
Integer & operator/=(word t)
Division Assignment.
NAMESPACE_END void swap(CryptoPP::Integer &a, CryptoPP::Integer &b)
Integer operator+() const
Addition.
Integer operator--(int)
Post-decrement.
ByteOrder
Provides the byte ordering.
bool NotZero() const
Determines if the Integer is non-0.
CryptoPP::Integer operator^(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Bitwise XOR.
bool IsOdd() const
Determines if the Integer is odd parity.
Integer a_times_b_mod_c(const Integer &x, const Integer &y, const Integer &m)
void SetPositive()
Sets the Integer to positive.
void PositiveMultiply(Integer &product, const Integer &a, const Integer &b)
#define NAMESPACE_BEGIN(x)
CryptoPP::Integer operator*(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Multiplication.
bool IsEven() const
Determines if the Integer is even parity.
Secure memory block with allocator and cleanup.
Abstract base classes that provide a uniform interface to this library.
bool operator<(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Comparison.
Signedness
Used when importing and exporting integers.
Ring of congruence classes modulo n.
std::hash for asio::adress
Interface for random number generators.
void GenerateRandom(RandomNumberGenerator &rng, const NameValuePairs ¶ms=g_nullNameValuePairs)
Sign
Used internally to represent the integer.
void PositiveSubtract(Integer &diff, const Integer &a, const Integer &b)
Classes and functions for secure memory allocations.
Integer & operator/=(const Integer &t)
Division Assignment.
Integer operator<<(size_t n) const
Left-shift.
bool IsPositive() const
Determines if the Integer is positive.
a number with no special properties
Integer Squared() const
Multiply this integer by itself.
bool IsNegative() const
Determines if the Integer is negative.
bool NotPositive() const
Determines if the Integer is non-positive.
Exception thrown when an error is encountered decoding an OpenPGP integer.
Interface for encoding and decoding ASN1 objects.
void PositiveDivide(Integer &remainder, Integer "ient, const Integer &a, const Integer &b)
Performs static initialization of the Integer class.
bool operator==(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Comparison.
void PositiveAdd(Integer &sum, const Integer &a, const Integer &b)
bool operator>(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Comparison.
CryptoPP::Integer operator+(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Addition.
Multiple precision integer with arithmetic operations.
void Divide(word *R, word *Q, word *T, const word *A, size_t NA, const word *B, size_t NB)
CryptoPP::Integer operator%(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Remainder.
RandomNumberType
Properties of a random integer.
CryptoPP::Integer operator&(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Bitwise AND.
Integer & operator*=(const Integer &t)
Multiplication Assignment.
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
bool IsZero() const
Determines if the Integer is 0.
std::ostream & operator<<(std::ostream &_out, bytes const &_e)
Integer operator++(int)
Post-increment.
Signature sign(Secret const &_k, h256 const &_hash)
Returns siganture of message hash.
Exception thrown when division by 0 is encountered.
CryptoPP::Integer operator/(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Division.
Exception thrown when a random number cannot be found that satisfies the condition.
Performs modular arithmetic in Montgomery representation for increased speed.
std::vector< T > & operator+=(std::vector< typename std::enable_if< std::is_pod< T >::value, T >::type > &_a, std::vector< T > const &_b)
Concatenate two vectors of elements of POD types.
Integer Doubled() const
Add this integer to itself.
N diff(N const &_a, N const &_b)
std::istream & operator>>(std::istream &in, Integer &a)
bool operator<=(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Comparison.
bool operator!=(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Comparison.
CryptoPP::Integer operator|(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Bitwise OR.
Integer operator>>(size_t n) const
Right-shift.
Integer & operator%=(word t)
Remainder Assignment.
bool operator>=(const CryptoPP::Integer &a, const CryptoPP::Integer &b)
Comparison.
Integer a_exp_b_mod_c(const Integer &x, const Integer &e, const Integer &m)
unsigned int GetByte(ByteOrder order, T value, unsigned int index)
Gets a byte from a value.
Integer & operator%=(const Integer &t)
Remainder Assignment.
bool NotNegative() const
Determines if the Integer is non-negative.
Interface for retrieving values given their names.