|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mpisws.p2p.transport.rc4.RC4TransportLayer<Identifier,MsgType>
Identifier
- MsgType
- public class RC4TransportLayer<Identifier,MsgType>
Only encrypts socket traffic!!! Encrypts channels based on a password. Builds a session password for each socket which is a hash of the user-defined password and a clear-text seed. Note that the seed length isn't sent in the protocol, so it must be the same on all peers. Why do we need a password seed? Imagine a protocol where you contact a peer and it returns a boolean. W/O a seed, the protocol would only return 2 possible messages. While you may not know which is which, you could probably figure it out by seeing who returns what. Both sides need to have a different seed, so that under a simple agreement protocol, you can't easily see a replay. E.G: A -> B: 14 // I propose 14 B -> A: 14 // I agree to 14, in this case an evesdropper could determine whether or not B agreed with A, which is a leak of info Here's the Seed protocol we use: // pw is a pre-established password A -> B: SeedB B -> E(H(pw,SeedB))[SeedA,SeedB] // Now A and B each have an agreed upon seed // Note that it may be important in step 2 to send SeedA before SeedB, otherwise, an attacker could keep sending new SeedB, // and maybe learn something about the first packet... but maybe this doesn't matter because of the Hashing to generate the secret key
Field Summary | |
---|---|
protected TransportLayerCallback<Identifier,MsgType> |
callback
|
protected Environment |
env
|
protected ErrorHandler<Identifier> |
errorHandler
|
static int |
KEY_LENGTH
|
protected Logger |
logger
|
protected java.security.MessageDigest |
md
|
protected TransportLayer<Identifier,MsgType> |
tl
Default 1 1 = encrypt 0 = don't encrypt Need to implemet this before we add it to the API |
Constructor Summary | |
---|---|
RC4TransportLayer(TransportLayer<Identifier,MsgType> tl,
Environment env,
java.lang.String password,
ErrorHandler<Identifier> errorHandler)
|
|
RC4TransportLayer(TransportLayer<Identifier,MsgType> tl,
Environment env,
java.lang.String password,
int pwSeedLength,
RandomSource random,
ErrorHandler<Identifier> errorHandler)
|
Method Summary | |
---|---|
void |
acceptMessages(boolean b)
Toggle accepting incoming messages. |
void |
acceptSockets(boolean b)
Toggle accepting new sockets. |
void |
destroy()
|
Identifier |
getLocalIdentifier()
The local node. |
void |
incomingSocket(P2PSocket<Identifier> s)
Notification of a new socket. |
void |
messageReceived(Identifier i,
MsgType m,
java.util.Map<java.lang.String,java.lang.Object> options)
Called when a new message is received. |
SocketRequestHandle<Identifier> |
openSocket(Identifier i,
SocketCallback<Identifier> deliverSocketToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Open a socket to the Identifier |
MessageRequestHandle<Identifier,MsgType> |
sendMessage(Identifier i,
MsgType m,
MessageCallback<Identifier,MsgType> deliverAckToMe,
java.util.Map<java.lang.String,java.lang.Object> options)
Send the message to the identifier |
void |
setCallback(TransportLayerCallback<Identifier,MsgType> callback)
Set the callback for incoming sockets/messages |
void |
setErrorHandler(ErrorHandler<Identifier> handler)
To be notified of problems not related to an outgoing messaage/socket. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected TransportLayer<Identifier,MsgType> tl
protected TransportLayerCallback<Identifier,MsgType> callback
protected Environment env
protected Logger logger
protected ErrorHandler<Identifier> errorHandler
protected java.security.MessageDigest md
public static final int KEY_LENGTH
Constructor Detail |
---|
public RC4TransportLayer(TransportLayer<Identifier,MsgType> tl, Environment env, java.lang.String password, ErrorHandler<Identifier> errorHandler) throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public RC4TransportLayer(TransportLayer<Identifier,MsgType> tl, Environment env, java.lang.String password, int pwSeedLength, RandomSource random, ErrorHandler<Identifier> errorHandler) throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
Method Detail |
---|
public void acceptMessages(boolean b)
TransportLayer
acceptMessages
in interface TransportLayer<Identifier,MsgType>
public void acceptSockets(boolean b)
TransportLayer
acceptSockets
in interface TransportLayer<Identifier,MsgType>
public Identifier getLocalIdentifier()
TransportLayer
getLocalIdentifier
in interface TransportLayer<Identifier,MsgType>
public SocketRequestHandle<Identifier> openSocket(Identifier i, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
openSocket
in interface TransportLayer<Identifier,MsgType>
i
- who to open the socket todeliverSocketToMe
- the callback when the socket is openedoptions
- options on how to open the socket (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
public void incomingSocket(P2PSocket<Identifier> s) throws java.io.IOException
TransportLayerCallback
incomingSocket
in interface TransportLayerCallback<Identifier,MsgType>
s
- the incoming socket
java.io.IOException
public MessageRequestHandle<Identifier,MsgType> sendMessage(Identifier i, MsgType m, MessageCallback<Identifier,MsgType> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
TransportLayer
sendMessage
in interface TransportLayer<Identifier,MsgType>
i
- the destinationm
- the messagedeliverAckToMe
- layer dependent notification when the message is sent (can indicate placed on the wire, point-to-point acknowledgment, or end-to-end acknowledgement)options
- delivery options (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
public void setCallback(TransportLayerCallback<Identifier,MsgType> callback)
TransportLayer
setCallback
in interface TransportLayer<Identifier,MsgType>
callback
- the callback for incoming sockets/messagespublic void setErrorHandler(ErrorHandler<Identifier> handler)
TransportLayer
setErrorHandler
in interface TransportLayer<Identifier,MsgType>
handler
- to be notified of problems not related to a specific messaage/socket.public void destroy()
destroy
in interface Destructable
public void messageReceived(Identifier i, MsgType m, java.util.Map<java.lang.String,java.lang.Object> options) throws java.io.IOException
TransportLayerCallback
messageReceived
in interface TransportLayerCallback<Identifier,MsgType>
i
- The node it is coming fromm
- the messageoptions
- describe how the message arrived (udp/tcp, encrypted etc)
java.io.IOException
- if there is a problem decoding the message
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |