net.rim.device.api.crypto Class CryptoByteArrayArithmetic

java.lang.Object net.rim.device.api.crypto.CryptoByteArrayArithmetic

public class CryptoByteArrayArithmetic
extends Object

Modular arithmetic on large unsigned integers. Integers are repesented as byte arrays with the most significant byte at position 0 in the array, or position offset if offset is specified. The arrays can be up to 256 bytes long.

When possible, methods that can work with a modulus that is a power of two are provided. In this case, the modulus will be 2log2modulus, where log2modulus is the integer representing log2 of the modulus that will be used in the calculations.

Each arithmetic method also has a version which allows an offset into each array to be specified, as well as the length in bytes of the integer stored in the array. In this case, the integer operated on will be the integer in the array that begins at byte offset and continues for length bytes.

Category:
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.
Since:
BlackBerry API 3.6.0

Method Summary static void add(byte[] a, byte[] b, byte[] modulus, byte[] result)
Computes the sum of the integers represented by arrays a and b, mod the integer represented by the array modulus, and stores the result in the array result. static void add(byte[] a, byte[] b, int log2modulus, byte[] result)
Computes the sum of the integers represented by arrays a and b, mod 2log2modulus and stores the result in the array result. static void add(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Computes the sum of the integers of length length in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result, beginning at resultOffset. static void add(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Computes the sum of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset. static int compare(byte[] a, byte[] b)
Compares the integer represented in array a to the one represented in array b. static int compare(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength)
Compares the integer represented in array a to the one represented in array b. static byte[] createArray(int log2n)
Returns an array containing 2^log2n. static void decrement(byte[] a, byte[] modulus, byte[] result)
Subtracts one from the integer represented by the array a, mod the integer represented by the array modulus, and stores the result in the array result. static void decrement(byte[] a, int log2modulus, byte[] result)
Subtracts one from the integer represented by array a, mod 2log2modulus and stores the result in the array result. static void decrement(byte[] a, int aOffset, int aLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Subtracts one from the integer of length aLength in the array beginning at a[ aOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result beginning at resultOffset. static void decrement(byte[] a, int aOffset, int aLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Subtracts one from the integer in the array beginning at a[ aOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset. static void divide(byte[] dividend, byte[] divisor, byte[] quotient, byte[] remainder)
Computes the quotient and remainder of dividend / divisor The quotient is stored in quotient, and the remainder is stored in remainder. static void divide(byte[] dividend, int dividendOffset, int dividendLength, byte[] divisor, int divisorOffset, int divisorLength, byte[] quotient, int quotientOffset, int quotientLength, byte[] remainder, int remainderOffset, int remainderLength)
Computes the quotient and remainder of the integer in the array dividend, beginning at dividendOffset, divided by the integer in the array divisor, beginning at divisorOffset. static void divideByTwo(byte[] a, byte[] modulus, byte[] result)
Divide the integer represented by the array a by two modulo the integer represented by the array modulus. static void divideByTwo(byte[] a, int log2modulus, byte[] result)
Divide the integer represented by the array a by a modulus which is a power of 2. static void divideByTwo(byte[] a, int aOffset, int aLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Divide the integer of length aLength beginning at a[ aOffset ] by two modulo the integer of length modulusLength beginning at modulus[ modulusOffset ]. static void divideByTwo(byte[] a, int aOffset, int aLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Divide the integer of length length beginning at a[ aOffset ] by a modulus which is a power of 2. static byte[] ensureLength(byte[] array, int length)
Takes a byte array and adjusts its length by trimming or padding it. static void exponent(byte[] base, byte[] exponent, byte[] modulus, byte[] result)
Modular exponentiation with the integers found in base, exponent and modulus Takes baseexponent mod modulus and stores it in result result must be at least as large as modulus. static void exponent(byte[] base, int baseOffset, int baseLength, byte[] exponent, int exponentOffset, int exponentLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Modular exponentiation with the integers found in base, exponent and modulus Takes basemodulus mod modulus and stores the result in the resultLength bytes of result, beginning at result[ resultOffset ]. static int findFirstNonZeroByte(byte[] a, int offset, int length)
Returns the first non-zero byte in the array a, starting at a[ offset ] continuing for length bytes. static void gcd(byte[] a, byte[] b, byte[] result)
Computes the greatest common divisor of the integer represented by the array a and the integer represetned by the array b, and stores the result in the array result must be at least as long as the longest of a and b. static void gcd(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength, byte[] result, int resultOffset, int resultLength)
Computes the greatest common divisor of the integer represetned by the array a, beginning at aOffset, and the integer represented by the array b, beginning at bOffset and stores the result in the array result, beginning at result[ resultOffset ]. static int getNumBits(byte[] array)
Returns the minimum number of bits required to encode the number contained in array. static void increment(byte[] a, byte[] modulus, byte[] result)
Adds one to the integer represented by the array a, mod the integer represented by the array modulus, and stores the result in the array result. static void increment(byte[] a, int log2modulus, byte[] result)
Adds one to the integer represented by array a, mod 2log2modulus and stores the result in the array result. static void increment(byte[] a, int aOffset, int aLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Adds one to the integer of length aLength in the array beginning at a[ aOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result beginning at resultOffset. static void increment(byte[] a, int aOffset, int aLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Adds one to the integer in the array beginning at a[ aOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset. static void invert(byte[] a, byte[] modulus, byte[] result)
Computes the inverse of the integer represented by the array a, modulo the integer represented by the array modulus and stores the result in result. static void invert(byte[] a, int aOffset, int aLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Computes the inverse of the integer in in the array a beginning at aOffset, modulo the integer in modulus beginning at modulusOffset and stores the result the the array result, beginning at result[ resultOffset ]. static boolean isOne(byte[] a)
Compares array a to 1. static boolean isOne(byte[] a, int offset, int length)
Compares array a to 1. static boolean isZero(byte[] a)
Compares array a to 0. static boolean isZero(byte[] a, int offset, int length)
Compares array a to 0. static void mod(byte[] a, byte[] modulus, byte[] result)
Computes the modulus of the integer represented by the array a moduloed by the integer represented by the array modulus, and stores the result in result. static void mod(byte[] a, int log2modulus, byte[] result)
Computes the modulus of the integer represented by the array a, moduloed by the an integer which is a power of 2, and stores the result in result. static void mod(byte[] a, int aOffset, int aLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Computes the modulus of the integer in the array a, beginning at aOffset, moduloed by the integer in the array modulus, beginning at modulusOffset, and stores the result in result, beginning at result[ resultOffset ]. static void mod(byte[] a, int aOffset, int aLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Computes the modulus of the integer in the array a, beginning at aOffset, moduloed by the an integer which is a power of 2 and stores the result in result beginning at result[ resultOffset ]. static void multiply(byte[] a, byte[] b, byte[] modulus, byte[] result)
Computes the product of the integers represented by the arrays a and b, mod the integer represented by the array modulus, and stores the result in the array result. static void multiply(byte[] a, byte[] b, int log2modulus, byte[] result)
Computes the product of the integers represented by the arrays a and b, mod 2log2modulus, and stores the result in result. static void multiply(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Computes the product of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod the integer in the array beginning at modulus[ modulusOffset ], and stores the result in result, beginning at resultOffset. static void multiply(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Computes the product of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod 2log2modulus, and stores the result in result, beginning at resultOffset. static void multiplyByTwo(byte[] a, byte[] modulus, byte[] result)
Multiply the integer representned by array a by two modulo the integer represented by array modulus. static void multiplyByTwo(byte[] a, int log2modulus, byte[] result)
Multiply the integer represetned by array a by a modulus which is a power of 2. static void multiplyByTwo(byte[] a, int aOffset, int aLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Multiply the integer of length aLength beginning at a[ aOffset ] by two modulo the integer of length modulusLength beginning at modulus[ modulusOffset ], and stores the result in result beginning at resultOffset. static void multiplyByTwo(byte[] a, int aOffset, int aLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Multiply the integer of length length beginning at a[ aOffset ] by a modulus which is a power of 2. static byte[] pad(byte[] array, int numberOfZeros) static void square(byte[] a, byte[] modulus, byte[] result)
Computes the square of the integer represented by the array a, mod the integer represented by the array modulus, and stores the result in the array result must be at least as long as modulus. static void square(byte[] a, int log2modulus, byte[] result)
Computes the square of the integer represented by the array a, mod 2log2modulus, and stores the result in result. static void square(byte[] a, int aOffset, int aLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Computes the square of the integer of length aLength in the array beginning at a[ aOffset ], mod the integer in the array beginning at modulus[ modulusOffset ], and stores the result in result, beginning at resultOffset. static void square(byte[] a, int aOffset, int aLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Computes the square of the integer of length aLength in the array beginning at a[ aOffset ], mod 2log2modulus, and stores the result in result, beginning at resultOffset. static void subtract(byte[] a, byte[] b, byte[] modulus, byte[] result)
Computes the difference of the integers represented by arrays a and b, mod the integer represented by the array modulus, and stores the result in the array result. static void subtract(byte[] a, byte[] b, int log2modulus, byte[] result)
Computes the difference of the integers represented by arrays a and b, mod 2log2modulus and stores the result in the array result. static void subtract(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength, byte[] modulus, int modulusOffset, int modulusLength, byte[] result, int resultOffset, int resultLength)
Computes the difference of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result, beginning at resultOffset. static void subtract(byte[] a, int aOffset, int aLength, byte[] b, int bOffset, int bLength, int log2modulus, byte[] result, int resultOffset, int resultLength)
Computes the difference of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset. static byte[] trim(byte[] array)
Removes the leading zeros from given byte[] and returns a new byte[] without them. static long valueOf(byte[] array)
Converts array into a long integer (Note: the returned value should be considered as an unsigned value). static byte[] valueOf(long i)
Converts i into a byte array.

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

isZero

public static boolean isZero(byte[] a,
int offset,
int length)
Compares array a to 0.

Parameters:
a - The array containing the integer to be compared to zero.
offset - The Offset into the array a, where the integer begins.
length - The number of bytes in the integer being compared.
Returns:
Returns true if and only if integer in a equals zero.
Category:
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.
Since:
BlackBerry API 3.6.0

isZero

public static boolean isZero(byte[] a)
Compares array a to 0.

Parameters:
a - The array to be compared to zero.
Returns:
Returns true if and only if integer in a equals zero.
Category:
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.
Since:
BlackBerry API 3.6.0

isOne

public static boolean isOne(byte[] a,
int offset,
int length)
Compares array a to 1.

Parameters:
a - The array containing the integer to be compared to one.
offset - The offset into the array a, where the integer begins.
length - The number of bytes in the integer being compared.
Returns:
Returns true if and only if the integer in a equals one.
Category:
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.
Since:
BlackBerry API 3.6.0

isOne

public static boolean isOne(byte[] a)
Compares array a to 1.

Parameters:
a - The array to be compared to one.
Returns:
Returns true if and only if integer in a equals one.
Category:
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.
Since:
BlackBerry API 3.6.0

findFirstNonZeroByte

public static int findFirstNonZeroByte(byte[] a,
int offset,
int length)
Returns the first non-zero byte in the array a, starting at a[ offset ] continuing for length bytes.

If the integer represented in the array is zero, the position of the last byte is returned. If there is no data to read the result returned will be -1.

Parameters:
a - The byte array.
offset - The first byte of the integer in a.
length - The length in bytes of the integer in a.
Returns:
The position in a of the first non-zero byte in the integer. If the integer represented in the array is zero, it returns the position of the last byte in the integer.
Category:
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.
Since:
BlackBerry API 3.6.0

compare

public static int compare(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength)
Compares the integer represented in array a to the one represented in array b.

Parameters:
a - The first integer.
aOffset - The offset into a, where the integer begins.
aLength - The length in bytes of the integer in a.
b - The second integer.
bOffset - The offset into b, where the integer begins.
bLength - The length in bytes of the integer in b.
Returns:
An integer less than, equal to, or greater than 0 if the integer in a is numerically less than, equal to, or greater than the integer in b.
Category:
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.
Since:
BlackBerry API 3.6.0

compare

public static int compare(byte[] a,
byte[] b)
Compares the integer represented in array a to the one represented in array b.

Parameters:
a - The first integer.
b - The second integer.
Returns:
An integer less than, equal to, or greater than 0 if the integer in a is numerically less than, equal to, or greater than the integer in b.
Category:
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.
Since:
BlackBerry API 3.6.0

multiplyByTwo

public static void multiplyByTwo(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Multiply the integer of length aLength beginning at a[ aOffset ] by two modulo the integer of length modulusLength beginning at modulus[ modulusOffset ], and stores the result in result beginning at resultOffset.

Parameters:
a - The integer to multiply by two.
aOffset - The offset into a, where the integer begins.
aLength - The length of the integer in a.
modulus - The modulus.
modulusOffset - The offset into modulus, where the integer begins.
modulusLength - The length of the integer in modulus.
result - The array where the result will be stored.
resultOffset - The offset into result, where the result begins.
resultLength - The length of the integer in result. Must be >= modulusLength.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

multiplyByTwo

public static void multiplyByTwo(byte[] a,
byte[] modulus,
byte[] result)
throws ArithmeticException
Multiply the integer representned by array a by two modulo the integer represented by array modulus.

The result must be at least as long as modulus.

Parameters:
a - The integer to multiply by two.
modulus - The modulus.
result - The array where the result is stored.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

multiplyByTwo

public static void multiplyByTwo(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Multiply the integer of length length beginning at a[ aOffset ] by a modulus which is a power of 2.

Parameters:
a - The integer to multiply by two.
aOffset - The offset into a, where the integer begins.
aLength - The length of the integer in a.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array where the result will be stored.
resultOffset - The offset into result, where the result begins.
resultLength - The length of the integer in result. resultLength*8 must be at least log2modulus
Category:
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.
Since:
BlackBerry API 3.6.0

multiplyByTwo

public static void multiplyByTwo(byte[] a,
int log2modulus,
byte[] result)
Multiply the integer represetned by array a by a modulus which is a power of 2. result must be at least as long as modulus

Parameters:
a - The integer to multiply by two.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*the length of result.
result - The array where the result is stored.
Category:
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.
Since:
BlackBerry API 3.6.0

divideByTwo

public static void divideByTwo(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Divide the integer of length aLength beginning at a[ aOffset ] by two modulo the integer of length modulusLength beginning at modulus[ modulusOffset ].

NOTE: The result of the operation does not exist if a is odd and modulus is even.

Parameters:
a - The integer to divide by two.
aOffset - The offset into a, where the integer begins.
aLength - The length of the integer in a.
modulus - The modulus.
modulusOffset - The offset into modulus, where the integer begins.
modulusLength - The length of the integer in modulus.
result - The byte array that will store the result.
resultOffset - The offset of the result data within the array.
resultLength - The length of the result data in the array.
Throws:
ArithmeticException - Thrown when the modulus is zero or a is odd and modulus is even.
Category:
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.
Since:
BlackBerry API 3.6.0

divideByTwo

public static void divideByTwo(byte[] a,
byte[] modulus,
byte[] result)
throws ArithmeticException
Divide the integer represented by the array a by two modulo the integer represented by the array modulus.

NOTE: The result of the operation does not exist if a is odd and modulus is even.

Parameters:
a - The integer to multiply by two.
modulus - The modulus.
result - A byte array containing the result.
Throws:
ArithmeticException - Thrown if the modulus is zero or a is odd and modulus is even.
Category:
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.
Since:
BlackBerry API 3.6.0

divideByTwo

public static void divideByTwo(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Divide the integer of length length beginning at a[ aOffset ] by a modulus which is a power of 2.

NOTE: The result of the operation does not exist if a is odd, since the modulus is even.

Parameters:
a - The integer to divide by two.
aOffset - The offset into a, where the integer begins.
aLength - The length of the integer in a.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*aLength.
result - The byte array that will store the result.
resultOffset - The offset of the result data within the array.
resultLength - The length of the result data in the array.
Throws:
ArithmeticException - Thrown if a is odd.
Category:
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.
Since:
BlackBerry API 3.6.0

divideByTwo

public static void divideByTwo(byte[] a,
int log2modulus,
byte[] result)
Divide the integer represented by the array a by a modulus which is a power of 2.

NOTE: The result of the operation does not exist if a is odd, since the modulus is even.

Parameters:
a - The integer to divide by two.
log2modulus - The log2 of the modulus 0 <= log2modulus <= 8*the length of a.
result - A byte array containing the result.
Throws:
ArithmeticException - Thrown if a is odd.
Category:
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.
Since:
BlackBerry API 3.6.0

int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Computes the sum of the integers of length length in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result, beginning at resultOffset.

Parameters:
a - The array containing the first integer in the addition.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the integer in a.
b - The array containing the second integer in the addition.
bOffset - The offset into the second array, where the first byte of the second integer is located.
bLength - The length of the integer in b.
modulus - The array containing the modulus of the operation.
modulusOffset - The offset into the modluls array, where the first byte of the modulus integer is located.
modulusLength - The length of the integer in modulus.
result - The array where the result of the modular addition will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

byte[] b,
byte[] modulus,
byte[] result)
throws ArithmeticException
Computes the sum of the integers represented by arrays a and b, mod the integer represented by the array modulus, and stores the result in the array result. result must be at least as long as modulus.

Parameters:
a - The array containing the first integer in the addition.
b - The array containing the second integer in the addition.
modulus - The array containing the modulus of the operation.
result - The array where the result of the modular addition will be stored.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Computes the sum of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset.

Parameters:
a - The array containing the first integer in the addition.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the integer in a.
b - The array containing the second integer in the addition.
bOffset - The offset into the second array, where the first byte of the second integer is located.
bLength - The length of the integer in b.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array where the result of the modular addition will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. The value resultLength*8 must be at least log2modulus.
Category:
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.
Since:
BlackBerry API 3.6.0

byte[] b,
int log2modulus,
byte[] result)
Computes the sum of the integers represented by arrays a and b, mod 2log2modulus and stores the result in the array result.

Parameters:
a - The array containing the first integer in the addition.
b - The array containing the second integer in the addition.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8* the length of result.
result - The array where the result of the modular addition will be stored.
Category:
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.
Since:
BlackBerry API 3.6.0

subtract

public static void subtract(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Computes the difference of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result, beginning at resultOffset.

Parameters:
a - The array containing the first integer in the subtraction.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the integer in a.
b - The array containing the second integer in the subtraction.
bOffset - The offset into the second array, where the first byte of the second integer is located.
bLength - The length of the integer in b.
modulus - The array containing the modulus of the operation.
modulusOffset - The offset into the modluls array, where the first byte of the modulus integer is located.
modulusLength - The length of the integer in modulus.
result - The array where the result of the modular subtraction will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

subtract

public static void subtract(byte[] a,
byte[] b,
byte[] modulus,
byte[] result)
throws ArithmeticException
Computes the difference of the integers represented by arrays a and b, mod the integer represented by the array modulus, and stores the result in the array result.

The result must be at least as long as modulus.

Parameters:
a - The array containing the first integer in the operation.
b - The array containing the second integer in the operation.
modulus - The array containing the modulus of the operation.
result - The array where the result of the modular operation will be stored.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

subtract

public static void subtract(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Computes the difference of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset.

Parameters:
a - The array containing the first integer in the operation.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the integer in a.
b - The array containing the second integer in the operation.
bOffset - The offset into the second array, where the first byte of the second integer is located
bLength - the length of the integer in b.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array where the result of the modular operation will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. resultLength*8 must be at least log2modulus
Category:
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.
Since:
BlackBerry API 3.6.0

subtract

public static void subtract(byte[] a,
byte[] b,
int log2modulus,
byte[] result)
Computes the difference of the integers represented by arrays a and b, mod 2log2modulus and stores the result in the array result.

Parameters:
a - The array containing the first integer in the operation.
b - The array containing the second integer in the operation.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8* the length of result.
result - The array where the result of the modular operation will be stored.
Category:
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.
Since:
BlackBerry API 3.6.0

multiply

public static void multiply(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Computes the product of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod the integer in the array beginning at modulus[ modulusOffset ], and stores the result in result, beginning at resultOffset.

Parameters:
a - The array containing the first integer in the operation.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the integer in a.
b - The array containing the second integer in the operation.
bOffset - The offset into the second array, where the first byte of the second integer is located.
bLength - The length of the integer in b.
modulus - The array containing the modulus of the operation.
modulusOffset - The offset into the modluls array, where first byte of the the modulus integer is located.
modulusLength - The length of the integer in modulus.
result - The array where the result of the modular operation will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

multiply

public static void multiply(byte[] a,
byte[] b,
byte[] modulus,
byte[] result)
throws ArithmeticException
Computes the product of the integers represented by the arrays a and b, mod the integer represented by the array modulus, and stores the result in the array result.

result must be at least as long as modulus

Parameters:
a - The array containing the first integer in the operation.
b - The array containing the second integer in the operation.
modulus - The array containing the modulus of the operation.
result - The array where the result of the modular operation will be stored.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

multiply

public static void multiply(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Computes the product of the integers in the arrays beginning at a[ aOffset ] and b[ bOffset ], mod 2log2modulus, and stores the result in result, beginning at resultOffset.

Parameters:
a - The array containing the first integer in the operation.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the integer in a.
b - The array containing the second integer in the operation.
bOffset - The offset into the second array, where the first byte of the second integer is located.
bLength - The length of the integer in b.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array where the result of the modular operation will be stored.
resultOffset - The offs et into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. resultLength*8 must be at least log2modulus
Category:
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.
Since:
BlackBerry API 3.6.0

multiply

public static void multiply(byte[] a,
byte[] b,
int log2modulus,
byte[] result)
Computes the product of the integers represented by the arrays a and b, mod 2log2modulus, and stores the result in result.

Parameters:
a - The array containing the first integer in the operation.
b - The array containing the second integer in the operation.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8* the length of result.
result - The array where the result of the modular operation will be stored.
Category:
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.
Since:
BlackBerry API 3.6.0

square

public static void square(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Computes the square of the integer of length aLength in the array beginning at a[ aOffset ], mod the integer in the array beginning at modulus[ modulusOffset ], and stores the result in result, beginning at resultOffset.

Parameters:
a - The array containing the integer to be squared.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the integer in a.
modulus - The array containing the modulus of the operation.
modulusOffset - The offset into the modluls array, where first byte of the the modulus integer is located.
modulusLength - The length of the integer in modulus.
result - The array where the result of the modular operation will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

square

public static void square(byte[] a,
byte[] modulus,
byte[] result)
throws ArithmeticException
Computes the square of the integer represented by the array a, mod the integer represented by the array modulus, and stores the result in the array result must be at least as long as modulus.

Parameters:
a - The array containing the first integer in the operation.
modulus - The array containing the modulus of the operation.
result - The array where the result of the modular operation will be stored.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

square

public static void square(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Computes the square of the integer of length aLength in the array beginning at a[ aOffset ], mod 2log2modulus, and stores the result in result, beginning at resultOffset.

Parameters:
a - The array containing the first integer in the operation.
aOffset - The offset into the first array, where the first byte of the first integer is located.
aLength - The length of the array a.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array where the result of the modular operation will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. resultLength*8 must be at least log2modulus.
Category:
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.
Since:
BlackBerry API 3.6.0

square

public static void square(byte[] a,
int log2modulus,
byte[] result)
Computes the square of the integer represented by the array a, mod 2log2modulus, and stores the result in result.

Parameters:
a - The array containing the first integer in the operation.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8* the length of result.
result - The array where the result of the modular operation will be stored.
Category:
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.
Since:
BlackBerry API 3.6.0

mod

public static void mod(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Computes the modulus of the integer in the array a, beginning at aOffset, moduloed by the integer in the array modulus, beginning at modulusOffset, and stores the result in result, beginning at result[ resultOffset ].

Parameters:
a - The array containing the integer to take the modulo of.
aOffset - The offset into a, where the first byte of the integer is located.
aLength - The length of the integer in a.
modulus - The array containing the modulus.
modulusOffset - The offset into modulus, where the integer begins.
modulusLength - The length of the integer in modulus.
result - Where the resulting value of the operation will be stored.
resultOffset - The offset into result where the result will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

mod

public static void mod(byte[] a,
byte[] modulus,
byte[] result)
throws ArithmeticException
Computes the modulus of the integer represented by the array a moduloed by the integer represented by the array modulus, and stores the result in result. result must be at least as long as modulus.

Parameters:
a - The array containing the array to take the modulo of.
modulus - The array containing the modulus.
result - An array where the resulting value of the operation will be stored.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

mod

public static void mod(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Computes the modulus of the integer in the array a, beginning at aOffset, moduloed by the an integer which is a power of 2 and stores the result in result beginning at result[ resultOffset ].

Parameters:
a - The byte array containing the array to take the modulo of.
aOffset - The offset into a, where the first byte of the integer is located.
aLength - The length of the integer in a.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array that will store the resulting value of the operation.
resultOffset - The offset into result where the result will be stored.
resultLength - The length of the integer in result. resultLength*8 must be at least log2modulus.
Category:
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.
Since:
BlackBerry API 3.6.0

mod

public static void mod(byte[] a,
int log2modulus,
byte[] result)
Computes the modulus of the integer represented by the array a, moduloed by the an integer which is a power of 2, and stores the result in result.

Parameters:
a - The byte array containing the array to take the modulo of.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8* the length of result.
result - The array where the resulting value of the operation will be stored
Category:
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.
Since:
BlackBerry API 3.6.0

invert

public static void invert(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Computes the inverse of the integer in in the array a beginning at aOffset, modulo the integer in modulus beginning at modulusOffset and stores the result the the array result, beginning at result[ resultOffset ].

Parameters:
a - The byte array containing the integer to take the inverse of.
aOffset - The offset into a, where the first byte of the integer is located.
aLength - The length of the integer in a.
modulus - The array containing the modulus. The integer represented in modulus must be odd.
modulusOffset - The offset into modulus, where the first byte of the integer is located.
modulusLength - The length of the integer in modulus.
result - Where the resulting value of the operation will be stored.
resultOffset - The offset into result where the result will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength.
Throws:
ArithmeticException - Thrown if modulus is zero or inverse doesn't exist.
Category:
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.
Since:
BlackBerry API 3.6.0

invert

public static void invert(byte[] a,
byte[] modulus,
byte[] result)
throws ArithmeticException
Computes the inverse of the integer represented by the array a, modulo the integer represented by the array modulus and stores the result in result. result must be at least as long as modulus.

Parameters:
a - The byte array containing the intger to take the inverse of.
modulus - The array containing the modulus. The integer represented in modulus must be odd.
result - Where the resulting value of the operation will be stored.
Throws:
ArithmeticException - Thrown if the modulus is zero or inverse doesn't exist.
Category:
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.
Since:
BlackBerry API 3.6.0

gcd

public static void gcd(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
byte[] result,
int resultOffset,
int resultLength)
Computes the greatest common divisor of the integer represetned by the array a, beginning at aOffset, and the integer represented by the array b, beginning at bOffset and stores the result in the array result, beginning at result[ resultOffset ].

Parameters:
a - The byte array containing the first integer.
aOffset - The offset into a, where the first byte of the integer is located.
aLength - The length of the integer in a.
b - The byte array containing the second integer.
bOffset - The offset into b, where the first byte of the integer is located.
bLength - The length of the integer in b.
result - Where the resulting value of the operation will be stored.
resultOffset - The offset into result where the result of the gcd will be stored.
resultLength - The length of the integer in result. Must be >= the maximum of aLength and bLength.
Category:
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.
Since:
BlackBerry API 3.6.0

gcd

public static void gcd(byte[] a,
byte[] b,
byte[] result)
Computes the greatest common divisor of the integer represented by the array a and the integer represetned by the array b, and stores the result in the array result must be at least as long as the longest of a and b.

Parameters:
a - The byte array containing the first integer.
b - The byte array containing the second integer.
result - Where GCD( a, b ) will be stored.
Category:
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.
Since:
BlackBerry API 3.6.0

exponent

public static void exponent(byte[] base,
int baseOffset,
int baseLength,
byte[] exponent,
int exponentOffset,
int exponentLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
Modular exponentiation with the integers found in base, exponent and modulus Takes basemodulus mod modulus and stores the result in the resultLength bytes of result, beginning at result[ resultOffset ]. resultLength must be at least as large as modulusLength.

Note:MODULUS must be prime for exponentiate to work!

Parameters:
base - The array containing the base in the exponentiation.
baseOffset - The offset into base, where the first byte of the base is located.
baseLength - The length of the integer in base.
exponent - The array containing the exponent.
exponentOffset - The offset into exponent, where the first byte of the exponent is located.
exponentLength - The length of the integer in exponent.
modulus - The array containing the modulus of the operation. Note: this value must be prime.
modulusOffset - The offset into the modulus array, where the first byte of the modulus integer is located.
modulusLength - The length of the integer in modulus.
result - The array where the result of the modular exponentiation will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

exponent

public static void exponent(byte[] base,
byte[] exponent,
byte[] modulus,
byte[] result)
throws ArithmeticException
Modular exponentiation with the integers found in base, exponent and modulus Takes baseexponent mod modulus and stores it in result result must be at least as large as modulus.

Parameters:
base - The array containing the base in the exponentiation.
exponent - The array containing the exponent.
modulus - The array containing the modulus of the operation.
result - The array where the result of the modular exponentiation will be stored. result must be at least as large as modulus.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

increment

public static void increment(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
Adds one to the integer of length aLength in the array beginning at a[ aOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result beginning at resultOffset.

Parameters:
a - The array containing the integer to be incremented.
aOffset - The offset into the first array, where the first byte of the integer is located.
aLength - The length of the integer in a.
modulus - The array containing the modulus of the operation.
modulusOffset - The offset into the modluls array, where the first byte of the modulus integer is located.
modulusLength - The length of the integer in modulus.
result - The array where the result of the modular addition will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

increment

public static void increment(byte[] a,
byte[] modulus,
byte[] result)
Adds one to the integer represented by the array a, mod the integer represented by the array modulus, and stores the result in the array result. result must be at least as long as modulus.

Parameters:
a - The array containing the first integer in the addition.
modulus - The array containing the modulus of the operation.
result - The array where the result of the modular addition will be stored.
Throws:
ArithmeticException - thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

increment

public static void increment(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Adds one to the integer in the array beginning at a[ aOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset.

Parameters:
a - The array containing the integer to have one added to.
aOffset - The offset into the array a, where the first byte of the integer is located.
aLength - The length of the integer in a.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array where the result of the modular addition will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. resultLength*8 must be at least log2modulus.
Category:
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.
Since:
BlackBerry API 3.6.0

increment

public static void increment(byte[] a,
int log2modulus,
byte[] result)
Adds one to the integer represented by array a, mod 2log2modulus and stores the result in the array result.

Parameters:
a - The array containing the integer that will have one added to it.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8* the length of result.
result - The array where the result of the modular addition will be stored.
Category:
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.
Since:
BlackBerry API 3.6.0

decrement

public static void decrement(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
Subtracts one from the integer of length aLength in the array beginning at a[ aOffset ], mod the integer beginning at modulus[ modulusOffset ], and stores the result in the array result beginning at resultOffset.

Parameters:
a - The array containing the integer to be decremented.
aOffset - The offset into the first array, where the first byte of the integer is located.
aLength - The length of the integer in a.
modulus - The array containing the modulus of the operation.
modulusOffset - The offset into the modluls array, where the first byte of the modulus integer is located.
modulusLength - The length of the integer in modulus.
result - The array where the result of the modular subtraction will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. Must be >= modulusLength
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

decrement

public static void decrement(byte[] a,
byte[] modulus,
byte[] result)
Subtracts one from the integer represented by the array a, mod the integer represented by the array modulus, and stores the result in the array result. result must be at least as long as modulus.

Parameters:
a - The array containing the first integer in the subtraction.
modulus - The array containing the modulus of the operation.
result - The array where the result of the modular subtraction will be stored.
Throws:
ArithmeticException - Thrown if the modulus is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

decrement

public static void decrement(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
Subtracts one from the integer in the array beginning at a[ aOffset ], mod 2log2modulus, and stores the result in the array result, beginning at resultOffset.

Parameters:
a - The array containing the integer to have one subtracted from.
aOffset - The offset into the array a, where the first byte of the integer is located.
aLength - The length of the integer in a.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8*resultLength.
result - The array where the result of the modular addition will be stored.
resultOffset - The offset into the result array, where the resulting integer will be stored.
resultLength - The length of the integer in result. resultLength*8 must be at least log2modulus.
Category:
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.
Since:
BlackBerry API 3.6.0

decrement

public static void decrement(byte[] a,
int log2modulus,
byte[] result)
Subtracts one from the integer represented by array a, mod 2log2modulus and stores the result in the array result.

Parameters:
a - The array containing the integer that will have one subtracted from it.
log2modulus - The log2 of the modulus. 0 <= log2modulus <= 8* the length of result.
result - The array where the result of the modular subtraction will be stored.
Category:
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.
Since:
BlackBerry API 3.6.0

divide

public static void divide(byte[] dividend,
int dividendOffset,
int dividendLength,
byte[] divisor,
int divisorOffset,
int divisorLength,
byte[] quotient,
int quotientOffset,
int quotientLength,
byte[] remainder,
int remainderOffset,
int remainderLength)
throws ArithmeticException
Computes the quotient and remainder of the integer in the array dividend, beginning at dividendOffset, divided by the integer in the array divisor, beginning at divisorOffset. The quotient is stored in quotient, beginning at quotientOffset and the remainder is stored in remainder, beginning at remainderOffset.

After the operation, the identity dividend = divisor*quotient + remainder will hold.

NOTE: this operation is not modular arithmetic, like most of the rest of the methods in CryptoByteArrayArithmetic

Parameters:
dividend - The array containing the integer which is the dividend.
dividendOffset - The offset into dividend, where the first byte of the integer is located.
dividendLength - The length of the integer in dividend.
divisor - The array containing the integer which is the divisor.
divisorOffset - The offset into divisor, where the first byte of the integer is located.
divisorLength - The length of the integer in divisor.
quotient - The output array which will contain the quotient of dividend / divisor.
quotientOffset - The offset into quotient, where the first byte of the integer will be.
quotientLength - The length of the integer in quotient. Must be >= dividendLength.
remainder - The output array which will contain the remainder of dividend / divisor.
remainderOffset - The offset into remainder, where the first byte of the integer will be.
remainderLength - The length of the integer in remainder. Must be >= divisorLength.
Throws:
ArithmeticException - Thrown if the divisor is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

divide

public static void divide(byte[] dividend,
byte[] divisor,
byte[] quotient,
byte[] remainder)
throws ArithmeticException
Computes the quotient and remainder of dividend / divisor The quotient is stored in quotient, and the remainder is stored in remainder. The array quotient must be at least as long as dividend and the array remainder must be at least as long as divisor.

After the operation, the identity dividend = divisor*quotient + remainder will hold.
NOTE: this operation is not modular arithmetic, like most of the rest of the methods in CryptoByteArrayArithmetic.

Parameters:
dividend - The array containing the integer which is the dividend.
divisor - The array containing the integer which is the divisor.
quotient - The output array which will contain the quotient of dividend / divisor.
remainder - The output array which will contain the remainder of dividend / divisor.
Throws:
ArithmeticException - Thrown if the divisor is zero.
Category:
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.
Since:
BlackBerry API 3.6.0

trim

public static byte[] trim(byte[] array)
Removes the leading zeros from given byte[] and returns a new byte[] without them. If there are no leading zeros then the given byte array is returned.

Parameters:
array - The byte array from which the leading zeros will be removed.
Returns:
The given array without the leading zeros.
Category:
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.
Since:
BlackBerry API 3.6.0

int numberOfZeros)

Parameters:
array - The byte array to be padded.
numberOfZeros - The number of zero bytes to pad array with.
Returns:
Category:
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.
Since:
BlackBerry API 3.6.0

ensureLength

public static byte[] ensureLength(byte[] array,
int length)
throws NumberFormatException
Takes a byte array and adjusts its length by trimming or padding it. Only leading zeros will be trimmed.

Parameters:
array - The byte[] to be adjusted
length - The length to be adjusted to
Returns:
Throws:
NumberFormatException - Thrown if its not possible to adjust byte[] to the requested size
Category:
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.
Since:
BlackBerry API 3.6.0

valueOf

public static byte[] valueOf(long i)
Converts i into a byte array.

Throws:
IllegalArgumentException - if i < 0
Category:
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.
Since:
BlackBerry API 3.6.0

valueOf

public static long valueOf(byte[] array)
Converts array into a long integer (Note: the returned value should be considered as an unsigned value).

Throws:
IllegalArgumentException - if array contains a number bigger than 64 bits.
Category:
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.
Since:
BlackBerry API 3.6.0

createArray

public static byte[] createArray(int log2n)
Returns an array containing 2^log2n.

Throws:
IllegalArgumentException - if log2n < 0
CryptoByteArrayArithmetic.getNumBits(byte[])
Category:
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.
Since:
BlackBerry API 3.6.0

getNumBits

public static int getNumBits(byte[] array)
Returns the minimum number of bits required to encode the number contained in array.

Throws:
IllegalArgumentException - if array is null.