ds.ov2.test
Class Performance_mult_host

java.lang.Object
  extended by ds.ov2.test.Performance_mult_host

 class Performance_mult_host
extends Object

Correctness check and performance measurements for various methods of the bignat library. This class started as correctness check and performance measusurement tool for multiplication. Now the class name is just misleading. This class checks and measures:

This class contains the complete host driver code for all protocols defined in Bignat_protcols.id.

CPP Preprocessing
no cpp preprocessing needed
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.49 $
Last Commit:
$Date: 2010-02-18 12:40:39 $ by $Author: tews $

Nested Class Summary
private  class Performance_mult_host.Div_call_result
          Combined result record of the div protocol.
private  class Performance_mult_host.Mult_call_result
          Combined result record for the Montgomery multiplication, demontgomerization, squared multiplication, squared 4 multiplication and additon protocols.
 class Performance_mult_host.RSA_exp_result
          Combined result record for the RSA_exp protocol.
private  class Performance_mult_host.Subtract_call_result
          Combined result record for the subtraction protocol.
 
Field Summary
private  Bignat_protocols_stubs bignat_stubs
          Instance with the protocol-step method stubs.
private  CardChannel card_channel
          The channel to the applet.
private  Misc_protocols_host misc_host
          Instance for changing the bignat sizes on the card.
private  PrintWriter out
          The output channel for test and performance data.
 
Constructor Summary
Performance_mult_host(Test_protocols test_protocols, CardChannel cc)
          Construct a new test object.
 
Method Summary
 void add_measure()
          Addition performance.
 Performance_mult_host.Mult_call_result add_perf_once(Random rand, int bignat_size)
          Checks and measures addition on the card.
 Performance_mult_host.Mult_call_result card_add(BigInteger s1, BigInteger s2)
          Run the add protocol to add two numbers on the card.
 Performance_mult_host.Mult_call_result card_demontgomerize(BigInteger bi, Host_modulus m, int rounds_1, int rounds_2)
          Run the demontgomerize protocol (Demontgomerize a number on the card).
 Performance_mult_host.Div_call_result card_div(BigInteger divident, BigInteger divisor, int rounds_1, int rounds_2)
          Run the complete div protocol.
 Performance_mult_host.Mult_call_result card_mont_mult(BigInteger f1, BigInteger f2, Host_modulus m, int rounds_1, int rounds_2)
          Run the mont_mult protocol (Montgomery multiplication on the card).
 Performance_mult_host.Mult_call_result card_normal_mult(BigInteger f1, BigInteger f2, int mult_rounds_1, int mult_rounds_2)
          Run the mult protocol to multiply two numbers on the card.
 Performance_mult_host.Mult_call_result card_short_sq_4_mult(BigInteger f1, BigInteger f2, Host_modulus m)
          Run the short squared 4 mult protocol (Bignat.short_squared_rsa_mult_4).
 Performance_mult_host.Mult_call_result card_short_sq_mult(BigInteger f1, BigInteger f2, Host_modulus m, int rounds_1, int rounds_2)
          Run the short squared mult protocol (Bignat.short_squared_rsa_mult_2).
 Performance_mult_host.Mult_call_result card_sq_mult_4(BigInteger f1, BigInteger f2, Host_modulus mod)
          Run the squared 4 mult protocol (Bignat.squared_rsa_mult_4).
 Performance_mult_host.Mult_call_result card_sq_mult(BigInteger f1, BigInteger f2, Host_modulus m, int rounds_1, int rounds_2)
          Run the squared mult protocol (Bignat.squared_rsa_mult_2).
 Performance_mult_host.Subtract_call_result card_subtract(BigInteger x, BigInteger y)
          Run the subtract protocol to subtract two numbers on the card.
 void div_check()
          Correctness check for division.
 Performance_mult_host.Div_call_result div_measure_size(int size, Random rand, int rounds_1, int rounds_2)
          Measure and print performance of one div protocol run.
 void div_measure()
          Division performance.
 Performance_mult_host.Div_call_result div_perf_once(Random rand, int size, int rounds_1, int rounds_2)
          Performs one division check and measurement.
 BigInteger[][] make_mult_corner_cases(int max_bits, Random rand)
          Generate multiplication corner cases.
 void mult_check()
          Montgomery multiplication correctness check.
 void mult_measure_size(int size, Random rand)
          Measure Montgomery multiplication and demontgomerization performance.
 void mult_measure()
          Montgomery multiplication and demontgomerization performance.
 Performance_mult_host.Mult_call_result[] mult_perf_once(Random rand, int bignat_size, int mult_rounds_1, int mult_rounds_2, int demont_rounds_1, int demont_rounds_2)
          Performs one combined Montgomery multiplication and demontgomerization check and performance measurement.
 void normal_mult_measure()
          Normal multiplication performance.
 Performance_mult_host.Mult_call_result normal_mult_perf_once(Random rand, int bignat_size, int mult_rounds_1, int mult_rounds_2)
          Checks and measures normal multiplication on the card.
 Performance_mult_host.RSA_exp_result rsa_exp_card(BigInteger base, BigInteger exp, BigInteger mod)
          Run the RSA_exp protocol.
 void rsa_exp_check()
          Correctness check for the RSA exponent.
 void rsa_exp_measure_size(Random rand, int short_bit_size, int effective_long_size, int base_bignat_size)
          Measure the computation of one power via RSA encryption and print the timings in gnuplot compatible way.
 void rsa_exp_measure()
          Measure the RSA exponent.
 Performance_mult_host.RSA_exp_result rsa_exp_once(Random rand, int short_bit_size, int effective_long_size, int base_bignat_size)
          Performs one RSA exponent check and measurement.
 void run_add_perf()
          Exception wrapper for add_measure().
 void run_div_check()
          Exception wrapper for div_check().
 void run_div_perf()
          Exception wrapper for div_measure().
 void run_mult_check()
          Exception wrapper for mult_check().
 void run_mult_perf()
          Exception wrapper for mult_measure().
 void run_normal_mult_perf()
          Exception wrapper for normal_mult_measure().
 void run_rsa_exp_check()
          Exception wrapper for rsa_exp_check().
 void run_rsa_exp_perf()
          Exception wrapper for rsa_exp_measure().
 void run_short_sq_4_mult_perf()
          Exception wrapper for short_sq_4_mult_measure().
 void run_short_sq_mult_perf()
          Exception wrapper for short_sq_mult_measure().
 void run_sq_mult_4_check()
          Exception wrapper for sq_mult_4_check().
 void run_sq_mult_4_perf()
          Exception wrapper for sq_mult_4_measure().
 void run_sq_mult_check()
          Exception wrapper for sq_mult_check().
 void run_sq_mult_perf()
          Exception wrapper for sq_mult_measure().
 void run_subtract_perf()
          Exception wrapper for subtract_measure().
 void short_sq_4_mult_measure()
          Short square 4 multiplication performance.
 Performance_mult_host.Mult_call_result short_sq_4_mult_perf_once(Random rand, int short_bignat_size, int long_bignat_size, BigInteger x, BigInteger y)
          Checks and measures short square 4 multiplication on the card (Bignat.short_squared_rsa_mult_4).
 void short_sq_mult_measure()
          Short squared multiplication performance.
 Performance_mult_host.Mult_call_result short_sq_mult_perf_once(Random rand, int short_bignat_size, int long_bignat_size, int mult_rounds_1, int mult_rounds_2, BigInteger x, BigInteger y)
          Checks and measures short squared multiplication on the card (Bignat.short_squared_rsa_mult_2).
 void sq_mult_4_check()
          Squared 4 multiplication correctness check.
 void sq_mult_4_measure()
          Squared 4 multiplication performance.
 Performance_mult_host.Mult_call_result sq_mult_4_perf_once(Random rand, int bignat_size, BigInteger x, BigInteger y)
          Checks and measures squared 4 multiplication on the card (Bignat.squared_rsa_mult_4).
 void sq_mult_check()
          Squared multiplication correctness check.
 void sq_mult_measure()
          Squared multiplication performance.
 Performance_mult_host.Mult_call_result sq_mult_perf_once(Random rand, int bignat_size, int mult_rounds_1, int mult_rounds_2, BigInteger x, BigInteger y)
          Checks and measures squared multiplication on the card (Bignat.squared_rsa_mult_2).
 void subtract_measure()
          Subtraction performance.
 Performance_mult_host.Subtract_call_result subtract_perf_once(Random rand, int bignat_size)
          Checks and measures subtraction on the card.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

private PrintWriter out
The output channel for test and performance data. Initialized to System.out in the constructor.


misc_host

private Misc_protocols_host misc_host
Instance for changing the bignat sizes on the card.


bignat_stubs

private Bignat_protocols_stubs bignat_stubs
Instance with the protocol-step method stubs.


card_channel

private CardChannel card_channel
The channel to the applet.

Constructor Detail

Performance_mult_host

public Performance_mult_host(Test_protocols test_protocols,
                             CardChannel cc)
Construct a new test object. Creates the stub objects and initializes all the fields.

Method Detail

card_mont_mult

public Performance_mult_host.Mult_call_result card_mont_mult(BigInteger f1,
                                                             BigInteger f2,
                                                             Host_modulus m,
                                                             int rounds_1,
                                                             int rounds_2)
                                                      throws CardException
Run the mont_mult protocol (Montgomery multiplication on the card). Sends the factors f1 and f2 and the modulus m in step mont_mult_init to the card. Performs rounds_1 montgomery multiplications in step mont_mult_1 and rounds_2 rounds in step mont_mult_2. Finally queries the result with the mont_mult_result step.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 900 milliseconds).

Parameters:
f1 - first factor
f2 - second factor
m - modulus
rounds_1 - number of multiplications to perform in the mont_mult_1 step
rounds_2 - number of multiplications to perform in the mont_mult_2 step
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

card_demontgomerize

public Performance_mult_host.Mult_call_result card_demontgomerize(BigInteger bi,
                                                                  Host_modulus m,
                                                                  int rounds_1,
                                                                  int rounds_2)
                                                           throws CardException
Run the demontgomerize protocol (Demontgomerize a number on the card). Sends bi and m in step demont_init to the card, performs rounds_1 demontgomerizations in step demont_1, another rounds_2 demontgomerizations in step demont_2 and gets the demontgomerized result in step demont_result.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 900 milliseconds).

Parameters:
bi - number to demontgomerize
m - modulus
rounds_1 - number of demontgomerizations in step demont_1
rounds_2 - number of demontgomerizations in step demont_2
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

mult_perf_once

public Performance_mult_host.Mult_call_result[] mult_perf_once(Random rand,
                                                               int bignat_size,
                                                               int mult_rounds_1,
                                                               int mult_rounds_2,
                                                               int demont_rounds_1,
                                                               int demont_rounds_2)
                                                        throws CardException
Performs one combined Montgomery multiplication and demontgomerization check and performance measurement. If 3 user provided inputs are available, the factors and the modulus are taken from them (see State.fix_inputs). Otherwise random numbers are generated of size bignat_size for the factors and the modulus. The factors are montgomerized and then multiplied on the card (with the mont_mult protocol) and the result is then demontgomerized on the card (with the demontgomerize protocol).

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined results of the two protocols are given back.

Assumes that the bignat size has been set to an appropriate value before.

Parameters:
rand - Randomness source
bignat_size - the size of the factors and the modulus without Montgomery digits
mult_rounds_1 - number of multiplications in step mont_mult_1
mult_rounds_2 - number of multiplications in step mont_mult_2
demont_rounds_1 - number of demontgomerizations in step demont_1
demont_rounds_2 - number of demontgomerizations in step demont_2
Returns:
the combined results of the mont_mult and the demontgomerize protocol in this order
Throws:
CardException - for communication problems and protocol errors

mult_check

public void mult_check()
                throws CardException
Montgomery multiplication correctness check. Set the bignat size to State.long_size and performs State.rounds multiplication and demontgomerization checks via method mult_perf_once.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

mult_measure_size

public void mult_measure_size(int size,
                              Random rand)
                       throws CardException
Measure Montgomery multiplication and demontgomerization performance. This method runs mult_perf_once once and prints the performance results of the two protocol runs in a nice format for gnuplot. Uses the two multiplication/demontgomerization steps to determine the protocol and data transmission overhead. The measurement is deduced from the timing differences between the respective first and second steps.

If the card makes an error the parameters are printed and the program is terminated.

Parameters:
size - the bignat size to measure without Montgomery digits
rand - Randomness source
Throws:
CardException - for communication problems and protocol errors

mult_measure

public void mult_measure()
                  throws CardException
Montgomery multiplication and demontgomerization performance. Performs State.rounds measurments of montgomery multipliation and demontgomerization for each bignat size between State.start_size and State.long_bignat_max_size with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_div

public Performance_mult_host.Div_call_result card_div(BigInteger divident,
                                                      BigInteger divisor,
                                                      int rounds_1,
                                                      int rounds_2)
                                               throws CardException
Run the complete div protocol. Transfer divident and divisor to the card in step div_init, perform rounds_1 divitions of them in step div_1 and another rounds_2 divitions in step div_2 and finally transfer the results back in step div_result.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 20 milliseconds).

Parameters:
divident - the divident
divisor - the divisor
rounds_1 - number of divitions in step div_1
rounds_2 - number of divitions in step div_2
Returns:
the combined div protocol results
Throws:
CardException - for communication problems and protocol errors

div_perf_once

public Performance_mult_host.Div_call_result div_perf_once(Random rand,
                                                           int size,
                                                           int rounds_1,
                                                           int rounds_2)
                                                    throws CardException
Performs one division check and measurement. If two user provided inputs are available (see State.fix_inputs) divident and division are taken from there. Otherwise they are randomly generated. The divident will be of size size. For the divisor State.divisor_length is interpreted as a percent value of size that the divisor should have.

The bignat size must have been set to an appropriate value before calling this method.

If the card makes an error the parameters are printed and the program is terminated.

Parameters:
rand - Randomness source
size - divident size
rounds_1 - number of divitions in step div_1
rounds_2 - number of divitions in step div_2
Returns:
the combined div protocol results
Throws:
CardException - for communication problems and protocol errors

div_check

public void div_check()
               throws CardException
Correctness check for division. Performs State.rounds runs of the div protocol for size State.long_size.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

div_measure_size

public Performance_mult_host.Div_call_result div_measure_size(int size,
                                                              Random rand,
                                                              int rounds_1,
                                                              int rounds_2)
                                                       throws CardException
Measure and print performance of one div protocol run. The print is gnuplot compatible. Uses the two division steps to determine the protocol and data transmission overhead: The measurement is deduced from the timing difference of the div_1 and the div_2 steps.

If the card makes an error the parameters are printed and the program is terminated.

Parameters:
rand - Randomness source
size - divident size
rounds_1 - number of divitions in step div_1
rounds_2 - number of divitions in step div_2
Returns:
the compined div protocol results
Throws:
CardException - for communication problems and protocol errors

div_measure

public void div_measure()
                 throws CardException
Division performance. Measures State.rounds runs of the div protocol for each size between State.start_size and State.long_size with size increments of 4 bytes. If State.start_size is zero, a very small start size is used. Prints all data in gnuplot compatible format.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

rsa_exp_card

public Performance_mult_host.RSA_exp_result rsa_exp_card(BigInteger base,
                                                         BigInteger exp,
                                                         BigInteger mod)
                                                  throws CardException
Run the RSA_exp protocol. The init step transfers the base, the exponent and the modulus to the card. There the modulus and the exponent are installed in the public key. The second step measures the overhead for calling RSA_exponent.fixed_power, the third step calls that method to just do the encryption. The fourth step measures the overhead for RSA_exponent.power, the fifth step calls that method to compute the power (install the exponent and encrypt). The last step transfers the results back.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 100 milliseconds).

Parameters:
base - the base
exp - the exponent
mod - the modulus
Returns:
combined results for the RSA_exp protocol
Throws:
CardException - for communication problems and protocol errors

rsa_exp_once

public Performance_mult_host.RSA_exp_result rsa_exp_once(Random rand,
                                                         int short_bit_size,
                                                         int effective_long_size,
                                                         int base_bignat_size)
                                                  throws CardException
Performs one RSA exponent check and measurement. If three user provided inputs are available (see State.fix_inputs) base, exponent and modulus are taken from there. Otherwise they are randomly generated. If an exponent has been fixed with -fixed-exponent that exponent is used instead of a randomly generated one.

For the application in the selective disclosure protocols, the modulus and the base should have the same size and the exponent should be shorter. However for performance measurements it would be nice to permit the exponent to be longer than the base. On the card the exponent must be smaller than the key size. Further, the modulus must have key-size many significant bytes. If the first byte in the modulus is zero the jcop emulator and the cards that I tested crash.

As solution we have three sizes here. base_bignat_size equals the key size plus two Montgomery digits. It is given in bytes. effective_long_size is the size of the base in bytes which should not be greater than base_bignat_size minus the Montgomery digits. short_bit_size is the size of the exponent in bits.

The bignat size must have been set to an appropriate value before calling this method.

If the card makes an error the parameters are printed and the program is terminated.

Parameters:
rand - Randomness source
short_bit_size - size of the exponent in bits
effective_long_size - size of the base in bytes
base_bignat_size - size of the modulus in bytes plus two montgomery digits (that is, to obtain the size of the modulus 2 * Bignat.size_multiplier must be subtracted from base_bignat_size)
Returns:
the combined RSA_exp protocol results
Throws:
CardException - for communication problems and protocol errors

rsa_exp_check

public void rsa_exp_check()
                   throws CardException
Correctness check for the RSA exponent. Performs State.rounds tests with sizes derived from State.long_size.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

rsa_exp_measure_size

public void rsa_exp_measure_size(Random rand,
                                 int short_bit_size,
                                 int effective_long_size,
                                 int base_bignat_size)
                          throws CardException
Measure the computation of one power via RSA encryption and print the timings in gnuplot compatible way. For an explanation about the various size parameters, see rsa_exp_once.

If the card makes an error the parameters are printed and the program is terminated.

Parameters:
rand - Randomness source
short_bit_size - size of the exponent in bits
effective_long_size - size of the base in bytes
base_bignat_size - size of the modulus in bytes plus two montgomery digits (that is, to obtain the size of the modulus 2 * Bignat.size_multiplier must be subtracted from base_bignat_size)
Throws:
CardException - for communication problems and protocol errors

rsa_exp_measure

public void rsa_exp_measure()
                     throws CardException
Measure the RSA exponent. Start at State.start_size and perform State.rounds test for each size with 2 byte increments. If State.start_size is 0 a sufficiently small default start size is used. The exponent length will be computed according to the estimations of Lenstra, see Security_parameter, except for the case that State.short_bit_size has been set explicitely. Then this exponent size is used for all measurements.

If the card throws one of the known exceptions for an unsupported key size then this size is dropped and the measurement continues with the next size.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_sq_mult

public Performance_mult_host.Mult_call_result card_sq_mult(BigInteger f1,
                                                           BigInteger f2,
                                                           Host_modulus m,
                                                           int rounds_1,
                                                           int rounds_2)
                                                    throws CardException
Run the squared mult protocol (Bignat.squared_rsa_mult_2). Sends the factors f1 and f2 and the modulus m in step sq_mult_init to the card. Performs rounds_1 multiplications in step mult_1 and rounds_2 rounds in step mult_2. Finally queries the result with the sq_mult_result step.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 1 milliseconds).

Parameters:
f1 - first factor
f2 - second factor
m - modulus
rounds_1 - number of multiplications to perform in the mult_1 step
rounds_2 - number of multiplications to perform in the mult_2 step
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

sq_mult_perf_once

public Performance_mult_host.Mult_call_result sq_mult_perf_once(Random rand,
                                                                int bignat_size,
                                                                int mult_rounds_1,
                                                                int mult_rounds_2,
                                                                BigInteger x,
                                                                BigInteger y)
                                                         throws CardException
Checks and measures squared multiplication on the card (Bignat.squared_rsa_mult_2). If 3 user provided inputs are available, the factors and the modulus are taken from them (see State.fix_inputs). Otherwise, if the arguments x and y are non-null they are taken as factors with a randomly generated modulus of size long_bignat_size. Otherwise random numbers are generated of size bignat_size for the factors and the modulus. The factors are then multiplied on the card with the squared mult protocol.

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined result of the protocol is given back.

Assumes that the bignat size has been set to an appropriate value before.

Parameters:
rand - Randomness source
bignat_size - the size of the factors and the modulus
mult_rounds_1 - number of multiplications in step sq_mult_1
mult_rounds_2 - number of multiplications in step sq_mult_2
x - first factor when non-null
y - first factor when non-null
Returns:
the combined result of the squared mult protocol
Throws:
CardException - for communication problems and protocol errors

sq_mult_check

public void sq_mult_check()
                   throws CardException
Squared multiplication correctness check. Set the bignat size to State.long_size and performs State.rounds squared multiplications checks via method sq_mult_perf_once.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

sq_mult_measure

public void sq_mult_measure()
                     throws CardException
Squared multiplication performance. Performs State.rounds measurments of squared multipliation for each bignat size between State.start_size and State.long_bignat_max_size with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_short_sq_mult

public Performance_mult_host.Mult_call_result card_short_sq_mult(BigInteger f1,
                                                                 BigInteger f2,
                                                                 Host_modulus m,
                                                                 int rounds_1,
                                                                 int rounds_2)
                                                          throws CardException
Run the short squared mult protocol (Bignat.short_squared_rsa_mult_2). Sends the factors f1 and f2 and the modulus m in step short_sq_mult_init to the card. Performs rounds_1 multiplications in step mult_1 and rounds_2 rounds in step mult_2. Finally queries the result with the sq_mult_result step.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 1 milliseconds).

Parameters:
f1 - first factor
f2 - second factor
m - modulus
rounds_1 - number of multiplications to perform in the mult_1 step
rounds_2 - number of multiplications to perform in the mult_2 step
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

make_mult_corner_cases

public BigInteger[][] make_mult_corner_cases(int max_bits,
                                             Random rand)
Generate multiplication corner cases. Generates an array of factor pairs, each pair being a multiplication corner case.

Parameters:
max_bits - maximal number of significant bits of the factors
rand - randomness source
Returns:
corner cases as array of factor pairs

short_sq_mult_perf_once

public Performance_mult_host.Mult_call_result short_sq_mult_perf_once(Random rand,
                                                                      int short_bignat_size,
                                                                      int long_bignat_size,
                                                                      int mult_rounds_1,
                                                                      int mult_rounds_2,
                                                                      BigInteger x,
                                                                      BigInteger y)
                                                               throws CardException
Checks and measures short squared multiplication on the card (Bignat.short_squared_rsa_mult_2). If 3 user provided inputs are available, the factors and the modulus are taken from them (see State.fix_inputs). Otherwise, if the arguments x and y are non-null they are taken as factors with a randomly generated modulus of size long_bignat_size. Otherwise random numbers are generated of size short_bignat_size for the factors and of size long_bignat_size for the modulus. The factors are then multiplied on the card with the short squared mult protocol.

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined result of the protocol is given back.

Assumes that the bignat size has been set to an appropriate value before.

The long_bignat_size must be more than twice as long as the short_bignat_size, otherwise the method on the card might throw an assertion or silently produce wrong values.

Parameters:
rand - Randomness source
short_bignat_size - the size of the factors
long_bignat_size - the size of the modulus
mult_rounds_1 - number of multiplications in step sq_mult_1
mult_rounds_2 - number of multiplications in step sq_mult_2
x - first factor when non-null
y - first factor when non-null
Returns:
the combined result of the short squared mult protocol
Throws:
CardException - for communication problems and protocol errors

short_sq_mult_measure

public void short_sq_mult_measure()
                           throws CardException
Short squared multiplication performance. Performs State.rounds measurments of short squared multipliation for each bignat size between State.start_size and State.short_size with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way. If State.long_size has not been set via option -size the size of the RSA modulus and the temporaries will increase as necessary. Otherwise State.long_size will be used.

If State.check_corner_cases is set will generate multiplication corner cases make_mult_corner_cases and use them in the first rounds of every size.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_sq_mult_4

public Performance_mult_host.Mult_call_result card_sq_mult_4(BigInteger f1,
                                                             BigInteger f2,
                                                             Host_modulus mod)
                                                      throws CardException
Run the squared 4 mult protocol (Bignat.squared_rsa_mult_4). Sends the factors f1 and f2, the modulus m and some multiples of the modulus in step sq_mult_4_init to the card. Performs one multiplication in step sq_mult_4_2 and queries the result with the sq_mult_4_result step.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 1 milliseconds).

Parameters:
f1 - first factor
f2 - second factor
mod - modulus
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

sq_mult_4_perf_once

public Performance_mult_host.Mult_call_result sq_mult_4_perf_once(Random rand,
                                                                  int bignat_size,
                                                                  BigInteger x,
                                                                  BigInteger y)
                                                           throws CardException
Checks and measures squared 4 multiplication on the card (Bignat.squared_rsa_mult_4). If 3 user provided inputs are available, the factors and the modulus are taken from them (see State.fix_inputs). Otherwise, if the arguments x and y are non-null they are taken as factors with a randomly generated modulus of size long_bignat_size. Otherwise random numbers are generated of size bignat_size for the factors and the modulus. The factors are then multiplied on the card with the squared mult 4 protocol.

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined result of the protocol is given back.

Assumes that the bignat size has been set to an appropriate value before.

Parameters:
rand - Randomness source
bignat_size - the size of the factors and the modulus
x - first factor when non-null
y - first factor when non-null
Returns:
the combined result of the squared 4 mult protocol
Throws:
CardException - for communication problems and protocol errors

sq_mult_4_check

public void sq_mult_4_check()
                     throws CardException
Squared 4 multiplication correctness check. Set the bignat size to State.long_size and performs State.rounds squared 4 multiplications checks via method sq_mult_4_perf_once.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

sq_mult_4_measure

public void sq_mult_4_measure()
                       throws CardException
Squared 4 multiplication performance. Performs State.rounds measurments of squared 4 multipliation for each bignat size between State.start_size and State.long_bignat_max_size with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_short_sq_4_mult

public Performance_mult_host.Mult_call_result card_short_sq_4_mult(BigInteger f1,
                                                                   BigInteger f2,
                                                                   Host_modulus m)
                                                            throws CardException
Run the short squared 4 mult protocol (Bignat.short_squared_rsa_mult_4). Sends the factors f1 and f2 and the modulus m in step short_sq_4_mult_init to the card. Step 2 is empty, the multiplication is done in step 3. Finally queries the result with the short_sq_4_mult_result step.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 1 milliseconds).

Parameters:
f1 - first factor
f2 - second factor
m - modulus
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

short_sq_4_mult_perf_once

public Performance_mult_host.Mult_call_result short_sq_4_mult_perf_once(Random rand,
                                                                        int short_bignat_size,
                                                                        int long_bignat_size,
                                                                        BigInteger x,
                                                                        BigInteger y)
                                                                 throws CardException
Checks and measures short square 4 multiplication on the card (Bignat.short_squared_rsa_mult_4). If 3 user provided inputs are available, the factors and the modulus are taken from them (see State.fix_inputs). Otherwise, if the arguments x and y are non-null they are taken as factors with a randomly generated modulus of size long_bignat_size. Otherwise random numbers are generated of size short_bignat_size for the factors and of size long_bignat_size for the modulus. The factors are then multiplied on the card with the short square 4 mult protocol.

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined result of the protocol is given back.

Assumes that the bignat size has been set to an appropriate value before.

The long_bignat_size must be more than twice as long as the short_bignat_size, otherwise the method on the card might throw an assertion or silently produce wrong values.

Parameters:
rand - Randomness source
short_bignat_size - the size of the factors
long_bignat_size - the size of the modulus
x - first factor when non-null
y - first factor when non-null
Returns:
the combined result of the short squared mult protocol
Throws:
CardException - for communication problems and protocol errors

short_sq_4_mult_measure

public void short_sq_4_mult_measure()
                             throws CardException
Short square 4 multiplication performance. Performs State.rounds measurments of short squared multipliation for each bignat size between State.start_size and State.short_size with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way. If State.long_size has not been set via option -size the size of the RSA modulus and the temporaries will increase as necessary. Otherwise State.long_size will be used.

If State.check_corner_cases is set will generate multiplication corner cases make_mult_corner_cases and use them in the first rounds of every size.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_add

public Performance_mult_host.Mult_call_result card_add(BigInteger s1,
                                                       BigInteger s2)
                                                throws CardException
Run the add protocol to add two numbers on the card.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 10 milliseconds).

Parameters:
s1 - first summand
s2 - second summand
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

add_perf_once

public Performance_mult_host.Mult_call_result add_perf_once(Random rand,
                                                            int bignat_size)
                                                     throws CardException
Checks and measures addition on the card. If 2 user provided inputs are available, the summands are taken from them (see State.fix_inputs). Otherwise random numbers are generated of size bignat_size. The summands are then added on the card with the add protocol.

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined result of the protocol is given back.

Assumes that the bignat size has been set to an appropriate value before.

Parameters:
rand - Randomness source
bignat_size - the size of the factors
Returns:
the combined result of the add protocol
Throws:
CardException - for communication problems and protocol errors

add_measure

public void add_measure()
                 throws CardException
Addition performance. Performs State.rounds measurments of addition for each bignat size between State.start_size and State.long_bignat_max_size with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_subtract

public Performance_mult_host.Subtract_call_result card_subtract(BigInteger x,
                                                                BigInteger y)
                                                         throws CardException
Run the subtract protocol to subtract two numbers on the card.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 10 milliseconds).

Parameters:
x - minuend
y - subtrahend
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

subtract_perf_once

public Performance_mult_host.Subtract_call_result subtract_perf_once(Random rand,
                                                                     int bignat_size)
                                                              throws CardException
Checks and measures subtraction on the card. If 2 user provided inputs are available, they are taken as minuend and subtrahend (see State.fix_inputs). Otherwise random numbers are generated of size bignat_size. The numbers are then subtracted on the card with the subtract protocol.

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined result of the protocol is given back.

Assumes that the bignat size has been set to an appropriate value before.

Parameters:
rand - Randomness source
bignat_size - the size of the factors
Returns:
the combined result of the subtract protocol
Throws:
CardException - for communication problems and protocol errors

subtract_measure

public void subtract_measure()
                      throws CardException
Subtraction performance. Performs State.rounds measurments of subtraction for each bignat size between State.start_size and State.long_bignat_max_size with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

card_normal_mult

public Performance_mult_host.Mult_call_result card_normal_mult(BigInteger f1,
                                                               BigInteger f2,
                                                               int mult_rounds_1,
                                                               int mult_rounds_2)
                                                        throws CardException
Run the mult protocol to multiply two numbers on the card.

To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 10 milliseconds).

Parameters:
f1 - first factor
f2 - second factor
mult_rounds_1 - number of multiplications in step mult_1
mult_rounds_2 - number of multiplications in step mult_2
Returns:
combined protocol results
Throws:
CardException - for communication problems and protocol errors

normal_mult_perf_once

public Performance_mult_host.Mult_call_result normal_mult_perf_once(Random rand,
                                                                    int bignat_size,
                                                                    int mult_rounds_1,
                                                                    int mult_rounds_2)
                                                             throws CardException
Checks and measures normal multiplication on the card. If 2 user provided inputs are available, the factors are taken from them (see State.fix_inputs). Otherwise random numbers are generated of size bignat_size. The factors are then multiplied on the card with the mult protocol.

If the card makes an error the parameters are printed and the program is terminated. Otherwise the combined result of the protocol is given back.

Assumes that the bignat size has been set to an appropriate value before. Especially the double_sized bignats must have been set to 2 * bignat_size.

Parameters:
rand - Randomness source
bignat_size - the size of the factors
mult_rounds_1 - number of multiplications in step mult_1
mult_rounds_2 - number of multiplications in step mult_2
Returns:
the combined result of the normal mult protocol
Throws:
CardException - for communication problems and protocol errors

normal_mult_measure

public void normal_mult_measure()
                         throws CardException
Normal multiplication performance. Performs State.rounds measurments of multiplication for each bignat size between State.start_size and State.double_size/ 2 with 4 byte increments. If State.start_size is zero, starts at a very small size. Each measurement is printed in a gnuplot compatible way.

If the card makes an error the parameters are printed and the program is terminated.

Throws:
CardException - for communication problems and protocol errors

run_mult_check

public void run_mult_check()
Exception wrapper for mult_check(). Same as mult_check(), except that exceptions are cought and stack traces are printed for them.


run_mult_perf

public void run_mult_perf()
Exception wrapper for mult_measure(). Same as mult_measure(), except that exceptions are cought and stack traces are printed for them.


run_div_check

public void run_div_check()
Exception wrapper for div_check(). Same as div_check(), except that exceptions are cought and stack traces are printed for them.


run_div_perf

public void run_div_perf()
Exception wrapper for div_measure(). Same as div_measure(), except that exceptions are cought and stack traces are printed for them.


run_rsa_exp_check

public void run_rsa_exp_check()
Exception wrapper for rsa_exp_check(). Same as rsa_exp_check(), except that exceptions are cought and stack traces are printed for them.


run_rsa_exp_perf

public void run_rsa_exp_perf()
Exception wrapper for rsa_exp_measure(). Same as rsa_exp_measure(), except that exceptions are cought and stack traces are printed for them.


run_sq_mult_check

public void run_sq_mult_check()
Exception wrapper for sq_mult_check(). Same as sq_mult_check(), except that exceptions are cought and stack traces are printed for them.


run_sq_mult_perf

public void run_sq_mult_perf()
Exception wrapper for sq_mult_measure(). Same as sq_mult_measure(), except that exceptions are cought and stack traces are printed for them.


run_short_sq_mult_perf

public void run_short_sq_mult_perf()
Exception wrapper for short_sq_mult_measure(). Same as short_sq_mult_measure(), except that exceptions are cought and stack traces are printed for them.


run_sq_mult_4_check

public void run_sq_mult_4_check()
Exception wrapper for sq_mult_4_check(). Same as sq_mult_4_check(), except that exceptions are cought and stack traces are printed for them.


run_sq_mult_4_perf

public void run_sq_mult_4_perf()
Exception wrapper for sq_mult_4_measure(). Same as sq_mult_4_measure(), except that exceptions are cought and stack traces are printed for them.


run_short_sq_4_mult_perf

public void run_short_sq_4_mult_perf()
Exception wrapper for short_sq_4_mult_measure(). Same as short_sq_4_mult_measure(), except that exceptions are cought and stack traces are printed for them.


run_add_perf

public void run_add_perf()
Exception wrapper for add_measure(). Same as add_measure(), except that exceptions are cought and stack traces are printed for them.


run_subtract_perf

public void run_subtract_perf()
Exception wrapper for subtract_measure(). Same as subtract_measure(), except that exceptions are cought and stack traces are printed for them.


run_normal_mult_perf

public void run_normal_mult_perf()
Exception wrapper for normal_mult_measure(). Same as normal_mult_measure(), except that exceptions are cought and stack traces are printed for them.