ds.ov2.front
Class Host_testframe

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

public class Host_testframe
extends Object

Main class for the host test frame that combines the OV-chip applet and host driver code to be tested on a standard JVM. The host test frame is great for debugging the applet code, because here the applet runs on the PC and it can print any amount of debugging output. After debugging the same code can run on a real Java Card. With different preprocessor configurations this file provides the main class for three host test frames: The host test frame for the plain RSA applet, the host test frame for the Montgomerizing applet, and the host test frame for the squaring applet. They are started with the scripts plainhosttestframe, monthosttestframe, and squarehosttestframe, respectively.

In the host test frame the test stub code is substituted for the real stub code. Both are generated by the IDL compiler and have the same public interface. The real stub code calls Host_protocol.run_step to communicate to a Java Card or an emulator. Instead the test stub code calls the applet code directly, causing the applet and the host driver code to run together on the same JVM.

The three host test frames are very similar to the card test frame Card_testframe. Here we describe only the differences and give a complete list of the options.

Test save/restore PTLS parameters
This test frame provides an additional feature: Test the save/restore functionality for PTLS parameters. This test generates Test_state.ptls_param_rounds many PTLS parameter sets, writes them to disc and reads them back to see if there are any differences.
Applet choice
Whether to test the plain, the Montgomerizing, or the squaring RSA applet cannot be selected via options. Instead, there are three different applications, plainhosttestframe for the Plain RSA applet, monthosttestframe for the Montgomerizing RSA applet, and squarehosttestframe for the squaring RSA applet.
Unsupported Options
The following options are not supported: -jcop, -sun, -c, -r, -list-readers
The three host test frames accept the following options.
-test-size
Test loop with increasing key size
-test-const
Test a fixed key size.
-test-ptls-save
Test PTLS parameter save/restore. The number of rounds is determined by the number of ptls key generation rounds (see option -ptls-rounds).
-base-length n
Set key length to n bits, which will be identical to the base size. If the exponent length has not been set before automatically adapts the exponent length according to Lenstra's "Key length" estimations.
-exp-length n
Set the exponent length to n bits.
-attr n
Set number of attributes that the card receives during personalization.
-ptls-rounds n
Number of ptls key generation rounds.
-card-init-rounds n
Number of card init generation rounds.
-resign-rounds n
Number of resigning rounds.
-proof-rounds n
Number of proof rounds.
-768
Use the RSA 768 factorization of 2009 to calibrate the security parameter estimation
-ignore
Ignore all wrong certificates and proofs.
-i n
Provide decimal n as input for the test.
-hex n
Provide hexadecimal n as input for the test.
-h
Print usage information.
-d, -dd, -ddd
Print debug and progress messages, the more d's the more messages.
This class contains the special parts for the host test frame, especially the test for saving PTLS parameters. Many parts that are shared with the card test frame (Card_testframe) are contained in Testframe.

Static class.

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

Nested Class Summary
(package private) static class Host_testframe.Buffered_string_writer
          Character stream that collects the contents in a buffer in memory that can be retrieved later.
 
Field Summary
static Option[] host_test_frame_options
          Array with (only one) host test frame specific option.
static String long_application_name
          Long appliation name.
static String short_application_name
          Short application name for error messages.
 
Constructor Summary
protected Host_testframe()
          Static class, object creation disabled.
 
Method Summary
static void main(String[] args)
          Main method of the host test frames.
static void test_const_size()
          Simulate the applet life with several sets of PTLS parameters for the configures base and exponent sizes.
static void test_increase_size()
          Simulate the applet life with several sets of PTLS parameters for increasing base and exponent sizes.
static void test_ptls_save()
          Test writing/reading PTLS parameters to/from file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

short_application_name

public static final String short_application_name
Short application name for error messages.


long_application_name

public static final String long_application_name
Long appliation name.


host_test_frame_options

public static final Option[] host_test_frame_options
Array with (only one) host test frame specific option.

Constructor Detail

Host_testframe

protected Host_testframe()
Static class, object creation disabled.

Method Detail

test_const_size

public static void test_const_size()
                            throws NoSuchAlgorithmException,
                                   CardException,
                                   IOException
Simulate the applet life with several sets of PTLS parameters for the configures base and exponent sizes. 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.

Top level action, called when -test-const was specified.

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_increase_size

public static void test_increase_size()
                               throws NoSuchAlgorithmException,
                                      CardException,
                                      IOException
Simulate the applet life with several sets of PTLS parameters for increasing base and exponent sizes. 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.

Top level action, called when -test-size was specified.

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_ptls_save

public static void test_ptls_save()
                           throws NoSuchAlgorithmException,
                                  FileNotFoundException,
                                  PTLS_rsa_parameters.PTLS_io_exception
Test writing/reading PTLS parameters to/from file. Performs Test_state.ptls_param_rounds many tests to save a PTLS parameter set to the disk and read it back.

Top level action, called when -test-ptls-save was given.

Throws:
NoSuchAlgorithmException - if no provider for RSA key generation can be found
FileNotFoundException - if the file with the saved parameters disappeared
PTLS_rsa_parameters.PTLS_io_exception

main

public static void main(String[] args)
                 throws NoSuchAlgorithmException,
                        CardException,
                        FileNotFoundException,
                        PTLS_rsa_parameters.PTLS_io_exception,
                        IOException
Main method of the host test frames. Parses the command line and then invokes the specified tests.

Parameters:
args - command line
Throws:
IOException - if the applet cap file is not accessible or a read/write error occurs
NoSuchAlgorithmException - if no provider for RSA key generation can be found
FileNotFoundException - if the file with the saved parameters disappeared
CardException - for communication errors with the card
PTLS_rsa_parameters.PTLS_io_exception - for errors when writing/reading PTLS parameters