ostore.security
Class SafeBigInt
java.lang.Object
|
+--ostore.security.SafeBigInt
- All Implemented Interfaces:
- QuickSerializable
- public class SafeBigInt
- extends Object
- implements QuickSerializable
BigInteger is broken in two respects for use with our cryptographic
code; this class makes it hard to run into such problems.
- Version:
- $Id: SafeBigInt.java,v 1.10 2002/07/20 22:19:35 srhea Exp $
- Author:
- Sean C. Rhea
SafeBigInt
public SafeBigInt(byte[] val)
- Don't construct negative numbers.
SafeBigInt
public SafeBigInt(int signum,
byte[] magnitude)
SafeBigInt
public SafeBigInt(int bitLength,
int certainty,
Random rnd)
SafeBigInt
public SafeBigInt(int numBits,
Random rnd)
SafeBigInt
public SafeBigInt(String val)
SafeBigInt
public SafeBigInt(String val,
int radix)
SafeBigInt
public SafeBigInt(BigInteger bi)
SafeBigInt
public SafeBigInt(InputBuffer buffer)
serialize
public void serialize(OutputBuffer buffer)
- Description copied from interface:
QuickSerializable
- Add the object to the
buffer
.
- Specified by:
serialize
in interface QuickSerializable
- Following copied from interface:
ostore.util.QuickSerializable
- Parameters:
buffer
- the output buffer to add the object to
add
public SafeBigInt add(SafeBigInt val)
multiply
public SafeBigInt multiply(SafeBigInt val)
modInverse
public SafeBigInt modInverse(SafeBigInt m)
isProbablePrime
public boolean isProbablePrime(int certainty)
compareTo
public int compareTo(SafeBigInt val)
bitLength
public int bitLength()
equals
public boolean equals(Object other)
- Overrides:
equals
in class Object
toBigInteger
public BigInteger toBigInteger()
mod
public SafeBigInt mod(SafeBigInt m)
gcd
public SafeBigInt gcd(SafeBigInt val)
divide
public SafeBigInt divide(SafeBigInt val)
shiftLeft
public SafeBigInt shiftLeft(int n)
modPow
public SafeBigInt modPow(SafeBigInt exponent,
SafeBigInt m)
intValue
public int intValue()
toString
public String toString()
- Overrides:
toString
in class Object
toString
public String toString(int radix)
toByteArray
public byte[] toByteArray()
- Strips leading zeroes off
super.toByteArray ()
.
valueOf
public static SafeBigInt valueOf(long val)