ds.ov2.front
Class Host_signature

java.lang.Object
  extended by ds.ov2.util.Serializable_array
      extended by ds.ov2.front.Host_signature
All Implemented Interfaces:
APDU_Serializable

public class Host_signature
extends Serializable_array
implements APDU_Serializable

Host data type for Signature's with signature checking. Used to receive objects of type Signature from the card. This class further implements the validity check for signatures. This class does not implement sending a signature to the card, because signatures are established on the card in a completely differnt way.

For a general description of signatures, the validity check and the hash-size issue, see Signature.

This is a host data type. It is compatible with nothing. The card data type Signature is compatible with this class.

CPP Preprocessing
no cpp preprocessing needed
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.19 $
Last Commit:
$Date: 2009-06-19 20:37:36 $ by $Author: tews $

Field Summary
private  APDU_byte_array apdu_hash
          APDU container for the hash.
private  APDU_BigInteger apdu_number
          APDU container for the number.
private  MessageDigest digest
          SHA-1 hash instance.
(package private)  byte[] hash
          The hash part of the signature.
(package private)  BigInteger number
          The number part of the signature.
static PrintWriter out
          Debug channel.
private  APDU_Serializable[] serializable_contents
          Array of the two APDU containers in support for Serializable_array.
 
Constructor Summary
Host_signature(short short_bignat_size, short long_bignat_size, byte applet_id)
          Create a new host signature object.
 
Method Summary
 boolean check_signature_ex(BigInteger blinded_a, PTLS_rsa_parameters params, boolean montgomerized)
          Debug and exception wrapper for check_signature(java.math.BigInteger, ds.ov2.front.PTLS_rsa_parameters, boolean).
private  boolean check_signature(BigInteger blinded_a, PTLS_rsa_parameters params, boolean montgomerized)
          Signature check.
 short from_byte_array(short len, short this_index, byte[] byte_array, short byte_index)
          Deserialization of this object for the OV-chip protocol layer.
protected  APDU_Serializable[] get_array()
          Return serializable_contents in support for abstract Serializable_array.
(package private)  int get_hash_size()
          Return the size of the hash hash.
 short get_length()
          Return 2 as effective size in support for abstract Serializable_array.
(package private)  int get_number_size()
          Return the size of the number number.
 
Methods inherited from class ds.ov2.util.Serializable_array
is_compatible_with, size, to_byte_array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ds.ov2.util.APDU_Serializable
is_compatible_with, size, to_byte_array
 

Field Detail

hash

byte[] hash
The hash part of the signature. Initialized in from_byte_array.


number

BigInteger number
The number part of the signature. Initialized in from_byte_array.


apdu_hash

private APDU_byte_array apdu_hash
APDU container for the hash.


apdu_number

private APDU_BigInteger apdu_number
APDU container for the number.


serializable_contents

private APDU_Serializable[] serializable_contents
Array of the two APDU containers in support for Serializable_array.


digest

private MessageDigest digest
SHA-1 hash instance.


out

public static PrintWriter out
Debug channel. If non-null print debug information to this channel. Must be set from the outside.

Constructor Detail

Host_signature

public Host_signature(short short_bignat_size,
                      short long_bignat_size,
                      byte applet_id)
Create a new host signature object. Internal numbers and buffers depend on the exponent and base sizes as well as on the applet that we communicate with (see Hash_size).

Parameters:
short_bignat_size - size of the exponent bignats in bytes
long_bignat_size - size of the base bignats in bytes
applet_id - the applet ID
Throws:
RuntimeException - with a cause of type NoSuchAlgorithmException if the SHA-1 hash function cannot be found.
Method Detail

check_signature

private boolean check_signature(BigInteger blinded_a,
                                PTLS_rsa_parameters params,
                                boolean montgomerized)
Signature check. Check whether hash and number forms a valid signature for the blinded attribute expression blinded_a with respect to the PTLS parameters params.

If the argument montgomerized is true this method performs a check for a montgomerized signature, that is a signature where numbers must be montgomerized before they are fed into the hash function. Further, when montgomerized is true it is assumed that blinded_a is already montgomerized. In essence, for a signature from the Montgomerizing applet montgomerized should be true and otherwise false.

Restrictions of the hash size (see Signature and Hash_size) are taken into account as necessary. 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:

XXXXXXXXXXXXXXX

Parameters:
blinded_a - the blinded attribute expression that was signed; in montgomerized form if montgomerized is true
params - the PTLS parameters
montgomerized - true if the signature and blinded_a come from the montgomerizing applet
Returns:
true if the signature is valid, false otherwise

check_signature_ex

public boolean check_signature_ex(BigInteger blinded_a,
                                  PTLS_rsa_parameters params,
                                  boolean montgomerized)
Debug and exception wrapper for check_signature(java.math.BigInteger, ds.ov2.front.PTLS_rsa_parameters, boolean). Prints the arguments to out if that is non-null and prints information about escaping runtime exceptions to out or System.err. Does not catch any exception, only prints information and rethrows them.

Parameters:
blinded_a - the blinded attribute expression that was signed; in montgomerized form if montgomerized is true
params - the PTLS parameters
montgomerized - true if the signature and blinded_a come from the montgomerizing applet
Returns:
true if the signature is valid, false otherwise

get_hash_size

int get_hash_size()
Return the size of the hash hash. Needed for the compatibility check in Signature.is_compatible_with.

Returns:
the size of the hash in bytes

get_number_size

int get_number_size()
Return the size of the number number. Needed for the compatibility check in Signature.is_compatible_with.

Returns:
the size of number in bytes

get_array

protected APDU_Serializable[] get_array()
Return serializable_contents in support for abstract Serializable_array.

Specified by:
get_array in class Serializable_array
Returns:
array of objects to (de-)serialize

get_length

public short get_length()
Return 2 as effective size in support for abstract Serializable_array.

Overrides:
get_length in class Serializable_array
Returns:
2

from_byte_array

public short from_byte_array(short len,
                             short this_index,
                             byte[] byte_array,
                             short byte_index)
Deserialization of this object for the OV-chip protocol layer. See APDU_Serializable.from_byte_array.

Overridden here to initialize number from the APDU wrapper after deserialization finished.

Specified by:
from_byte_array in interface APDU_Serializable
Overrides:
from_byte_array in class Serializable_array
Parameters:
len - available data in byte_array
this_index - number of bytes that have already been read in preceeding calls
byte_array - data array to deserialize from
byte_index - index in byte_array
Returns:
the number of bytes actually read, except for the case where deserialization finished by reading precisely len bytes, in this case len + 1 is returned.