|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectds.ov2.test.Performance_mult_host
class Performance_mult_host
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:
Bignat.squared_rsa_mult_2
Bignat.short_squared_rsa_mult_2
Bignat.squared_rsa_mult_4
Bignat.short_squared_rsa_mult_4
Bignat.mult
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 |
---|
private PrintWriter out
System.out
in the constructor.
private Misc_protocols_host misc_host
private Bignat_protocols_stubs bignat_stubs
private CardChannel card_channel
Constructor Detail |
---|
public Performance_mult_host(Test_protocols test_protocols, CardChannel cc)
Method Detail |
---|
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
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).
f1
- first factorf2
- second factorm
- modulusrounds_1
- number of multiplications to perform in the
mont_mult_1 steprounds_2
- number of multiplications to perform in the
mont_mult_2 step
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result card_demontgomerize(BigInteger bi, Host_modulus m, int rounds_1, int rounds_2) throws CardException
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).
bi
- number to demontgomerizem
- modulusrounds_1
- number of demontgomerizations in step demont_1rounds_2
- number of demontgomerizations in step demont_2
CardException
- for communication problems and protocol errorspublic 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
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.
rand
- Randomness sourcebignat_size
- the size of the factors and the modulus
without Montgomery digitsmult_rounds_1
- number of multiplications in step mont_mult_1mult_rounds_2
- number of multiplications in step mont_mult_2demont_rounds_1
- number of demontgomerizations in step
demont_1demont_rounds_2
- number of demontgomerizations in step
demont_2
CardException
- for communication problems and protocol errorspublic void mult_check() throws CardException
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.
CardException
- for communication problems and protocol errorspublic void mult_measure_size(int size, Random rand) throws CardException
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.
size
- the bignat size to measure without Montgomery digitsrand
- Randomness source
CardException
- for communication problems and protocol errorspublic void mult_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Div_call_result card_div(BigInteger divident, BigInteger divisor, int rounds_1, int rounds_2) throws CardException
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).
divident
- the dividentdivisor
- the divisorrounds_1
- number of divitions in step div_1rounds_2
- number of divitions in step div_2
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Div_call_result div_perf_once(Random rand, int size, int rounds_1, int rounds_2) throws CardException
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.
rand
- Randomness sourcesize
- divident sizerounds_1
- number of divitions in step div_1rounds_2
- number of divitions in step div_2
CardException
- for communication problems and protocol errorspublic void div_check() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Div_call_result div_measure_size(int size, Random rand, int rounds_1, int rounds_2) throws CardException
If the card makes an error the parameters are printed and the program is terminated.
rand
- Randomness sourcesize
- divident sizerounds_1
- number of divitions in step div_1rounds_2
- number of divitions in step div_2
CardException
- for communication problems and protocol errorspublic void div_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.RSA_exp_result rsa_exp_card(BigInteger base, BigInteger exp, BigInteger mod) throws CardException
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).
base
- the baseexp
- the exponentmod
- the modulus
CardException
- for communication problems and protocol errorspublic 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
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.
rand
- Randomness sourceshort_bit_size
- size of the exponent in bitseffective_long_size
- size of the base in bytesbase_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
)
CardException
- for communication problems and protocol errorspublic void rsa_exp_check() throws CardException
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.
CardException
- for communication problems and protocol errorspublic void rsa_exp_measure_size(Random rand, int short_bit_size, int effective_long_size, int base_bignat_size) throws CardException
rsa_exp_once
.
If the card makes an error the parameters are printed and the program is terminated.
rand
- Randomness sourceshort_bit_size
- size of the exponent in bitseffective_long_size
- size of the base in bytesbase_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
)
CardException
- for communication problems and protocol errorspublic void rsa_exp_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result card_sq_mult(BigInteger f1, BigInteger f2, Host_modulus m, int rounds_1, int rounds_2) throws CardException
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).
f1
- first factorf2
- second factorm
- modulusrounds_1
- number of multiplications to perform in the
mult_1 steprounds_2
- number of multiplications to perform in the
mult_2 step
CardException
- for communication problems and protocol errorspublic 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
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.
rand
- Randomness sourcebignat_size
- the size of the factors and the modulusmult_rounds_1
- number of multiplications in step sq_mult_1mult_rounds_2
- number of multiplications in step sq_mult_2x
- first factor when non-nully
- first factor when non-null
CardException
- for communication problems and protocol errorspublic void sq_mult_check() throws CardException
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.
CardException
- for communication problems and protocol errorspublic void sq_mult_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic 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
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).
f1
- first factorf2
- second factorm
- modulusrounds_1
- number of multiplications to perform in the
mult_1 steprounds_2
- number of multiplications to perform in the
mult_2 step
CardException
- for communication problems and protocol errorspublic BigInteger[][] make_mult_corner_cases(int max_bits, Random rand)
max_bits
- maximal number of significant bits of the
factorsrand
- randomness source
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
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.
rand
- Randomness sourceshort_bignat_size
- the size of the factorslong_bignat_size
- the size of the modulusmult_rounds_1
- number of multiplications in step sq_mult_1mult_rounds_2
- number of multiplications in step sq_mult_2x
- first factor when non-nully
- first factor when non-null
CardException
- for communication problems and protocol errorspublic void short_sq_mult_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result card_sq_mult_4(BigInteger f1, BigInteger f2, Host_modulus mod) throws CardException
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).
f1
- first factorf2
- second factormod
- modulus
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result sq_mult_4_perf_once(Random rand, int bignat_size, BigInteger x, BigInteger y) throws CardException
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.
rand
- Randomness sourcebignat_size
- the size of the factors and the modulusx
- first factor when non-nully
- first factor when non-null
CardException
- for communication problems and protocol errorspublic void sq_mult_4_check() throws CardException
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.
CardException
- for communication problems and protocol errorspublic void sq_mult_4_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result card_short_sq_4_mult(BigInteger f1, BigInteger f2, Host_modulus m) throws CardException
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).
f1
- first factorf2
- second factorm
- modulus
CardException
- for communication problems and protocol errorspublic 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
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.
rand
- Randomness sourceshort_bignat_size
- the size of the factorslong_bignat_size
- the size of the modulusx
- first factor when non-nully
- first factor when non-null
CardException
- for communication problems and protocol errorspublic void short_sq_4_mult_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result card_add(BigInteger s1, BigInteger s2) throws CardException
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).
s1
- first summands2
- second summand
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result add_perf_once(Random rand, int bignat_size) throws CardException
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.
rand
- Randomness sourcebignat_size
- the size of the factors
CardException
- for communication problems and protocol errorspublic void add_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Subtract_call_result card_subtract(BigInteger x, BigInteger y) throws CardException
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).
x
- minuendy
- subtrahend
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Subtract_call_result subtract_perf_once(Random rand, int bignat_size) throws CardException
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.
rand
- Randomness sourcebignat_size
- the size of the factors
CardException
- for communication problems and protocol errorspublic void subtract_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic Performance_mult_host.Mult_call_result card_normal_mult(BigInteger f1, BigInteger f2, int mult_rounds_1, int mult_rounds_2) throws CardException
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).
f1
- first factorf2
- second factormult_rounds_1
- number of multiplications in step mult_1mult_rounds_2
- number of multiplications in step mult_2
CardException
- for communication problems and protocol errorspublic 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
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
.
rand
- Randomness sourcebignat_size
- the size of the factorsmult_rounds_1
- number of multiplications in step mult_1mult_rounds_2
- number of multiplications in step mult_2
CardException
- for communication problems and protocol errorspublic void normal_mult_measure() throws CardException
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.
CardException
- for communication problems and protocol errorspublic void run_mult_check()
mult_check()
. Same as mult_check()
, except that exceptions are cought and stack
traces are printed for them.
public void run_mult_perf()
mult_measure()
. Same as mult_measure()
, except that exceptions are cought and stack
traces are printed for them.
public void run_div_check()
div_check()
. Same as div_check()
, except that exceptions are cought and stack traces
are printed for them.
public void run_div_perf()
div_measure()
. Same as div_measure()
, except that exceptions are cought and stack
traces are printed for them.
public void run_rsa_exp_check()
rsa_exp_check()
. Same as rsa_exp_check()
, except that exceptions are cought and stack
traces are printed for them.
public void run_rsa_exp_perf()
rsa_exp_measure()
. Same as rsa_exp_measure()
, except that exceptions are cought and stack
traces are printed for them.
public void run_sq_mult_check()
sq_mult_check()
. Same as sq_mult_check()
, except that exceptions are cought and stack
traces are printed for them.
public void run_sq_mult_perf()
sq_mult_measure()
. Same as sq_mult_measure()
, except that exceptions are cought and stack
traces are printed for them.
public void run_short_sq_mult_perf()
short_sq_mult_measure()
. Same as
short_sq_mult_measure()
, except that exceptions are
cought and stack traces are printed for them.
public void run_sq_mult_4_check()
sq_mult_4_check()
. Same as sq_mult_4_check()
, except that exceptions are cought and stack
traces are printed for them.
public void run_sq_mult_4_perf()
sq_mult_4_measure()
. Same as sq_mult_4_measure()
, except that exceptions are cought and stack
traces are printed for them.
public void run_short_sq_4_mult_perf()
short_sq_4_mult_measure()
. Same as
short_sq_4_mult_measure()
, except that exceptions are
cought and stack traces are printed for them.
public void run_add_perf()
add_measure()
. Same as add_measure()
, except that exceptions are cought and stack
traces are printed for them.
public void run_subtract_perf()
subtract_measure()
. Same as subtract_measure()
, except that exceptions are cought and stack
traces are printed for them.
public void run_normal_mult_perf()
normal_mult_measure()
. Same as normal_mult_measure()
, except that exceptions are cought and stack
traces are printed for them.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |