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

Constructor Summary
SafeBigInt(BigInteger bi)
           
SafeBigInt(byte[] val)
          Don't construct negative numbers.
SafeBigInt(InputBuffer buffer)
           
SafeBigInt(int signum, byte[] magnitude)
           
SafeBigInt(int bitLength, int certainty, Random rnd)
           
SafeBigInt(int numBits, Random rnd)
           
SafeBigInt(String val)
           
SafeBigInt(String val, int radix)
           
 
Method Summary
 SafeBigInt add(SafeBigInt val)
           
 int bitLength()
           
 int compareTo(SafeBigInt val)
           
 SafeBigInt divide(SafeBigInt val)
           
 boolean equals(Object other)
           
 SafeBigInt gcd(SafeBigInt val)
           
 int intValue()
           
 boolean isProbablePrime(int certainty)
           
 SafeBigInt mod(SafeBigInt m)
           
 SafeBigInt modInverse(SafeBigInt m)
           
 SafeBigInt modPow(SafeBigInt exponent, SafeBigInt m)
           
 SafeBigInt multiply(SafeBigInt val)
           
 void serialize(OutputBuffer buffer)
          Add the object to the buffer.
 SafeBigInt shiftLeft(int n)
           
 BigInteger toBigInteger()
           
 byte[] toByteArray()
          Strips leading zeroes off super.toByteArray ().
 String toString()
           
 String toString(int radix)
           
static SafeBigInt valueOf(long val)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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)
Method Detail

serialize

public void serialize(OutputBuffer buffer)
Description copied from interface: QuickSerializable
Add the object to the buffer.

Specified by:
serialize in interface 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)