org.eu.mayrhofer.authentication.relate
Class DongleProtocolHandler

java.lang.Object
  extended by org.eu.mayrhofer.authentication.AuthenticationEventSender
      extended by org.eu.mayrhofer.authentication.relate.DongleProtocolHandler

public class DongleProtocolHandler
extends AuthenticationEventSender

This class implements the host part of the authentication protocol between two Relate dongles. It will prepare the data to initialize the dongle authentication mode (i.e. encrypt the shared secret with a block cipher) and check that the nonce received via the ultrasound delays matches (at least as far as the number of bits being used) the received encrypted nonce. Since the authentication protocol will also run as a background thread, this class will emit AuthenticationEvents.

Version:
1.0
Author:
Rene Mayrhofer

Field Summary
static int AuthenticationStages
          The number of authentication steps, not including the rounds of the dongles.
 
Fields inherited from class org.eu.mayrhofer.authentication.AuthenticationEventSender
eventsHandlers
 
Constructor Summary
DongleProtocolHandler(java.lang.String serialPort, int remoteRelateId, boolean useJSSE)
          Initializes the dongle protocol handler by setting the serialPort and remoteRelateId members.
 
Method Summary
static boolean compareBits(byte[] s, byte[] t, int numBits)
          Compares a number of bits starting at LSB.
 int getDongleInterlockTime()
          Returns the time it took to complete the dongle interlock protocol, i.e.
 int getRemoteRelateId()
          Returns the ID of the remote relate dongle with which this authentication protocol is run.
 int getSendCommandTime()
          Returns the time that it took to send the start-of-authentication command to the dongle
static int hammingDistance(byte[] s, byte[] t, int numBits)
          Computes the hamming distance between two bit strings, starting from the LSB.
 void startAuthentication(byte[] sharedKey, int rounds, int referenceMeasurement)
          This method performs a full authentication of the pre-established shared secrets with another Relate dongle.The authentication is started as a background thread.
 
Methods inherited from class org.eu.mayrhofer.authentication.AuthenticationEventSender
addAuthenticationProgressHandler, raiseAuthenticationFailureEvent, raiseAuthenticationProgressEvent, raiseAuthenticationSuccessEvent, removeAuthenticationProgressHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AuthenticationStages

public static final int AuthenticationStages
The number of authentication steps, not including the rounds of the dongles.

See Also:
Constant Field Values
Constructor Detail

DongleProtocolHandler

public DongleProtocolHandler(java.lang.String serialPort,
                             int remoteRelateId,
                             boolean useJSSE)
Initializes the dongle protocol handler by setting the serialPort and remoteRelateId members.

Parameters:
remoteRelateId - The remote relate id to perform the authentication with.
serialPort - The serial port to which the dongle is connected.
useJSSE - If set to true, the JSSE API with the default JCE provider of the JVM will be used for cryptographic operations. If set to false, an internal copy of the Bouncycastle Lightweight API classes will be used.
Method Detail

compareBits

public static boolean compareBits(byte[] s,
                                  byte[] t,
                                  int numBits)
Compares a number of bits starting at LSB. This method is only public for the JUnit tests, there's probably not much use for it elsewhere.

Parameters:
s - The first bit string.
t - The second bit string.
numBits - The number of bits to compare (starting at LSB).
Returns:
true if all numBits are equal, false otherwise.

hammingDistance

public static int hammingDistance(byte[] s,
                                  byte[] t,
                                  int numBits)
Computes the hamming distance between two bit strings, starting from the LSB. This method is only public for the JUnit tests, there's probably not much use for it elsewhere.

Parameters:
s - The first bit string.
t - The second bit string.
numBits - The number of bits to compare (starting at LSB).
Returns:
The hamming distance between the strings s and t (for numBits), i.e. the number of different bits.

startAuthentication

public void startAuthentication(byte[] sharedKey,
                                int rounds,
                                int referenceMeasurement)
This method performs a full authentication of the pre-established shared secrets with another Relate dongle.The authentication is started as a background thread.

Parameters:
sharedKey - The secret authentication key shared with the remote host.
rounds - The number of rounds to use. Due to the protocol and hardware limitations, the security of this authentication is given by rounds * EnropyBitsPerRound.
referenceMeasurement - The reference measurement to the remote relate dongle. It is assumed that the real distance between the dongles will not change during the authentication.

getSendCommandTime

public int getSendCommandTime()
Returns the time that it took to send the start-of-authentication command to the dongle

Returns:
Time for sending the command in ms.

getDongleInterlockTime

public int getDongleInterlockTime()
Returns the time it took to complete the dongle interlock protocol, i.e. the time between successfully sending the start-of-authentication command to the dongle and the receipt of the last round message.

Returns:
Time for the dongle interlock protocol in ms.

getRemoteRelateId

public int getRemoteRelateId()
Returns the ID of the remote relate dongle with which this authentication protocol is run.

Returns:
The remote relate ID used as the authentication peer.


2005-2006, Rene Mayrhofer.