|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.crypto.CryptoInteger
Represents large unsigned integer arithmetic class.
Most operations are performed with respect to a modulus.
Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
| Constructor Summary | ||
|
protected |
CryptoInteger()
Deprecated. If you use this constructor, all of the public functions in this class may throw NullPointerExceptions. Instead use the public constructors. |
|
|
CryptoInteger(byte[] value)
Constructs a CryptoInteger object with the given byte array. |
|
|
CryptoInteger(byte[] value,
int offset,
int length)
Constructs a CryptoInteger object with the given byte array. |
|
|
CryptoInteger(CryptoInteger other)
Creates a copy of a given CryptoInteger instance. |
|
|
CryptoInteger(int value)
Creates a CryptoInteger object with the given integer parameter. |
|
|
CryptoInteger(String value)
Constructs a CryptoInteger object with the given hexadecimal
string. |
| Method Summary | ||
|
CryptoInteger |
add(CryptoInteger a,
CryptoInteger modulus)
Returns a CryptoInteger whose value is (this + a) mod modulus. |
|
int |
compareTo(CryptoInteger other)
Compares this CryptoInteger with the specified
CryptoInteger. |
|
int |
compareTo(int other)
Compares this CryptoInteger with the specified integer value. |
|
void |
decrement(CryptoInteger a,
CryptoInteger modulus)
Decrements this CryptoInteger by a, all modulo modulus. |
|
void |
decrement(int a,
CryptoInteger modulus)
Decrements this CryptoInteger by a, all modulo modulus. |
|
void |
divideByTwo(CryptoInteger modulus)
Divides this by two modulo modulus. i.e. the resulting value * 2 will
be equivalent to this mod modulus. |
|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one. |
|
CryptoInteger |
exponent(CryptoInteger exponent,
CryptoInteger modulus)
Returns a CryptoInteger whose value is thisexponent mod modulus. |
|
CryptoInteger |
gcd(CryptoInteger a)
Returns the greatest common denominator of this and
a. |
|
int |
hashCode()
Returns a hash code value for the object. |
|
void |
increment(CryptoInteger a,
CryptoInteger modulus)
Increments this CryptoInteger by a, all modulo modulus. |
|
void |
increment(int a,
CryptoInteger modulus)
Increments this CryptoInteger by a, all modulo modulus. |
|
CryptoInteger |
invert(CryptoInteger modulus)
Returns the inverse of this modulo modulus. |
|
boolean |
isOdd()
Determines if this CryptoInteger is odd. |
|
CryptoInteger |
mod(CryptoInteger modulus)
Returns a CryptoInteger whose value is this mod modulus. |
|
CryptoInteger |
multiply(CryptoInteger a,
CryptoInteger modulus)
Returns a CryptoInteger whose value is (this * a) mod modulus. |
|
void |
multiplyByTwo(CryptoInteger modulus)
Multiplies this by two, modulo modulus. |
|
CryptoInteger |
square(CryptoInteger modulus)
Returns a CryptoInteger whose value is this2 mod modulus. |
|
CryptoInteger |
subtract(CryptoInteger a,
CryptoInteger modulus)
Returns a CryptoInteger whose value is (this - a) mod modulus. |
|
byte[] |
toByteArray()
Returns the byte array representation of the value. |
|
byte[] |
toByteArray(int length)
Returns the byte array representation of the value, padded or truncated to the specified length. |
|
String |
toString()
Returns the hexadecimal string representation of the value. |
|
String |
toString(int numberOfBytes)
Returns the hexadecimal string representation of the value, padded or truncated to the specified number of bytes (the string length will be twice this number). |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected CryptoInteger()
CryptoInteger object.
This is the default constructor.
Note: This object is mutable, and therefore so is the hash code. Don't modify this object after you place it in a hashtable.
Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger(byte[] value)
CryptoInteger object with the given byte array.
The first byte in the array is considered the most significant. The length of the given byte array must be in the range 1-256.
Note: This object is mutable, and therefore so is the hash code. Don't modify this object after you place it in a hashtable.
value - The byte array representation of the value.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger(byte[] value,
int offset,
int length)
CryptoInteger object with the given byte array.
The first byte in the array is considered most significant.
Note: This object is mutable, and therefore so is the hash code. Don't modify this object after you place it in a hashtable.
value - The byte array representation of the value.offset - The starting offset of the data to use from value.length - The number of bytes to use. Must be in the range 1-256.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger(CryptoInteger other)
CryptoInteger instance.
Note: This object is mutable, and therefore so is the hash code. Don't modify this object after you place it in a hashtable.
other - The CryptoInteger object to be copied.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger(int value)
CryptoInteger object with the given integer parameter.
Note: This object is mutable, and therefore so is the hash code. Don't modify this object after you place it in a hashtable.
value - The integer representation of the non-negative value.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger(String value)
CryptoInteger object with the given hexadecimal
string.
Characters must be 0-9, A-F, or a-f. The first character in the string is considered most significant. The string must represent 1 to 256 full bytes, i.e. 2 characters per byte.
Note: This object is mutable, and therefore so is the hash code. Don't modify this object after you place it in a hashtable.
value - The hexadecimal string representation of the value.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
| Method Detail |
public CryptoInteger add(CryptoInteger a, CryptoInteger modulus) throws ArithmeticException
CryptoInteger whose value is (this + a) mod modulus.
a - The CryptoInteger to be added to this.modulus - The modulus under which the sum is performed.(this + a) mod modulus.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public int compareTo(CryptoInteger other)
CryptoInteger with the specified
CryptoInteger.
other - The CryptoInteger to which this CryptoInteger is to be compared.CryptoInteger is numerically
less than, equal to, or greater than other.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public int compareTo(int other)
CryptoInteger with the specified integer value.
other - An integer to which this CryptoInteger is to be compared.CryptoInteger is numerically
less than, equal to, or greater than other.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public void decrement(CryptoInteger a, CryptoInteger modulus) throws ArithmeticException
CryptoInteger by a, all modulo modulus.
a - The CryptoInteger to be subtracted from this.modulus - The modulus under which the decrement is performed.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public void decrement(int a,
CryptoInteger modulus)
throws ArithmeticException
CryptoInteger by a, all modulo modulus.
a - The int to be subtracted from this.modulus - The modulus under which the decrement is performed.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public void divideByTwo(CryptoInteger modulus) throws ArithmeticException
this by two modulo modulus. i.e. the resulting value * 2 will
be equivalent to this mod modulus. If modulus is even, there are two possible
results; here we return the solution that is in the range [0, this/2 - 1]. this is odd and
modulus is even.
modulus - The modulus under which the division is performed. If this is odd, then
modulus must be odd.ArithmeticException - Thrown if the modulus is zero or this is odd and modulus is even.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public boolean equals(Object obj)
Object
The equals method implements an equivalence relation:
x,
x.equals(x) should return true.
x and
y, x.equals(y) should return
true if and only if y.equals(x) returns
true.
x,
y, and z, if x.equals(y)
returns true and y.equals(z) returns
true, then x.equals(z) should return
true.
x
and y, multiple invocations of x.equals(y)
consistently return true or consistently return
false, provided no information used in
equals comparisons on the object is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any reference values x and y,
this method returns true if and only if x and
y refer to the same object (x==y has the
value true).
Objectobj - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Boolean.hashCode(),
HashtableCerticom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger exponent(CryptoInteger exponent, CryptoInteger modulus) throws ArithmeticException
CryptoInteger whose value is thisexponent mod modulus.
exponent - The CryptoInteger that this is taken to the power of.modulus - The modulus under which the exponentation is performed.thisexponent mod modulus.ArithmeticException - Thrown if the modulus or the exponent is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger gcd(CryptoInteger a)
this and
a.
If both this and a are zero, the result is zero.
a - The value with which the GCD is to be computed.GCD( this, a ).Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public int hashCode()
Objectjava.util.Hashtable.
The general contract of hashCode is:
hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
ObjectObject.equals(java.lang.Object),
HashtableCerticom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public void increment(CryptoInteger a, CryptoInteger modulus) throws ArithmeticException
CryptoInteger by a, all modulo modulus.
a - The CryptoInteger to be added to this.modulus - The modulus under which the increment is performed.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public void increment(int a,
CryptoInteger modulus)
throws ArithmeticException
CryptoInteger by a, all modulo modulus.
a - The int to be added to this.modulus - The modulus under which the increment is performed.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger invert(CryptoInteger modulus) throws ArithmeticException
this modulo modulus.
That is, this.invert(modulus) * this
is equivalent to 1 modulo modulus.
modulus - The modulus under which the inverse is taken.this-1 mod modulus.ArithmeticException - Thrown if the modulus is zero or this
CryptoInteger has no multiplicative inverse mod modulus.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public boolean isOdd()
CryptoInteger is odd.
true if and only if this CryptoInteger is odd.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger mod(CryptoInteger modulus) throws ArithmeticException
CryptoInteger whose value is this mod modulus.
modulus - The modulus under which this is reduced.this mod modulus.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger multiply(CryptoInteger a, CryptoInteger modulus) throws ArithmeticException
CryptoInteger whose value is (this * a) mod modulus.
a - The CryptoInteger to be multiplied into this.modulus - The modulus under which the multiplication is performed.(this * a) mod modulus.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public void multiplyByTwo(CryptoInteger modulus) throws ArithmeticException
this by two, modulo modulus.
modulus - the modulus under which the multiplication is performedArithmeticException - modulus is zeroCerticom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger square(CryptoInteger modulus) throws ArithmeticException
CryptoInteger whose value is this2 mod modulus.
modulus - The modulus under which the squaring is performed.this2 mod modulus.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public CryptoInteger subtract(CryptoInteger a, CryptoInteger modulus) throws ArithmeticException
CryptoInteger whose value is (this - a) mod modulus.
a - The CryptoInteger to be subtracted from this.modulus - The modulus under which the subtraction is performed.(this - a) mod modulus.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public byte[] toByteArray()
The first byte in the array is considered most significant. The leading zero bytes are stripped.
Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public byte[] toByteArray(int length)
The first byte in the array is considered most
significant. A returned array that is 0 or >256 bytes long cannot
be passed into the CryptoInteger constructor.
length - The desired byte array length, must be non-negative.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public String toString()
Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
public String toString(int numberOfBytes)
The first character in the string is considered most significant. The returned string will use lowercase characters.
numberOfBytes - The number of bytes of the value to be represented in the string.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.