|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.crypto.CryptoByteArrayArithmetic
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.
Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
| 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 numberOfZeroes)
Pads byte array with zeros. |
|
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 |
public static boolean isZero(byte[] a,
int offset,
int length)
a to 0.
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.a equals zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static boolean isZero(byte[] a)
a to 0.
a - The array to be compared to zero.a equals zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static boolean isOne(byte[] a,
int offset,
int length)
a to 1.
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.a equals one.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static boolean isOne(byte[] a)
a to 1.
a - The array to be compared to one.a equals one.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static int findFirstNonZeroByte(byte[] a,
int offset,
int length)
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.
a - The byte array.offset - The first byte of the integer in a.length - The length in bytes of the integer in a.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.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static int compare(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength)
a to the one represented
in array b.
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.a is numerically
less than, equal to, or greater than the integer in b.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static int compare(byte[] a,
byte[] b)
a to the one represented
in array b.a - The first integer.b - The second integer.a is numerically
less than, equal to, or greater than the integer in b.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void multiplyByTwo(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
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.
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.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void multiplyByTwo(byte[] a,
byte[] modulus,
byte[] result)
throws ArithmeticException
a by two modulo the integer represented
by array modulus.
The result must be at least as long as modulus.
a - The integer to multiply by two.modulus - The modulus.result - The array where the result is stored.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void multiplyByTwo(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
length beginning at a[ aOffset ]
by a modulus which is a power of 2.
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 log2modulusCerticom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void multiplyByTwo(byte[] a,
int log2modulus,
byte[] result)
a by a modulus which is a power of 2.
result must be at least as long as modulus
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.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void divideByTwo(byte[] a,
int aOffset,
int aLength,
byte[] modulus,
int modulusOffset,
int modulusLength,
byte[] result,
int resultOffset,
int resultLength)
throws ArithmeticException
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.
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.ArithmeticException - Thrown when the modulus is zero or a is odd and modulus is even.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void divideByTwo(byte[] a,
byte[] modulus,
byte[] result)
throws ArithmeticException
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.
a - The integer to multiply by two.modulus - The modulus.result - A byte array containing the result.ArithmeticException - Thrown if the modulus is zero or a is odd and modulus is even.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void divideByTwo(byte[] a,
int aOffset,
int aLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
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.
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.ArithmeticException - Thrown if a is odd.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void divideByTwo(byte[] a,
int log2modulus,
byte[] result)
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.
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.ArithmeticException - Thrown if a is odd.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public 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)
throws ArithmeticException
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.
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.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void add(byte[] a,
byte[] b,
byte[] modulus,
byte[] result)
throws ArithmeticException
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.
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.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void add(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
a[ aOffset ] and b[ bOffset ], mod 2log2modulus, and
stores the result in the array result,
beginning at resultOffset.
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.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void add(byte[] a,
byte[] b,
int log2modulus,
byte[] result)
a and b,
mod 2log2modulus and stores the result in the array result.
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.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
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
a[ aOffset ] and b[ bOffset ], mod the
integer beginning at modulus[ modulusOffset ], and stores the result in the array
result, beginning at resultOffset.
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.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void subtract(byte[] a,
byte[] b,
byte[] modulus,
byte[] result)
throws ArithmeticException
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.
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.ArithmeticException - Thrown if the modulus is zero.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void subtract(byte[] a,
int aOffset,
int aLength,
byte[] b,
int bOffset,
int bLength,
int log2modulus,
byte[] result,
int resultOffset,
int resultLength)
a[ aOffset ] and b[ bOffset ], mod 2log2modulus,
and stores the result in the array result, beginning at resultOffset.
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 locatedbLength - 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 log2modulusCerticom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
public static void subtract(byte[] a,
byte[] b,
int log2modulus,
byte[] result)
a and b,
mod 2log2modulus and stores the result in the array result.
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.Certicom Contact Information
Phone:613-254-9258
Email: sales@certicom.com
Website: http://www.certicom.com/rim
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
a[ aOffset ] and b[ bOffset ],
mod the integer in the array beginning at modulus[ modulusOffset ], and stores
the result in result, beginning at resultOffset.
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 l