ostore.mac
Class HMACDHHandler
java.lang.Object
|
+--ostore.mac.MacHandler
|
+--ostore.mac.HMACDHHandler
- All Implemented Interfaces:
- EventHandlerIF, ProfilableIF
- public class HMACDHHandler
- extends MacHandler
MacHandler that uses HMAC for the message authentication and
Diffie-Hellman Key Generation.
Station-To-Station Protocol Implentation:
Basic Protocol:
There are four states: (1)UNINITIALIZED, (2)WAITFORRESPONSE, (3)WAITFORFINAL,
(4)ESTABLISHED.
There are three messages (across the network): (1)INITIALIZE, (2)RESPOND,
(3)FINALIZE.
There are three events (internal): (1)INIT (request to send out message 1),
(2) STS_TIMEOUT, (3)DH_TIMEOUT
State table
State |
Event | Next Stage
| Action |
UNINIT | Tapestry sends (1)INIT event |
WAITFORRESPONSE | Send message (1) |
UNINIT | Receive message (1) |
WAITFORFINAL | Compute secret, Send message (2) |
WAITFORRESPONSE | Receive message (2) |
ESTABLISHED | Confirm signature and Compute secret,
Send message (3) |
WAITFORRESPONSE | Receive message (1) |
WAITFORRESPONSE or WAITFORFINAL | If my guid is
greater that their guid, I become WAITFORFINAL, else ignore message.
|
WAITFORFINAL | Receive message (3) |
ESTABLISHED | Confirm signature |
establishedParties & pendingParties:
Needed: To be able to go through a false or faulty handshake,
one that is cancelled before completion, and not lose the existing
connection.
Solution: Keep two Hashtables (indexed by guid) one for established
connections (establishedParties) and another for in-progress
connections (pendingParties). If a pendingParties
connection successfully finishes a handshake, that entry replaces the
one in establishedParties.
Functional access to this MacHandler only accesses
establishedParties
Timeouts:
The HMACDHHandler handles timeouts (both session and Diffie-Hellman key
expirations) by sending itself delayed messages. The time (in milliseconds)
of these are determined by config variables: timeoutlength and
dhlifespan
TODO describe sts timeout and dh timeout
Synchronicity:
Internally: establishedPartiesI
This stage is not designed to be replicated. Replication may introduce
race conditions that have not been thoroughly investigated.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
tag
public static final String tag
DEBUG
public static final boolean DEBUG
ANNOUNCE
public static final boolean ANNOUNCE
HMACDHHandler
public HMACDHHandler()
handleEvent
public void handleEvent(QueueElementIF item)
throws EventHandlerException
- Overrides:
handleEvent
in class MacHandler
handleEvents
public void handleEvents(QueueElementIF[] item)
throws EventHandlerException
- Overrides:
handleEvents
in class MacHandler
init
public void init(ConfigDataIF config)
throws Exception
- Overrides:
init
in class MacHandler
getInstance
public static HMACDHHandler getInstance()
- Return the HMACDHHandler used by this machine.
Envisioned usage: Pass the string HMAC
establish
public void establish(SecureHash guid)
- Establish a connection between the guid and this instance of sandstorm
Once a connection is established, the MacHandler will broadcast
a MacHandler.KeyEstablished
announcement.
- Overrides:
establish
in class MacHandler
authenticate
public boolean authenticate(QuickSerializable user_data,
QSByteArray incoming_mac,
SecureHash guid)
throws MacHandler.GuidNotEstablished
- Note: a failure may mean that a message was sent right before
the sender decided to change keys that that message arrived
after a new key was established (though this is unlikely) it
is a possibility that needs to be accounted for.
- Overrides:
authenticate
in class MacHandler
- Returns:
true
iff this message is authentic, i.e.
verified by the internal MAC
doMAC
public QSByteArray doMAC(QuickSerializable user_data,
SecureHash guid)
throws MacHandler.GuidNotEstablished
- Computes the MAC code for the this message
- Overrides:
doMAC
in class MacHandler
- Returns:
true
iff the MAC was computed successfully.
idString
public String idString()
- Description copied from class:
MacHandler
- Id String
- Overrides:
idString
in class MacHandler
myGuid
public SecureHash myGuid()
- Description copied from class:
MacHandler
- My GUID
- Overrides:
myGuid
in class MacHandler
destroy
public void destroy()
throws Exception
- Overrides:
destroy
in class MacHandler
profileSize
public int profileSize()
- Overrides:
profileSize
in class MacHandler