net.i2p.router.networkdb.kademlia
Class MessageWrapper

java.lang.Object
  extended by net.i2p.router.networkdb.kademlia.MessageWrapper

public class MessageWrapper
extends Object

Method and class for garlic encrypting outbound netdb traffic, and sending keys and tags for others to encrypt inbound netdb traffic, including management of the ElGamal/AES tags.

Since:
0.7.10

Nested Class Summary
static class MessageWrapper.OneTimeSession
          A single key and tag, for receiving a single message.
(package private) static class MessageWrapper.WrappedMessage
          Wrapper so that we can keep track of the key and tags for later notification to the SKM
 
Constructor Summary
MessageWrapper()
           
 
Method Summary
static MessageWrapper.OneTimeSession generateSession(RouterContext ctx)
          Create a single key and tag, for receiving a single encrypted message, and register it with the router's session key manager, to expire in two minutes.
static MessageWrapper.OneTimeSession generateSession(RouterContext ctx, Hash localDest)
          Create a single key and tag, for receiving a single encrypted message, and register it with the client's session key manager, to expire in two minutes.
static MessageWrapper.OneTimeSession generateSession(RouterContext ctx, SessionKeyManager skm)
          Create a single key and tag, for receiving a single encrypted message, and register it with the given session key manager, to expire in two minutes.
(package private) static MessageWrapper.WrappedMessage wrap(RouterContext ctx, I2NPMessage m, Hash from, RouterInfo to)
          Garlic wrap a message from a client or this router, destined for a router, to hide the contents from the OBEP.
static GarlicMessage wrap(RouterContext ctx, I2NPMessage m, MessageWrapper.OneTimeSession session)
          Garlic wrap a message from nobody, destined for an unknown router, to hide the contents from the IBGW.
(package private) static GarlicMessage wrap(RouterContext ctx, I2NPMessage m, RouterInfo to)
          Garlic wrap a message from nobody, destined for a router, to hide the contents from the OBEP.
static GarlicMessage wrap(RouterContext ctx, I2NPMessage m, SessionKey encryptKey, SessionTag encryptTag)
          Garlic wrap a message from nobody, destined for an unknown router, to hide the contents from the IBGW.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageWrapper

public MessageWrapper()
Method Detail

wrap

static MessageWrapper.WrappedMessage wrap(RouterContext ctx,
                                          I2NPMessage m,
                                          Hash from,
                                          RouterInfo to)
Garlic wrap a message from a client or this router, destined for a router, to hide the contents from the OBEP. Caller must call acked() or fail() on the returned object.

Parameters:
from - must be a local client with a session key manager, or null to use the router's session key manager
Returns:
null on encrypt failure

wrap

static GarlicMessage wrap(RouterContext ctx,
                          I2NPMessage m,
                          RouterInfo to)
Garlic wrap a message from nobody, destined for a router, to hide the contents from the OBEP. Forces ElGamal.

Returns:
null on encrypt failure
Since:
0.9.5

generateSession

public static MessageWrapper.OneTimeSession generateSession(RouterContext ctx)
Create a single key and tag, for receiving a single encrypted message, and register it with the router's session key manager, to expire in two minutes. The recipient can then send us an AES-encrypted message, avoiding ElGamal.

Since:
0.9.7

generateSession

public static MessageWrapper.OneTimeSession generateSession(RouterContext ctx,
                                                            Hash localDest)
Create a single key and tag, for receiving a single encrypted message, and register it with the client's session key manager, to expire in two minutes. The recipient can then send us an AES-encrypted message, avoiding ElGamal.

Returns:
null if we can't find the SKM for the localDest
Since:
0.9.9

generateSession

public static MessageWrapper.OneTimeSession generateSession(RouterContext ctx,
                                                            SessionKeyManager skm)
Create a single key and tag, for receiving a single encrypted message, and register it with the given session key manager, to expire in two minutes. The recipient can then send us an AES-encrypted message, avoiding ElGamal.

Returns:
non-null
Since:
0.9.9

wrap

public static GarlicMessage wrap(RouterContext ctx,
                                 I2NPMessage m,
                                 MessageWrapper.OneTimeSession session)
Garlic wrap a message from nobody, destined for an unknown router, to hide the contents from the IBGW. Uses a supplied one-time session key tag for AES encryption, avoiding ElGamal.

Parameters:
session - non-null
Returns:
null on encrypt failure
Since:
0.9.12

wrap

public static GarlicMessage wrap(RouterContext ctx,
                                 I2NPMessage m,
                                 SessionKey encryptKey,
                                 SessionTag encryptTag)
Garlic wrap a message from nobody, destined for an unknown router, to hide the contents from the IBGW. Uses a supplied session key and session tag for AES encryption, avoiding ElGamal.

Parameters:
encryptKey - non-null
encryptTag - non-null
Returns:
null on encrypt failure
Since:
0.9.7