ds.ov2.front
Class Testframe

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

public class Testframe
extends Object

Common part of the host test frame and the card test frame. The host test frame is that test frame that runs one applet and the host driver together on the standard Java Virtual Machine for easy applet debugging. The card test frame runs the host driver to talk to a real applet on a real card or emulator.

This class contains the options that are shared between all the test frames and the shared methods that realize the test loops.

Static class.

CPP Preprocessing
This class uses the following cpp defines: RSA_CARD_PROTOCOL_STUBS, RSA_DEBUG_PROTOCOL_STUBS
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.41 $
Last Commit:
$Date: 2010-03-12 15:40:20 $ by $Author: tews $

Field Summary
private static RSA_card_debug debug_card
          Stubs instance for the debug protocols.
private static RSA_host_card host_card
          Host driver instance for the regular protocols.
static Option[] shared_options
          Option array with the shared options.
private static Reference<Boolean> use_applet_reset
          If true reset the applet before a new personalization instead of resinstalling it.
 
Constructor Summary
protected Testframe()
          Static class, object creation disabled.
 
Method Summary
static void initialize_stubs(PrintWriter out)
          (Re-)Initialize the host drivers for the regular and debug protocols host_card and debug_card.
static void install_applet_and_select(CardChannel card_channel, PrintWriter out)
          (Re-)Install the applet and select it.
static void parse_commandline(String[] args, Option[] additional_options, String short_application_name)
          Parse the command line for the host and the card test frames.
static void test_init_resign_proof(CardChannel card_channel, PrintWriter out, int attribute_number, int base_length, int exponent_length)
          Simulates the applet life for several sets of PTLS parameters for one base and exponent length.
static void test_one_card_issue_ex(CardChannel card_channel, PrintWriter out, PrintWriter err, PTLS_rsa_parameters ptls_params)
          Simulate the life of an OV-chip applet.
static void test_one_card_issue(CardChannel card_channel, PrintWriter out, PTLS_rsa_parameters ptls_params)
          Exception wrapper for test_one_card_issue_ex.
static void test_one_ptls_round(CardChannel card_channel, PrintWriter out, int attribute_number, int base_length, int exponent_length)
          Simulates the life of several applets for one newly generated set of PTLS parameters.
static void test_size_loop(CardChannel card_channel, PrintWriter out, int attribute_number, int start_size)
          Runs the applet life simulation for all base sizes from start_size up to 2048.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host_card

private static RSA_host_card host_card
Host driver instance for the regular protocols. The host driver instances (together with debug_card) are the only necessary thing to run the protocols. But behind them a little object hierarchy is hiding: the stubs RSA_card_protocol_stubs or RSA_card_protocol_test_stubs and RSA_card_debug_stubs or RSA_card_debug_test_stubs, the protocols array Front_protocols, the protocol descriptions RSA_card_protocol_description and RSA_card_debug_description, and the service instance for registered protocols Registered_protocols. In the host test frames the complete applet code hides behind this stubs instance.

The stubs are initialized in initialize_stubs(java.io.PrintWriter). This should be done whenever the applet is installed.


debug_card

private static RSA_card_debug debug_card
Stubs instance for the debug protocols. See host_card for more information.


use_applet_reset

private static Reference<Boolean> use_applet_reset
If true reset the applet before a new personalization instead of resinstalling it.


shared_options

public static final Option[] shared_options
Option array with the shared options.

Constructor Detail

Testframe

protected Testframe()
Static class, object creation disabled.

Method Detail

parse_commandline

public static void parse_commandline(String[] args,
                                     Option[] additional_options,
                                     String short_application_name)
Parse the command line for the host and the card test frames. The specific options of the host or card test frame and the application name to use are passed into this method. Calls State.update_exponent_length() at the end in case the base or exponent length has been changed via options.

Parameters:
args - command line as received in main
additional_options - additional options to prepend to the shared options
short_application_name - name to print in case of a command line parsing error

install_applet_and_select

public static void install_applet_and_select(CardChannel card_channel,
                                             PrintWriter out)
                                      throws CardException,
                                             IOException
(Re-)Install the applet and select it.

Parameters:
card_channel - channel to the card
out - debug and progress channel
Throws:
CardException - on communication errors
IOException - if the applet cap file is not accessible

initialize_stubs

public static void initialize_stubs(PrintWriter out)
(Re-)Initialize the host drivers for the regular and debug protocols host_card and debug_card. Together with these host drivers the whole protocol layer that hides behind them is (re-)initialized. In the host test frames even the complete applets are reinitialized.

Therefore this is somewhat the host-side counterpart for applet installation. When the applet is (re-)installed, this method should be called to (re-)install the appropriate host data structures.

Parameters:
out - output channel for debug and progress messages

test_one_card_issue_ex

public static void test_one_card_issue_ex(CardChannel card_channel,
                                          PrintWriter out,
                                          PrintWriter err,
                                          PTLS_rsa_parameters ptls_params)
                                   throws CardException,
                                          IOException
Simulate the life of an OV-chip applet. Install the applet and the host driver instances for it or resets the applet. Personalize the applet then (download PTLS parameters and attributes) and run the resign and gate (proof) protocol a few times. The number of resign and gate rounds is determined by some global variables that can be changed via command line options, see Card_testframe.

In the card test frame the applet to install can be chosen via options, see Card_testframe. In the host test frame the applet type is fixed.

This method uses the card_channel argument to determine whether it runs inside a host test frame. Applet deletion and installation is only done if card_channel is nonnull.

Parameters:
card_channel - channel to the card or null for a host test frame
out - output channel for debug and progress messages
err - output channel for serious problems
ptls_params - PTLS parameters instance
Throws:
CardException - on communication errors
IOException - if the applet cap file is not accessible

test_one_card_issue

public static void test_one_card_issue(CardChannel card_channel,
                                       PrintWriter out,
                                       PTLS_rsa_parameters ptls_params)
                                throws CardException,
                                       IOException
Exception wrapper for test_one_card_issue_ex. Simulates the life of an OV-chip applet and catches the exception that is raised when the card guesses one of the secret factors of the RSA modulus when generating a new random blinding. This can actually be easily observed for RSA key sizes below 16 bits. If the card guesses one of the factors some response is not invertible any more and BigInteger.modInverse(java.math.BigInteger) throws and ArithmeticException.

All other exceptions are not touched.

Parameters:
card_channel - channel to the card or null for a host test frame
out - output channel for debug and progress messages
ptls_params - PTLS parameters instance
Throws:
CardException - on communication errors
IOException - if the applet cap file is not accessible

test_one_ptls_round

public static void test_one_ptls_round(CardChannel card_channel,
                                       PrintWriter out,
                                       int attribute_number,
                                       int base_length,
                                       int exponent_length)
                                throws NoSuchAlgorithmException,
                                       CardException,
                                       IOException
Simulates the life of several applets for one newly generated set of PTLS parameters. The number of applets and the number of proof/resign rounds to run on each of them is determined by some global variables that can be changed via command line options, see Card_testframe.

Parameters:
card_channel - channal to the card or null for the host test frame
out - output channel for progress and debug messages
attribute_number - number of attributes to use
base_length - length of the RSA key and the bases
exponent_length - length of the attributes and the public RSA exponent
Throws:
CardException - on communication errors
IOException - if the applet cap file is not accessible
NoSuchAlgorithmException - if no provider for RSA key generation can be found

test_init_resign_proof

public static void test_init_resign_proof(CardChannel card_channel,
                                          PrintWriter out,
                                          int attribute_number,
                                          int base_length,
                                          int exponent_length)
                                   throws NoSuchAlgorithmException,
                                          CardException,
                                          IOException
Simulates the applet life for several sets of PTLS parameters for one base and exponent length. The numbers of what is simulated how often is determined by some global variables that can be changed via the command line, see Card_testframe.

Parameters:
card_channel - channal to the card or null for the host test frame
out - output channel for progress and debug messages
attribute_number - number of attributes to use
base_length - length of the RSA key and the bases
exponent_length - length of the attributes and the public RSA exponent
Throws:
CardException - on communication errors
IOException - if the applet cap file is not accessible
NoSuchAlgorithmException - if no provider for RSA key generation can be found

test_size_loop

public static void test_size_loop(CardChannel card_channel,
                                  PrintWriter out,
                                  int attribute_number,
                                  int start_size)
                           throws NoSuchAlgorithmException,
                                  CardException,
                                  IOException
Runs the applet life simulation for all base sizes from start_size up to 2048.

Parameters:
card_channel - channal to the card or null for the host test frame
out - output channel for progress and debug messages
attribute_number - number of attributes to use
start_size - base start size in bits
Throws:
CardException - on communication errors
IOException - if the applet cap file is not accessible
NoSuchAlgorithmException - if no provider for RSA key generation can be found