#include <pk.h>
Collaboration diagram for num:

Public Member Functions | |
Constructors and Destructors | |
| num () | |
| Constructor. | |
| num (const num &x) | |
| Constructor used to duplicate a given num object. | |
| num (const num &x, const str &y) | |
| Constructor used to convert a str into a num object with specified parameters. | |
| num (int x) | |
| Constructor used to instantiate a new num object based on an integer. | |
| num (const FParms *p1) | |
| Constructor used to create new num with specified parameters. | |
| num (const str &x) | |
| Constructor used to convert a str into a num object. | |
| num (int type1, int len) | |
| Constructor used to created a new num object of specified type and size. | |
| ~num () | |
| Destructor. Calls clear1(). | |
Initializers | |
| void | setlen (int n) |
| Set the length of this object in nwords. | |
| void | add (int n, const char *x) |
| Load octet string into this object. | |
| void | mod2to (int n) |
| Assign a power of 2 to this object. | |
Assignment and Arithmetic Operators | |
| void | operator= (const FParms *p1) |
| Assign parameters to this object. | |
| void | operator= (const num &x) |
| Assignment operator for num objects. | |
| num | operator & (const FParms *p1) const |
| Change this object's parameters, but not its value. | |
| num & | operator= (nword x) |
| Assignment operator for nword. | |
| num & | operator= (int x) |
| Assignment operator for int. | |
| num & | operator-= (int x) |
| Decrement this object by a specified integer. | |
| num | operator- () const |
| Negate this object. | |
| num | operator- (int x) |
| Subtract an integer from this object. | |
| num | operator+ (const num &y) const |
| Add a num object to this one. | |
| num | operator- (const num &y) const |
| Subtract a num object from this one. | |
| num | operator * (int y) const |
| Multiply this object by an integer. | |
| num | operator * (const num &y) const |
| Multiply this num by another one. | |
| num | operator/ (int y) const |
| Divide this num by an integer. | |
| num | operator/ (const num &x) const |
| Divide this num by another num. | |
| num & | operator+= (const num &x) |
| Increment this object by a specified value. | |
| num & | operator-= (const num &x) |
| Decrement this object by a specified value. | |
| int | operator% (int k) const |
| Compute this num's residue modulo a specified integer. | |
| num | operator^ (int n) const |
| Raise this object's value to an integer exponent. | |
| num & | operator *= (int n) |
| Multiply this num by an integer. | |
| num & | operator/= (int n) |
| Divide this object by an integer. | |
Arithmetic Predicates | |
| bool | isNeg () const |
| Predicate used to determine if this object is negative. | |
| bool | isNat () const |
| Predicate used to determine if this object represents a natural number. | |
| bool | isMod () const |
| Predicate used to determine if this object is a ring or field element. | |
| bool | isChar2 () const |
| Predicate used to determine if this object is an element of a field of char 2. | |
| bool | isEven () const |
| Predicate used to determine if this object is even. | |
| bool | isZero () const |
| Predicate used to determine if this object is the zero element. | |
| bool | isPrime (int rounds=8) const |
| Predicate used to test primality. | |
| bool | isIrred () const |
| Predicate used to test irreducibility. | |
| bool | isMontg () const |
| Predicate used to determine if this object is in its Montgomery representation. | |
| int | isSquare () const |
| Predicate to test quadratic residuosity. | |
Operator Predicates | |
| bool | operator| (const num &y) const |
| Predicate used to test whether a given num divides this one. | |
| bool | operator== (const num &y) const |
| Predicate to test equality of two nums. | |
| bool | operator!= (const num &y) const |
| Predicate to test inequality of two nums. | |
| bool | operator== (int n) const |
| Predicate to test equality of this oject with an int. | |
| bool | operator!= (int n) const |
| Predicate to test inequality of this oject with an int. | |
| bool | operator< (const num &y) const |
| Predicate to test "less than" relation between two nums. | |
| bool | operator<= (const num &y) const |
| Predicate to test "less than or equal to" relation between two nums. | |
| bool | operator> (const num &y) const |
| Predicate to test "greater than" relation between two nums. | |
| bool | operator>= (const num &y) const |
| Predicate to test "greater than or equal to" relation between two nums. | |
| bool | operator> (int n) const |
| Predicate to test "greater than" relation with an int. | |
| bool | operator< (int n) const |
| Predicate to test "less than" relation with an int. | |
| bool | operator<= (int n) const |
| Predicate to test "less than or equal to" relation with an int. | |
| bool | operator>= (int n) const |
| Predicate to test "greater than or equal to" relation with an int. | |
Arithmetic Functions | |
| num | abs () const |
| Absolute value of this object. | |
| num | sqrt () const |
| Calculate square root. | |
| void | mmult (const num &x, const num &y) |
| Assign the product of two num objects to this one. | |
| void | divide (const num &y, num ", num &rem) const |
| Divide this num by another. | |
| num | mod1 (const num &y, int deg=0) const |
| Modular reduction. | |
| num | mod (const num &y, int deg=0) const |
| Modular reduction. Alias for mod1(). | |
| num | mod2 (const num &y) const |
| Modular reduction. | |
| num | inverse () const |
| Compute the inverse of this object (uses Euclidean Algorithm). | |
| void | power (const num &x, const num &y) |
| Assign x^y to this object. | |
| num | reciprocal () const |
| Invert this object. | |
| void | square () |
| Square this object. | |
| void | square (int k) |
| Square this object a specified number of times. | |
| void | square (const num &x) |
| Assign the square of another num to this object. | |
| void | mpower (const num &x, const num &y) |
| Exponentiation: assign x^y to this object. | |
Inspectors | |
| int | bytes () const |
| Get the length of this object's value in bytes. | |
| int | l () const |
| Get the length of this object in nwords. | |
| int | bits () const |
| Get the number of bits in this object's representation. | |
| int | bit (int k) const |
| Get the kth bit of this object's value. | |
| int | byte (int k) const |
| Get the kth element in the array of bytes representing this object's value. | |
| nword & | wd (int k) |
| Get reference to kth nword in the representation of this object as an array of nwords. | |
| nword | w (int k) const |
| Get kth nword in the representation of this object as an array of nwords. | |
| const nword * | words () const |
| Get a pointer to the array of nwords representing this object. | |
| int | degree () const |
| Get object's degree. | |
| int | degf () const |
| Get the degree of the underlying field extension in characteristic 2. | |
| num | modulus () const |
| Get the characteristic of the underlying field. | |
| num | modulus2 () const |
| Get the degree of the field extension in char 2. | |
| const FParms * | parms () const |
| Get the parameters of the underlying group, ring, or field. | |
| int | checkModulus () const |
| Test object's parameters. | |
Conversions | |
| num | toint () const |
| Map this object to a natural number. | |
| template<class T> | |
| T | to (int n=0) const |
| Convert this object to type T. | |
| cdk::str | tostr (int n=0) const |
| Get a str representation of this object. | |
Constructor used to duplicate a given num object.
| x | num to duplicate in this object |
Constructor used to convert a str into a num object with specified parameters.
| x | num whose parameters are to be copied | |
| y | str to convert into this num object |
| num | ( | int | x | ) | [inline] |
Constructor used to instantiate a new num object based on an integer.
| x | int to be assigned to this new num object. |
Constructor used to create new num with specified parameters.
| p1 | parameters to use for this new num object. |
Constructor used to convert a str into a num object.
| x | str to be converted into this num. |
| num | ( | int | type1, | |
| int | len | |||
| ) | [inline] |
Constructor used to created a new num object of specified type and size.
| type1 | one of FParms::Types | |
| len | size of num object to be created |
| ~num | ( | ) | [inline] |
Destructor. Calls clear1().
| num abs | ( | ) | const |
Absolute value of this object.
| void add | ( | int | n, | |
| const char * | x | |||
| ) | [inline] |
Load octet string into this object.
| n | length of input array in nwords | |
| x | pointer to an octet string (base 256) to assign to this object. |
| int bit | ( | int | k | ) | const [inline] |
Get the kth bit of this object's value.
| k | the index of the bit to be returned |
| int bits | ( | ) | const [inline] |
Get the number of bits in this object's representation.
| int byte | ( | int | k | ) | const [inline] |
Get the kth element in the array of bytes representing this object's value.
| k | index of byte to return |
| int bytes | ( | ) | const [inline] |
Get the length of this object's value in bytes.
| int checkModulus | ( | ) | const |
Test object's parameters.
| int degf | ( | ) | const [inline] |
Get the degree of the underlying field extension in characteristic 2.
| int degree | ( | ) | const [inline] |
Get object's degree.
Divide this num by another.
| y | num by which to divide this object | |
| quot | buffer which is to receive quotient | |
| rem | buffer which is to receive remainder |
| num inverse | ( | ) | const |
Compute the inverse of this object (uses Euclidean Algorithm).
| bool isChar2 | ( | ) | const [inline] |
Predicate used to determine if this object is an element of a field of char 2.
| bool isEven | ( | ) | const [inline] |
Predicate used to determine if this object is even.
| bool isIrred | ( | ) | const |
Predicate used to test irreducibility.
| bool isMod | ( | ) | const [inline] |
Predicate used to determine if this object is a ring or field element.
| bool isMontg | ( | ) | const [inline] |
Predicate used to determine if this object is in its Montgomery representation.
| bool isNat | ( | ) | const [inline] |
Predicate used to determine if this object represents a natural number.
| bool isNeg | ( | ) | const [inline] |
Predicate used to determine if this object is negative.
| bool isPrime | ( | int | rounds = 8 |
) | const |
Predicate used to test primality.
| rounds | number of Miller-Rabin rounds to run |
| int isSquare | ( | ) | const |
Predicate to test quadratic residuosity.
| bool isZero | ( | ) | const [inline] |
Predicate used to determine if this object is the zero element.
| int l | ( | ) | const [inline] |
Get the length of this object in nwords.
Assign the product of two num objects to this one.
| x | multiplicand | |
| y | multiplier |
Modular reduction. Alias for mod1().
| y | modulus | |
| deg | 0 for char p; degree of the field extension in char 2 |
Modular reduction.
| y | modulus | |
| deg | 0 for char p; degree of the field extension in char 2 |
Modular reduction.
| y | modulus |
| void mod2to | ( | int | n | ) |
Assign a power of 2 to this object.
| n | exponent to which 2 is to be raised before storing in this object. |
| num modulus | ( | ) | const |
Get the characteristic of the underlying field.
| num modulus2 | ( | ) | const |
Get the degree of the field extension in char 2.
Exponentiation: assign x^y to this object.
| x | base | |
| y | exponent |
Change this object's parameters, but not its value.
| p1 | pointer to new parameters to use this num object. |
Multiply this num by another one.
| y | num by which to multiply this num |
| num operator * | ( | int | y | ) | const |
Multiply this object by an integer.
| y | int by which this object is to be multiplied |
| num& operator *= | ( | int | n | ) |
Multiply this num by an integer.
| n | integer multiplier |
| bool operator!= | ( | int | n | ) | const [inline] |
Predicate to test inequality of this oject with an int.
| n | int to which this object is to be compared |
| bool operator!= | ( | const num & | y | ) | const [inline] |
Predicate to test inequality of two nums.
| y | num to which this object is to be compared |
| int operator% | ( | int | k | ) | const |
Compute this num's residue modulo a specified integer.
| k | modulus |
Add a num object to this one.
| y | the num to added to this object. |
Increment this object by a specified value.
| x | num to add to this one |
Subtract a num object from this one.
| y | the num to subtracted from this object. |
| num operator- | ( | int | x | ) | [inline] |
Subtract an integer from this object.
| x | int to be subtracted from this object. |
| num operator- | ( | ) | const |
Negate this object.
Decrement this object by a specified value.
| x | num to subtract from this one |
| num& operator-= | ( | int | x | ) | [inline] |
Decrement this object by a specified integer.
| x | int to be subtracted from this object. |
Divide this num by another num.
| x | divisor |
| num operator/ | ( | int | y | ) | const |
Divide this num by an integer.
| y | the integer divisor |
| num& operator/= | ( | int | n | ) |
Divide this object by an integer.
| n | int divisor |
| bool operator< | ( | int | n | ) | const [inline] |
Predicate to test "less than" relation with an int.
| n | int to which this object is to be compared |
| bool operator< | ( | const num & | y | ) | const |
Predicate to test "less than" relation between two nums.
| y | num to which this object is to be compared |
| bool operator<= | ( | int | n | ) | const [inline] |
Predicate to test "less than or equal to" relation with an int.
| n | int to which this object is to be compared |
| bool operator<= | ( | const num & | y | ) | const |
Predicate to test "less than or equal to" relation between two nums.
| y | num to which this object is to be compared |
| num& operator= | ( | int | x | ) |
Assignment operator for int.
| x | int to be assigned to this object. |
Assignment operator for nword.
| x | nword to to be assigned to this object. |
| void operator= | ( | const num & | x | ) | [inline] |
Assignment operator for num objects.
| x | num to copy into this num object. |
| void operator= | ( | const FParms * | p1 | ) | [inline] |
Assign parameters to this object.
| p1 | new parameters to use for this object. |
| bool operator== | ( | int | n | ) | const |
Predicate to test equality of this oject with an int.
| n | int to which this object is to be compared |
| bool operator== | ( | const num & | y | ) | const |
Predicate to test equality of two nums.
| y | num to which this object is to be compared |
| bool operator> | ( | int | n | ) | const [inline] |
Predicate to test "greater than" relation with an int.
| n | int to which this object is to be compared |
| bool operator> | ( | const num & | y | ) | const [inline] |
Predicate to test "greater than" relation between two nums.
| y | num to which this object is to be compared |
| bool operator>= | ( | int | n | ) | const |
Predicate to test "greater than or equal to" relation with an int.
| n | int to which this object is to be compared |
| bool operator>= | ( | const num & | y | ) | const [inline] |
Predicate to test "greater than or equal to" relation between two nums.
| y | num to which this object is to be compared |
| num operator^ | ( | int | n | ) | const |
Raise this object's value to an integer exponent.
| n | exponent |
| bool operator| | ( | const num & | y | ) | const [inline] |
Predicate used to test whether a given num divides this one.
| y | divisor |
| const FParms* parms | ( | ) | const [inline] |
Get the parameters of the underlying group, ring, or field.
Assign x^y to this object.
| x | the base | |
| y | the exponent |
| num reciprocal | ( | ) | const |
Invert this object.
| void setlen | ( | int | n | ) | [inline] |
Set the length of this object in nwords.
| n | the number of nwords to use for this num. |
| num sqrt | ( | ) | const |
Calculate square root.
| void square | ( | const num & | x | ) | [inline] |
Assign the square of another num to this object.
| x | the num to be squared |
| void square | ( | int | k | ) |
Square this object a specified number of times.
| k | number of times to square this object |
| T to | ( | int | n = 0 |
) | const |
Convert this object to type T.
| n | minimum size of output in bytes |
| num toint | ( | ) | const |
Map this object to a natural number.
| cdk::str tostr | ( | int | n = 0 |
) | const |
Get a str representation of this object.
| n | the minimum length of the str to be created |
| nword w | ( | int | k | ) | const [inline] |
Get kth nword in the representation of this object as an array of nwords.
| k | index of nword to return |
| nword& wd | ( | int | k | ) | [inline] |
Get reference to kth nword in the representation of this object as an array of nwords.
| k | index of nword to return |
| const nword* words | ( | ) | const [inline] |
Get a pointer to the array of nwords representing this object.
| ISC Cryptographic Development Kit - User's Guide | |
| Questions? E-mail ISC technical support | |
| Copyright© 2002-2006 Information Security Corp. All rights reserved. |