Package org.bouncycastle.util
Class BigIntegers
java.lang.Object
org.bouncycastle.util.BigIntegers
BigInteger utilities.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final BigInteger
static final BigInteger
static final BigInteger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
asUnsignedByteArray
(int length, BigInteger value) Return the passed in value as an unsigned byte array of the specified length, padded with leading zeros as necessary..static byte[]
asUnsignedByteArray
(BigInteger value) Return the passed in value as an unsigned byte array.static void
asUnsignedByteArray
(BigInteger value, byte[] buf, int off, int len) Write the passed in value as unsigned bytes to the specified buffer range, padded with leading zeros as necessary.static byte
static BigInteger
createRandomBigInteger
(int bitLength, SecureRandom random) Return a positive BigInteger in the range of 0 to 2**bitLength - 1.static BigInteger
createRandomInRange
(BigInteger min, BigInteger max, SecureRandom random) Return a random BigInteger not less than 'min' and not greater than 'max'static BigInteger
createRandomPrime
(int bitLength, int certainty, SecureRandom random) Return a prime number candidate of the specified bit length.static BigInteger
fromUnsignedByteArray
(byte[] buf) static BigInteger
fromUnsignedByteArray
(byte[] buf, int off, int length) static int
static int
static long
static BigInteger
static BigInteger
static boolean
static boolean
static short
-
Field Details
-
ZERO
-
ONE
-
TWO
-
-
Constructor Details
-
BigIntegers
public BigIntegers()
-
-
Method Details
-
asUnsignedByteArray
Return the passed in value as an unsigned byte array.- Parameters:
value
- the value to be converted.- Returns:
- a byte array without a leading zero byte if present in the signed encoding.
-
asUnsignedByteArray
Return the passed in value as an unsigned byte array of the specified length, padded with leading zeros as necessary..- Parameters:
length
- the fixed length of the resultvalue
- the value to be converted.- Returns:
- a byte array padded to a fixed length with leading zeros.
-
asUnsignedByteArray
Write the passed in value as unsigned bytes to the specified buffer range, padded with leading zeros as necessary.- Parameters:
value
- the value to be converted.buf
- the buffer to which the value is written.off
- the start offset in arraybuf
at which the data is written.len
- the fixed length of data written (possibly padded with leading zeros).
-
createRandomInRange
Return a random BigInteger not less than 'min' and not greater than 'max'- Parameters:
min
- the least value that may be generatedmax
- the greatest value that may be generatedrandom
- the source of randomness- Returns:
- a random BigInteger value in the range [min,max]
-
fromUnsignedByteArray
-
fromUnsignedByteArray
-
byteValueExact
-
shortValueExact
-
intValueExact
-
longValueExact
-
modOddInverse
-
modOddInverseVar
-
modOddIsCoprime
-
modOddIsCoprimeVar
-
getUnsignedByteLength
-
createRandomBigInteger
Return a positive BigInteger in the range of 0 to 2**bitLength - 1.- Parameters:
bitLength
- maximum bit length for the generated BigInteger.random
- a source of randomness.- Returns:
- a positive BigInteger
-
createRandomPrime
Return a prime number candidate of the specified bit length.- Parameters:
bitLength
- bit length for the generated BigInteger.random
- a source of randomness.- Returns:
- a positive BigInteger of numBits length
-