ds.ov2.front
Class PTLS_rsa_parameters

java.lang.Object
  extended by ds.ov2.front.PTLS_rsa_parameters

public class PTLS_rsa_parameters
extends Object

PTLS parameters. The PTLS parameters are the static parameters that are needed for the OV-chip RSA protocols. They need to be generated once before the system starts. The PTLS parameter set contains the key material as well as the number of attributes and the key length'.

Montgomerization and Demontgomerization factors depend on the RSA modulus n and they are therefore included here (in the host modulus hmod). However, they also depend on the number of Montgomery digits and therefore on the applet type. Some methods here take therefore an applet type argument, although the PTLS parameters itself are independent of the applet type.

CPP Preprocessing
This class uses the following cpp defines: APPLET_TESTFRAME, TESTFRAME
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.22 $
Last Commit:
$Date: 2010-02-16 10:26:07 $ by $Author: tews $

Nested Class Summary
static class PTLS_rsa_parameters.PTLS_io_exception
          Exception for I/O problems during reading/writing PTLS parameters from/to disk.
 
Field Summary
 int attribute_number
          The number of attributes.
 BigInteger[] base
          The array of the bases.
 int base_length
          Length of the bases and the RSA modulus in bits (long bignats).
 int exponent_length
          The length of the attributes in bits (short or exponent bignats).
 Host_modulus hmod
          The RSA modulus wrapped in a host modulus that contains (de-)montgomerization factors as well.
(package private)  BigInteger inv_v
          1/v, the inverse of v modulus euler_phi(n)
 BigInteger n
          The RSA modulus, product of two primes.
private  PrintWriter out
          Output channel for debug and progress messages.
static int prime_certainy
          Prime certainy: certainy parameter for probabilistic prime generation.
private  BigInteger ptls_private_key
          The private key x of the PTLS.
 BigInteger ptls_public_key
          The public key of the PTLS h = x^v.
private  Random rand
          Randomness source.
 BigInteger v
          The RSA exponent v, coprime to euler_phi(n).
private  int verbosity
          Verbosity level.
private static String version
          cvs revision number, kept up to date by cvs keyword substitution.
 
Constructor Summary
PTLS_rsa_parameters(int attribute_number, PrintWriter out, int verbosity)
          Constructor.
 
Method Summary
private  BigInteger[] generate_v(BigInteger p, BigInteger q)
          Generate the public RSA exponent v.
 void generate(int base_length, int exponent_length, Applet_type applet_type)
          Generate a new set of PTLS parameters and store them in this instance.
private static String get_next_data(BufferedReader fin)
          Retrurn the part after the colon from the next line in the input fin.
 int make_base_bytes(int montgomery_digits)
          Compute the length of the bases and the RSA modulus in bytes for this instance.
 int make_exponent_bytes()
          Compute the length of the attributes/exponents in bytes for this instance.
(package private)  void print_all(Applet_type applet_type, PrintWriter out)
          Print all parameters in this instance to the given channel.
static PTLS_rsa_parameters read_from_file(String filename, Applet_type applet_type, PrintWriter out, int verbosity)
          Create a new PTLS parameter instance by loading file filename.
 void write_to_file(String filename)
          Write the PTLS parameters in this instance to file filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

base_length

public int base_length
Length of the bases and the RSA modulus in bits (long bignats).


exponent_length

public int exponent_length
The length of the attributes in bits (short or exponent bignats).


attribute_number

public final int attribute_number
The number of attributes.


n

public BigInteger n
The RSA modulus, product of two primes.


hmod

public Host_modulus hmod
The RSA modulus wrapped in a host modulus that contains (de-)montgomerization factors as well.


v

public BigInteger v
The RSA exponent v, coprime to euler_phi(n). All attributes must be smaller than v.


inv_v

BigInteger inv_v
1/v, the inverse of v modulus euler_phi(n)


ptls_private_key

private BigInteger ptls_private_key
The private key x of the PTLS.


ptls_public_key

public BigInteger ptls_public_key
The public key of the PTLS h = x^v.


base

public BigInteger[] base
The array of the bases. Has length attribute_number.


prime_certainy

public static final int prime_certainy
Prime certainy: certainy parameter for probabilistic prime generation.

See Also:
Constant Field Values

rand

private final Random rand
Randomness source.


out

private PrintWriter out
Output channel for debug and progress messages.


verbosity

private int verbosity
Verbosity level.


version

private static final String version
cvs revision number, kept up to date by cvs keyword substitution. The revision number is used to tag PTLS parameter files.

See Also:
Constant Field Values
Constructor Detail

PTLS_rsa_parameters

public PTLS_rsa_parameters(int attribute_number,
                           PrintWriter out,
                           int verbosity)
Constructor. Copies only the arguments into the state of this instance. Does not generate new PTLS parameters.

Parameters:
attribute_number - number of attributes
out - debug/progress messages
verbosity - verbosity
Method Detail

generate_v

private BigInteger[] generate_v(BigInteger p,
                                BigInteger q)
Generate the public RSA exponent v. If compiled with APPLET_TESTFRAME and if another fixed input is available, take the next fixed input as v. Otherwise generate it randomly satisfying the necessary conditions.

Parameters:
p - first factor of the RSA modulus
q - second factor of the RSA modulus
Returns:
v of bit-length exponent_length, prime, and coprime to phi(p * q)

make_base_bytes

public int make_base_bytes(int montgomery_digits)
Compute the length of the bases and the RSA modulus in bytes for this instance.

Parameters:
montgomery_digits - number of montgomery digits
Returns:
base length in bytes

make_exponent_bytes

public int make_exponent_bytes()
Compute the length of the attributes/exponents in bytes for this instance.

Returns:
attribute/exponent length in bytes

generate

public void generate(int base_length,
                     int exponent_length,
                     Applet_type applet_type)
              throws NoSuchAlgorithmException
Generate a new set of PTLS parameters and store them in this instance. For base length greater than 512 bits the (hopefully secure) Java RSA key generator is used. For base length below 512 bits Unsecure_rsa_key is used.

If compiled with APPLET_TESTFRAME, and if fixed inputs are available, they are taken as follows. First two inputs: factors of the RSA modulus n. Input number 3: v. Input number 4: x, the private PTLS key ptls_private_key. The next attribute_number inputs: the bases.

Parameters:
base_length - length of the bases and the RSA modulus in bits
exponent_length - length of the attributes (exponents) in bits
applet_type - current applet type for determining the number of Montgomery digits and the (de-)montgomerization factors
Throws:
NoSuchAlgorithmException - if no provider for RSA key generation can be found

write_to_file

public void write_to_file(String filename)
                   throws PTLS_rsa_parameters.PTLS_io_exception
Write the PTLS parameters in this instance to file filename. No compatibility with future and past versions. The file format is simply ASCII with the numbers as decimal strings.

Parameters:
filename - file to write to
Throws:
PTLS_rsa_parameters.PTLS_io_exception - if an IO error occurs

get_next_data

private static String get_next_data(BufferedReader fin)
                             throws PTLS_rsa_parameters.PTLS_io_exception
Retrurn the part after the colon from the next line in the input fin.

Parameters:
fin - input reader
Returns:
the part after the colon of the next line, which should be a number in decimal base
Throws:
PTLS_rsa_parameters.PTLS_io_exception - for read errors

read_from_file

public static PTLS_rsa_parameters read_from_file(String filename,
                                                 Applet_type applet_type,
                                                 PrintWriter out,
                                                 int verbosity)
                                          throws PTLS_rsa_parameters.PTLS_io_exception
Create a new PTLS parameter instance by loading file filename.

Parameters:
filename - file to read
applet_type - current applet type for determining the number of Montgomery digits and the (de-)montgomerization factors
out - debug/progress channel, may be null to supress output
verbosity - verbosity level
Returns:
parameter instance with parameters read from filename
Throws:
PTLS_rsa_parameters.PTLS_io_exception - if the file is not accessable, its version tag does not match version, or some other read error occurs

print_all

void print_all(Applet_type applet_type,
               PrintWriter out)
Print all parameters in this instance to the given channel.

Only available if TESTFRAME is defined.

Parameters:
applet_type - current applet type for determining the number of Montgomery digits and the (de-)montgomerization factors
out - channel to print to