ds.ov2.gui
Class Card_protocols

java.lang.Object
  extended by ds.ov2.gui.Card_protocols

public class Card_protocols
extends Object

Basic card/applet actions of the graphical demonstrator. This includes running the protocols but also applet installation, deletion and querying the card status. Additionally, this class contains actions for managing PTLS parameter sets.

CPP Preprocessing
no cpp preprocessing needed
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.20 $
Last Commit:
$Date: 2009-06-18 11:57:39 $ by $Author: tews $

Field Summary
(package private)  RSA_card_debug debug_card
          RSA debug protocol instance.
(package private)  RSA_host_card host_card
          RSA host protocols instance.
private  PTLS_rsa_parameters ptls_parameters
          PTLS parameter instance.
 
Constructor Summary
Card_protocols()
          Constructor.
 
Method Summary
 void clear_parameters()
          Clear the current set of PTLS parameters.
 void delete_applets(Printable_aid[] aids, Gui_protocol_messages messages)
          Delete applets and/or packages from the card.
 boolean entry_gate_check(Applet_type applet_type, Gui_protocol_messages messages)
          Run the entry-gate proof protocol.
 void generate_ptls_parameters(int attribute_number, int key_size, int exp_size, Applet_type applet_type)
          Generate a new set of PTLS parameters.
 int get_attribute_number()
          Return the number of attributes.
 BigInteger[] get_bases()
          Return the array of bases.
private  CardChannel get_card_channel()
          Open the default channel to the card in the configured card reader.
 cardservices.AIDRegistry get_card_status()
          Get the registry of all installed applets/packages from the card.
private  cardservices.GlobalPlatformService get_gps(CardChannel channel)
          Open a connection to the global platform manager on the card.
 BigInteger get_max_base()
          Return the maximal possible base value.
private  void install_applet_with_gps(cardservices.GlobalPlatformService gps, Applet_type applet_type, Gui_protocol_messages messages)
          Install one of the OV-Chip applets on a card.
 void install_applet(Applet_type applet_type, Gui_protocol_messages messages)
          Install one of the OV-chip applets.
 boolean issue(CardChannel channel, Gui_protocol_messages messages, Applet_type applet_type)
          Run the applet initialization protocol.
 void personalize(Applet_type applet_type, Gui_protocol_messages messages)
          Personalize the applet.
 int[] read_ptls_parameters(String file_name, Applet_type applet_type)
          Read PTLS parameters from file
 void reinstall_personalize(Applet_type applet_type, Gui_protocol_messages messages)
          Reinstall and personalize applet.
 void reset_applet(Applet_type applet_type)
          Reset the applet.
 boolean resign_with_update(Applet_type applet_type, BigInteger[] updates_bi, Gui_protocol_messages messages)
          Run the resign protocol with the specified attribute updates.
 void save_ptls_parameters(String file_name)
          Save the current PTLS parameters to file.
 void update_bases(BigInteger[] new_bases)
          Update the bases in the PTLS parameters.
 boolean valid_parameters()
          Check whether we have a set of PTLS parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ptls_parameters

private PTLS_rsa_parameters ptls_parameters
PTLS parameter instance. This instance contains the parameters that are used in the GUI demonstrator.


host_card

RSA_host_card host_card
RSA host protocols instance.


debug_card

RSA_card_debug debug_card
RSA debug protocol instance.

Constructor Detail

Card_protocols

public Card_protocols()
Constructor. Creates and initializes the necessary objects on the host side for talking to the OV-chip applets through the protocol layer.

Method Detail

valid_parameters

public boolean valid_parameters()
Check whether we have a set of PTLS parameters.

Returns:
true if parameters have been configured

clear_parameters

public void clear_parameters()
Clear the current set of PTLS parameters.


generate_ptls_parameters

public void generate_ptls_parameters(int attribute_number,
                                     int key_size,
                                     int exp_size,
                                     Applet_type applet_type)
                              throws NoSuchAlgorithmException
Generate a new set of PTLS parameters.

Parameters:
attribute_number - number of bases and attributes to use
key_size - RSA key size in bits
exp_size - exponent size in bits
applet_type - the applet type (needed somewhere for the number of Montgomery digits)
Throws:
NoSuchAlgorithmException

save_ptls_parameters

public void save_ptls_parameters(String file_name)
                          throws PTLS_rsa_parameters.PTLS_io_exception
Save the current PTLS parameters to file.

Parameters:
file_name - file to use
Throws:
PTLS_rsa_parameters.PTLS_io_exception - on I/O errors

read_ptls_parameters

public int[] read_ptls_parameters(String file_name,
                                  Applet_type applet_type)
                           throws PTLS_rsa_parameters.PTLS_io_exception
Read PTLS parameters from file

Parameters:
file_name - the file name to read
applet_type - the applet type for which the protocol layer should be initialized
Returns:
array with three entries: the number of attributes/bases, the RSA key size in bits, the exponent size in bits
Throws:
PTLS_rsa_parameters.PTLS_io_exception - on I/O errors

get_max_base

public BigInteger get_max_base()
Return the maximal possible base value.

Returns:
the maximal possible base value

get_attribute_number

public int get_attribute_number()
Return the number of attributes.

Returns:
the number of attributes in the current PTLS parameters
Throws:
NullPointerException - if there are no valid parameters

get_bases

public BigInteger[] get_bases()
Return the array of bases.

Returns:
array of bases

update_bases

public void update_bases(BigInteger[] new_bases)
Update the bases in the PTLS parameters.

Parameters:
new_bases - the new bases to use from now on

get_card_channel

private CardChannel get_card_channel()
                              throws CardException
Open the default channel to the card in the configured card reader.

Must be executed on the Terminal thread.

Returns:
a card channel
Throws:
CardException - on communication problems with the card

get_gps

private cardservices.GlobalPlatformService get_gps(CardChannel channel)
                                            throws CardException
Open a connection to the global platform manager on the card.

Must be executed on the Terminal thread.

Parameters:
channel - channel to the card
Returns:
the global platform service instance
Throws:
CardException - for communication problems and global platform errors

get_card_status

public cardservices.AIDRegistry get_card_status()
                                         throws CardException
Get the registry of all installed applets/packages from the card.

Throws:
CardException - on communication errors

install_applet_with_gps

private void install_applet_with_gps(cardservices.GlobalPlatformService gps,
                                     Applet_type applet_type,
                                     Gui_protocol_messages messages)
                              throws cardservices.GlobalPlatformInstallForLoadException,
                                     cardservices.GlobalPlatformLoadException,
                                     CardException,
                                     IOException
Install one of the OV-Chip applets on a card. Use an existing global platform service instance, which has a channel to the card.

Must be executed on the Terminal thread.

Parameters:
gps - global platform service instance
applet_type - denotes the applet to install
messages - progress message instance
Throws:
cardservices.GlobalPlatformInstallForLoadException - if the install-for-load command fails
cardservices.GlobalPlatformLoadException - if cap file loading fails
CardException - for low-level communication errors
IOException - if the cap file cannot be opened

install_applet

public void install_applet(Applet_type applet_type,
                           Gui_protocol_messages messages)
                    throws cardservices.GlobalPlatformInstallForLoadException,
                           cardservices.GlobalPlatformLoadException,
                           CardException,
                           IOException
Install one of the OV-chip applets. The connection to the card and the global platform service instance is locally created and destroyed.

Parameters:
applet_type - the applet to install
messages - progress message instance
Throws:
cardservices.GlobalPlatformInstallForLoadException - if the install-for-load command fails
cardservices.GlobalPlatformLoadException - if cap file loading fails
CardException - for low-level communication errors
IOException - if the cap file cannot be opened

delete_applets

public void delete_applets(Printable_aid[] aids,
                           Gui_protocol_messages messages)
                    throws CardException
Delete applets and/or packages from the card.

Parameters:
aids - the ID's to delete
messages - progress message instance
Throws:
CardException - on communication errors

reset_applet

public void reset_applet(Applet_type applet_type)
                  throws CardException
Reset the applet.

Parameters:
applet_type - the applet to reset
Throws:
CardException - on communication errors

personalize

public void personalize(Applet_type applet_type,
                        Gui_protocol_messages messages)
                 throws CardException
Personalize the applet. Download key material, attributes and do a initial resign. The channel to the card is locally created and destroyed.

Parameters:
applet_type - the applet to personalize
messages - progress message instance
Throws:
CardException - on communication errors

reinstall_personalize

public void reinstall_personalize(Applet_type applet_type,
                                  Gui_protocol_messages messages)
                           throws cardservices.GlobalPlatformInstallForLoadException,
                                  cardservices.GlobalPlatformLoadException,
                                  CardException,
                                  IOException
Reinstall and personalize applet. The channel and the global platform manager instance is locally created and destroyed.

Parameters:
applet_type - the applet to reinstall
messages - progress message instance
Throws:
cardservices.GlobalPlatformInstallForLoadException - if the install-for-load command fails
cardservices.GlobalPlatformLoadException - if cap file loading fails
CardException - for low-level communication errors
IOException - if the cap file cannot be opened

issue

public boolean issue(CardChannel channel,
                     Gui_protocol_messages messages,
                     Applet_type applet_type)
              throws CardException
Run the applet initialization protocol.

Parameters:
channel - channel to the card
messages - progress message instance
applet_type - the applet to initialize
Returns:
true if the final resign step was successful
Throws:
CardException - on communication errors

resign_with_update

public boolean resign_with_update(Applet_type applet_type,
                                  BigInteger[] updates_bi,
                                  Gui_protocol_messages messages)
                           throws CardException
Run the resign protocol with the specified attribute updates. If the updates_bi parameter is null random attribute updates are invented via RSA_card_debug.invent_attribute_updates.

Parameters:
applet_type - the applet to select for resigning
updates_bi - pass null for random attribute updates, otherwise pass an array with with ptls_parameters.attribute_number attribute updates in the range of -ptls_parameters.v + 1 .. ptls_parameters.v -1
messages - progress message object
Returns:
true if resign succeeds
Throws:
CardException - on communication errors

entry_gate_check

public boolean entry_gate_check(Applet_type applet_type,
                                Gui_protocol_messages messages)
                         throws CardException
Run the entry-gate proof protocol.

Parameters:
applet_type - applet to select for proving
messages - progress message instance
Returns:
true if the proof was successful
Throws:
CardException - on communication errors