ds.ov2.front
Class RSA_card_debug

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

public class RSA_card_debug
extends Object

Host driver code for the debug protocols of the RSA applets. The debug protocols should not be available in a real system, because they extract all attribute values from the applet. However, for the current version of the test frame and the graphical demonstrator the debug protocols are necessary, because for the random attribute updates the host driver needs to know the real attribute values.

CPP Preprocessing
This class uses the following cpp defines: RSA_DEBUG_PROTOCOL_STUBS
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.24 $
Last Commit:
$Date: 2009-06-18 11:57:38 $ by $Author: tews $

Field Summary
private  Front_protocols front_protocols
          Registered protocols instance.
private  PrintWriter out
          Output channel for debug messages.
private  Random rand
          Randomness source.
 RSA_card_debug_stubs stubs
          Stubs instance for the protocol steps.
private  int verbosity
          Verbosity level.
 
Constructor Summary
RSA_card_debug(Front_protocols front_protocols, RSA_card_debug_stubs stubs, PrintWriter out, int verbosity)
          Constructor.
 
Method Summary
 RSA_card_debug_stubs.Get_result get_and_print_status(PrintWriter out, int level, CardChannel card_channel)
          Run the status protocol to retrieve and print the applet status.
 RSA_card_debug_stubs.Get_result get_status(CardChannel card_channel)
          Run the status protocol to retrieve the applet status.
 void host_side_init()
          Host side initialization for delayed protocols.
 BigInteger[] invent_attribute_updates(PTLS_rsa_parameters params, CardChannel card_channel)
          Invent random attribute updates.
 void print_applet_memory(PrintWriter out, CardChannel card_channel)
          Run the mem_size protocol to retrieve and print the available memory and whether assertions are compiled in the applet.
 void print_card_status(PrintWriter out, RSA_card_debug_stubs.Get_result s)
          Print the status from the status protocol.
 void reset_applet(CardChannel card_channel)
          Run the reset-applet-state protocol to reset the applet into state RSA_data.UNALLOCTED.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

front_protocols

private final Front_protocols front_protocols
Registered protocols instance.


stubs

public final RSA_card_debug_stubs stubs
Stubs instance for the protocol steps. Declared to be of type RSA_DEBUG_PROTOCOL_STUBS.


rand

private final Random rand
Randomness source.


out

private final PrintWriter out
Output channel for debug messages.


verbosity

private final int verbosity
Verbosity level.

Constructor Detail

RSA_card_debug

public RSA_card_debug(Front_protocols front_protocols,
                      RSA_card_debug_stubs stubs,
                      PrintWriter out,
                      int verbosity)
Constructor. Initialize all fields.

Parameters:
front_protocols - protocol array
stubs - of type RSA_DEBUG_PROTOCOL_STUBS, stubs for protocol steps
out - output channel
verbosity - verbosity level
Method Detail

host_side_init

public void host_side_init()
Host side initialization for delayed protocols.

Asserts that the host side initialization for the delayed protocols of front_protocols has been done before calling this method.


print_card_status

public void print_card_status(PrintWriter out,
                              RSA_card_debug_stubs.Get_result s)
Print the status from the status protocol.

Parameters:
out - output channel
s - result record from the status protocol

get_status

public RSA_card_debug_stubs.Get_result get_status(CardChannel card_channel)
                                           throws CardException
Run the status protocol to retrieve the applet status.

Parameters:
card_channel - channel to the applet
Returns:
result record of the status protocol
Throws:
CardChannel - on communication errors
CardException

get_and_print_status

public RSA_card_debug_stubs.Get_result get_and_print_status(PrintWriter out,
                                                            int level,
                                                            CardChannel card_channel)
                                                     throws CardException
Run the status protocol to retrieve and print the applet status. Convenience method combining get_status and print_card_status.

Parameters:
out - output channel, maybe null to supress output
level - required verbosity level; only print status if level is greater or equal the configured verbosity.
Returns:
result record of the status protocol
Throws:
CardException - for communication errors

print_applet_memory

public void print_applet_memory(PrintWriter out,
                                CardChannel card_channel)
                         throws CardException
Run the mem_size protocol to retrieve and print the available memory and whether assertions are compiled in the applet.

Parameters:
out - output channel
card_channel - channel to the applet
Throws:
CardException - on communication errors

reset_applet

public void reset_applet(CardChannel card_channel)
                  throws CardException
Run the reset-applet-state protocol to reset the applet into state RSA_data.UNALLOCTED. Do also reset the mirroring host data structures.

Parameters:
card_channel - channel to the applet
Throws:
CardException - on communication errors

invent_attribute_updates

public BigInteger[] invent_attribute_updates(PTLS_rsa_parameters params,
                                             CardChannel card_channel)
                                      throws CardException
Invent random attribute updates. The resign protocol fails when one of the attribute updates produces an under- or overflow. Therefore this method queries the card status in order to retrieve the current attribute values of the applet before determining the random updates.

The random updates excercise border conditions as follows. With a probability of 5% the update is chosen such that the attribute gets the maximal possible attribute value. Also with 5% the attribute get value 0. With both 40% a random value is added or subtracted without producing an overflow.

Parameters:
params - current PTLS parameter set
card_channel - channel to the applet
Returns:
array with params.attribute_number updates in the range -params.v + 1 .. params.v -1, inclusive
Throws:
CardException - on communication errors