|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectds.ov2.front.RSA_squared_card
public class RSA_squared_card
Protocol methods for the squared RSA applet. The code here is very
similar to RSA_plain_card
and RSA_mont_card
. There
are however enough differences to make a gerneralized unified class
a mess. All three applets, the Montgomerizing, the plain RSA and
the squaring RSA applet are very similar. For simplicity even all
protocol steps are identical (although not all of the data that is
transfered during applet personalization is used here in all
applets). Most differences between the three applets are just treated
by conditionals. Only for this class the differences are too big to
cover them all nicely in conditionals.
The squaring RSA applet uses an RSA cipher to compute both powers and products. It does neither need Montgomery correction factors nor Montgomery digits. For the communication with the host, all numbers are in plain, unmontgomerized form.
This class contains the methods that are called from the actions in
the protocol steps. Some of the necessary temporary values are
defined and allocated here. Most of the necessary data is however
in RSA_data
. The temporary values defined here do not take
part in the communication with the host. Therefore this class does
not need to be present in the host driver.
Field Summary | |
---|---|
private Vector |
alphas
Alphas and quotients. |
(package private) Bignat |
beta_1
Random beta_1 from the resign protocol and beta from the proof protocoll. |
(package private) Bignat |
beta_2
Random beta_2 from the resign protocol. |
(package private) RSA_data |
data
Static data and data send and received from the host. |
private Bignat |
double_small
Intermediate value of double small size. |
(package private) Front_protocols |
front_protocols
Registered protocols instance. |
(package private) MessageDigest |
hash
Message digest for computing 160 bit SHA-1. |
static PrintWriter |
out
Debug printer. |
(package private) Bignat |
ptls_key_times_temp_blinded_a
Temporary result RSA_data.ptls_key times the temporary
blinded attribute expression. |
private RandomData |
rand
Random number generator of type RANDOM. |
(package private) RSA_exponent |
rsa_exponent
Object for computing single exponents via public RSA encryption. |
(package private) Bignat |
sig_quotient
Qutient d in the signature protocol. |
(package private) RSA_exponent |
square_exponent
Object for computing squares via public RSA encryption in Bignat.squared_rsa_mult_2 ,
Bignat.short_squared_rsa_mult_2 , Bignat.squared_rsa_mult_4 and Bignat.short_squared_rsa_mult_4 . |
private Bignat |
temp_2
Temporary. |
private Bignat |
temp_3
Temporary. |
private Bignat |
temp_4
Temporary. |
Constructor Summary | |
---|---|
RSA_squared_card(RSA_data data,
Front_protocols front_protocols)
Non-allocating constructor. |
Method Summary | |
---|---|
void |
allocate(short short_bignat_size,
short long_bignat_size,
short attribute_length,
short mont_correction_len)
Allocate all data of the applet. |
void |
finish_signature(APDU_boolean accept)
Third step of the resign protocol. |
void |
initialize()
Initialize the squaring RSA applet data structures. |
void |
make_sig_hash()
Second step of the resign protocol. |
void |
proof_commit()
First step of the gate or proof protocol. |
void |
respond_to_challenge()
Second step of the gate or proof protocol. |
void |
switch_to_new_attributes(APDU_boolean success)
Atomically switch to various new values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
Front_protocols front_protocols
switch_to_new_attributes
.)
RSA_data data
private Bignat temp_2
temp_3
and RSA_data.result
in various computations.
Long bignat.
private Bignat temp_3
temp_2
and RSA_data.result
in various computations.
Long bignat.
private Bignat temp_4
Long bignat.
private Vector alphas
RSA_data.remainders
.)
The last element with index RSA_data.attribute_length
is always an alias of either RSA_data.v
or RSA_data.gamma_beta_3
.
In the resign protocol the vector is not used except for its
first entry (at index 0), which aliased under sig_quotient
and which stores the quotient there.
Length RSA_data.attribute_length
+ 1. Filled with short
bignats.
private Bignat double_small
Bignat.short_squared_rsa_mult_2
and Bignat.short_squared_rsa_mult_4
.
Bignat beta_1
Long bignat.
Bignat beta_2
Long bignat.
Bignat ptls_key_times_temp_blinded_a
RSA_data.ptls_key
times the temporary
blinded attribute expression. This is used three times in the
resign protocol. Long bignat.
Bignat sig_quotient
RSA_data.sig_remainder
). Alias of alphas
[0], which are otherwise not used during resigning.
Short bignat.
private RandomData rand
RSA_exponent rsa_exponent
RSA_exponent square_exponent
Bignat.squared_rsa_mult_2
,
Bignat.short_squared_rsa_mult_2
, Bignat.squared_rsa_mult_4
and Bignat.short_squared_rsa_mult_4
.
Has type
RSA_EXPONENT.
MessageDigest hash
public static PrintWriter out
Constructor Detail |
---|
public RSA_squared_card(RSA_data data, Front_protocols front_protocols)
data
and front_protocols
fields and creates an RSA_EXPONENT
for rsa_exponent
. Sets the State to UNALLOCTED
when
finished (see applet state
description). Allocation of all the bignats and vectors has
to be done explicitely with allocate(short, short, short, short)
.
data
- the data instancefront_protocols
- the protocols instanceMethod Detail |
---|
public void allocate(short short_bignat_size, short long_bignat_size, short attribute_length, short mont_correction_len)
RSA_data
and this class is allocated during applet
installation. Afterwards this method must be called in order to
allocate all further data structures (mainly bignats and
vectors).
The decision whether to allocate the data in RAM (transient
memory) or EEProm is hardwired here and in RSA_data.allocate(short, short, short, short, byte)
. It works for cards with about 2K of RAM up
to 1952 bit keys. If there is too little RAM or the key
size is too big strange things will happen.
Asserts that the state
is UNALLOCTED
. Sets the state to
UNINITIALIZED
when finished (see
applet state
description).
short_bignat_size
- size in bytes of the short (exponent) bignatslong_bignat_size
- size in bytes of the long (base) bignatsattribute_length
- number of attributes (without counting
the blinding)mont_correction_len
- length of the data.montgomery_corrections
arraypublic void initialize()
allocation
and before the
first resigning.
Before this method is entered the OV-chip protocol layer transfers the following data as arguments of the initialize step into the right place:
data
.n
data
.v
(indirectly via RSA_data.current_attributes
)data
.ptls_key
data
.bases
data
.base_factors
The base factors are not needed in the squaring applet, but for
simplicity all RSA applets share the
same protocol description. In this applet the length of the
base_factors vector is just 1.data
.current_attributes
data
.current_blinding
(indirectly via RSA_data.bases
)data
.RSA_data.montgomerized_one
Montgomerized 1. Not needed in this applet, but for simplicity
...data
.montgomery_corrections
. Not needed in this applet, but for
simplicity ...
Asserts that the applet is in state UNINITIALIZED
. After completion the
state is set to INITIALIZED
(see
applet state
description).
There are no results sent back to the host by the OV-chip protocol layer after this method has finished.
The source code of this method is affected by Brand's patents on selective disclosure protocols that are now in the posession of Microsoft. Microsoft lawyers are still pondering our request from January 2009 for making the full source code publically available. The source code of this method is therefore currently not publically available. The detailed operations of this method are:
data
.state
contains UNINITIALIZED
data
.mod_first_digit_mask
, data
.v_first_digit_mask
Bignat.get_first_digit_mask
. An important subtlety here is
that the index of the first digit of the modulus is always 0
because there are no montgomery digits used for this applet.
rsa_exponent
initialization
data
.n
.m
with RSA_exponent_interface.set_modulus
.
square_exponent
initialization
square_exponent
. Further
initialize some temporary
to 2 (Bignat.two()
) and set this as exponent with RSA_exponent_interface.set_exponent
(all temporaries can be
used for this purpose here; the offset is zero, because there
are no Montgomery digits in this applet).
data
.current_blinded_a
data.bases
^data.current_attributes
with
data
.bases
.squared_rsa_exponent_mod
.
It is wise to use all four temporaries (RSA_data.result
, temp_2
, temp_3
, temp_4
) here, let the result be stored in one of them and
copy (Bignat.copy
)
it later to data
.current_blinded_a
.
Note that the RSA_data.current_blinding
and the RSA_data.v
are alias in the bases and current_attributes
vector at index RSA_data.attribute_length
+ 1.
RSA_data.state
INITIALIZED
public void switch_to_new_attributes(APDU_boolean success)
finish_signature
step of the resign protocol the new_*
versions are atomically copied into the current_* ones. This is
done in this method by swapping references.
Swapping the references introduces a little problem in the
protocol layer: The layer also has aliases for instance of
RSA_data.current_blinded_a
and of RSA_data.current_signature
. After swapping references, these
aliases suddenly alias invalid data. Therefore one has to
uptate the step data structure with front_protocols.update_steps
.
The source code of this method is affected by Brand's patents on selective disclosure protocols that are now in the posession of Microsoft. Microsoft lawyers are still pondering our request from January 2009 for making the full source code publically available. The source code of this method is therefore currently not publically available. The detailed operations of this method are:
data
.current_attributes
, data
.current_blinding
, data
.current_blinded_a
and data
.current_signature
,
respectively.
success
is still false and that
data
.new_attributes
aliases
data
.v
at index data
.attribute_length
.
Misc.begin_transaction()
in order to be
compatible with the HOST_TESTFRAME
front_protocols
.update_steps
data
.RSA_data.state
to
BLINDED
if it was INITIALIZED
, set success
to true
and commit the
transaction with
Misc.commit_transaction()
success
- alias of RSA_card_protocol_description.signature_accepted
, initially
false, set to true when the atomic swapping succeedspublic void make_sig_hash()
data
.applet_id
, data
.current_blinded_a
and data
.current_signature
are
sent to the host in the
first step.) Prior to calling this method the protocol layer receives
data
.host_alpha
data
.remainders
; these
updates are in modulo format: to subract x
from an
attribute, the host sends data
.v
- x
.
After this method the protocol layer sends the remainder c in
data
.sig_remainder
.
Asserts that the applet is in state INITIALIZED
or BLINDED
(see applet state
description).
The source code of this method is affected by Brand's patents on selective disclosure protocols that are now in the posession of Microsoft. Microsoft lawyers are still pondering our request from January 2009 for making the full source code publically available. The source code of this method is therefore currently not publically available. The detailed operations of this method are:
data
.RSA_data.state
is either
INITIALIZED
or BLINDED
.
data
.new_attributes
double_small
, where the update from data
.remainders
is added and the
remainder modulo data
.v
is taken. Finally
the remainder in double_small
is copied to the new
attributes in data
.new_attributes
. The alias
to data
.v
at index data
.attribute_length
in data
.new_attributes
and data
.current_attributes
must not be
touched.
beta_1
, beta_2
and data
.gamma_beta_3
must be filled with random
values using
Bignat.rand_mod
. The first two are
long bignats modulo the RSA modulus that contain no
Montgomery digits. For the first two one has therefore
to use the modulus data
.n
.m
, the first digit index 0, and the
mask data
.mod_first_digit_mask
. For the third beta one has to use the
modulus data
.v
, the first digit
index 0, and the mask data
.v_first_digit_mask
.
XXXXXXXXXXXXXXXXXXXXXXXX
The remaining detailed description is not up to date.
data
.get_montgomery_correction
)
in one of the temporaries. Multiply this temporary then with
beta_1
in another temporary. Finally copy the last
temporary into data
.new_blinding
.
data
.set_current_blinding
. Compute then the exponent data
.bases
^data
.new_attributes
with the method Vector.mont_rsa_exponent_mod
and a
montgomery correction for data.attribute_length + 1
factors. Use data
.result
as
temporary for the result.
beta_1
^data
.v
using rsa_exponent
.power
and store the
result the temporary temp_2
. Then multiply temp_2
with the Montgomery correction for 2 factors and store
the result in temp_3
. Then multiply temp_3
with data
.result
and store the
result in temp_2
. Finally copy temp_2
into
data
.new_blinded_a
.
data
.gamma_beta_3
and store the result in
data
.result
. Then multiply
data
.result
with the
Montgomery correction for 4 factors and store the result in
temp_3
. Then compute the exponent data
.ptls_key
^data
.gamma_beta_3
and store the result in
temp_2
. Then multiply temp_2
and temp_3
and store the result in data
.result
. Then compute beta_2
^data
.v
and store the result in temp_3
. Then multiply temp_3
with data
.result
and store the result in
temp_2
. Finally multiply data
.host_alpha
with temp_2
and store
the result in data
.result
.
data
.new_blinded_a
into the hash by using hash
.update
with offset 2 (Montgomery digits)
and length data.new_blinded_a.size() - 2
. The necessary
byte array can be obtained with Bignat.get_digit_array
. Then finish the hash by feeding
data
.result
with offset 2 and
size() - 2
into MessageDigest doFinal
. Use
data
.new_signature
.hash_output_buf
with offset 0 as output array. Then finalize
the hash computation with data
.new_signature
.commit_hash
. Finally copy (Signature.hash_into_bignat
) the
hash value into double_small
.
data
.gamma_beta_3
to double_small
. Then divide (Bignat.remainder_divide
) double_small
by data
.v
, storing
the quotient in sig_quotient
. Finally copy double_small
into data
.sig_remainder
.
public void finish_signature(APDU_boolean accept)
data
.host_response
. After this
method the protocol layer sends the boolean result of this
method in RSA_card_protocol_description.signature_accepted
.
Sets the state of the applet to BLINDED
if it was INITIALIZED
(see applet state
description).
If the host response passes the acceptance check this method
computes the final signature and starts a transaction to switch
to the new attributes and the new signature. If all this goes
through the result value in accept
is set to true.
Otherwise it remains false when this method finishes.
The source code of this method is affected by Brand's patents on selective disclosure protocols that are now in the posession of Microsoft. Microsoft lawyers are still pondering our request from January 2009 for making the full source code publically available. The source code of this method is therefore currently not publically available.
accept
- reference to the accept result of this method,
equal to RSA_card_protocol_description.signature_accepted
,
will be true when returning from this method precisely if the
applet accepts the new signature and the transaction for
changing to the new attributes and the new signature succeeded.public void proof_commit()
data
.applet_id
to let the host distinguish
between the plain and the Montgomerizing applet,data
.current_blinded_a
,
data
.current_signature
, anddata
.result
Asserts that the applet is in the state BLINDED
(see applet state
description).
The source code of this method is affected by Brand's patents on selective disclosure protocols that are now in the posession of Microsoft. Microsoft lawyers are still pondering our request from January 2009 for making the full source code publically available. The source code of this method is therefore currently not publically available.
public void respond_to_challenge()
data
.gamma_beta_3
. After this method the protocol layer sends the
following data to the host:
data
.remainders
data
.result
The source code of this method is affected by Brand's patents on selective disclosure protocols that are now in the posession of Microsoft. Microsoft lawyers are still pondering our request from January 2009 for making the full source code publically available. The source code of this method is therefore currently not publically available.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |