|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.me.security.BigInteger
This class implements arbitrary precision long integer arithmetic. Its API is mostly identical to that of the java.math.BigInteger class, however there are limitations. This class is designed to be used for cryptographic applications, features not required for these applications have not been implemented. In particular:
Field Summary | |
static BigInteger |
ONE
BigInteger constant 1. |
static BigInteger |
TWO
BigInteger constant 2. |
static BigInteger |
ZERO
BigInteger constant 0. |
Constructor Summary | |
BigInteger(byte[] val)
Create BigInteger from 2's complement representation. |
|
BigInteger(int signum,
byte[] val)
Create BigInteger from sign and magnitude representation. |
|
BigInteger(int numBits,
SecureRandom rndSrc)
Create a random BigInteger which is exactly numBits long. |
|
BigInteger(String val)
Create a BigInteger from a decimal String representation. |
|
BigInteger(String val,
int radix)
Create a BigInteger from a String representation in the specified radix (2 <= radix <= 36). |
Method Summary | |
BigInteger |
abs()
Return the absolute value of this. |
BigInteger |
add(BigInteger val)
Return this + val. |
int |
bitCount()
Return the number of one bits in the binary complement representation of this number. |
int |
bitLength()
Return the index of the highest bit set. |
int |
compareTo(BigInteger val)
Compares this BigInteger to another |
BigInteger |
divide(BigInteger m)
Calculate this divided by m. |
BigInteger[] |
divideAndRemainder(BigInteger val)
Divide this by val and return the result and the remainder. |
boolean |
equals(Object obj)
Test two objects for equality. |
BigInteger |
gcd(BigInteger m)
Return the greatest common divisor of this and m. |
int |
getLowestSetBit()
Get the index of the lowest bit set. |
int |
hashCode()
Return a hash code for this object. |
static boolean |
initNative(boolean verbose)
Initialize the native code. |
int |
intValue()
Return the value of this as a int. |
long |
longValue()
Return the value of this as a long. |
BigInteger |
max(BigInteger val)
Return the larger number of this and val. |
BigInteger |
min(BigInteger val)
Return the smaller number of this and val. |
BigInteger |
mod(BigInteger m)
Calculate this mod m. |
BigInteger |
modInverse(BigInteger m)
Return the modular inverse of this with respect to m. |
BigInteger |
modPow(BigInteger exponent,
BigInteger m)
Compute thisexponent modulo m. |
BigInteger |
multiply(BigInteger val)
Return this * val. |
BigInteger |
setBit(int n)
Set the bit at the given position. |
BigInteger |
shiftLeft(int n)
Create a new BigInteger which is this*2n. |
BigInteger |
shiftRight(int n)
Create a new BigInteger which is this*2-n. |
int |
signum()
Return the signum of this number. |
BigInteger |
subtract(BigInteger val)
Return this - val. |
boolean |
testBit(int n)
Test if the bit at the given position is set. |
byte[] |
toByteArray()
Return a byte array representation of this, MSB first. |
byte[] |
toByteArray(boolean leadingZero)
Return a byte array representation of this, MSB first. |
String |
toString()
Return a base 10 string representation of this. |
String |
toString(int radix)
Return a string representation of this in the given radix. |
static BigInteger |
valueOf(long val)
Create a BigInteger from the specified long value. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final BigInteger ZERO
public static final BigInteger ONE
public static final BigInteger TWO
Constructor Detail |
public BigInteger(int signum, byte[] val) throws NumberFormatException
signum
- val
- NumberFormatException
- public BigInteger(byte[] val)
val
- 2's complement repr. as byte arraypublic BigInteger(int numBits, SecureRandom rndSrc)
length
- of the new BigInteger numbersource
- of the random numberpublic BigInteger(String val) throws NumberFormatException
BigInteger
- as String valueNumberFormatException
- if the characters are not between 0 and 9public BigInteger(String val, int radix) throws NumberFormatException
BigInteger
- as string valueradix
- Method Detail |
public static boolean initNative(boolean verbose)
verbose
- modepublic static BigInteger valueOf(long val)
long
- value representation of the new BigInteger numberpublic int compareTo(BigInteger val)
BigInteger
- to be compared topublic BigInteger shiftRight(int n)
public BigInteger shiftLeft(int n)
public int bitLength()
public boolean testBit(int n)
public BigInteger setBit(int n) throws ArithmeticException
public BigInteger[] divideAndRemainder(BigInteger val)
public BigInteger mod(BigInteger m)
public BigInteger divide(BigInteger m)
public BigInteger subtract(BigInteger val)
public BigInteger add(BigInteger val)
public BigInteger multiply(BigInteger val)
public byte[] toByteArray(boolean leadingZero)
public byte[] toByteArray()
public int getLowestSetBit()
public int bitCount()
public BigInteger modPow(BigInteger exponent, BigInteger m)
public BigInteger gcd(BigInteger m)
public BigInteger modInverse(BigInteger m)
public String toString(int radix)
public String toString()
toString
in class Object
public BigInteger abs()
public int signum()
public BigInteger max(BigInteger val)
public BigInteger min(BigInteger val)
public int intValue()
public long longValue()
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
|
This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |