public class TransientSessionKeyManager
extends net.i2p.crypto.SessionKeyManager
| Modifier and Type | Field and Description |
|---|---|
protected net.i2p.I2PAppContext |
_context |
static int |
DEFAULT_TAGS
This was 100 since 0.6.1.10 (50 before that).
|
static int |
LOW_THRESHOLD
ditto
|
static int |
MAX_INBOUND_SESSION_TAGS
a few MB? how about 24 MB!
This is the max size of _inboundTagSets.
|
| Constructor and Description |
|---|
TransientSessionKeyManager(net.i2p.I2PAppContext context)
The session key manager should only be constructed and accessed through the
application context.
|
TransientSessionKeyManager(net.i2p.I2PAppContext context,
int tagsToSend,
int lowThreshold) |
| Modifier and Type | Method and Description |
|---|---|
net.i2p.data.SessionTag |
consumeNextAvailableTag(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
Retrieve the next available session tag for identifying the use of the given
key when communicating with the target.
|
net.i2p.data.SessionKey |
consumeTag(net.i2p.data.SessionTag tag)
Determine if we have received a session key associated with the given session tag,
and if so, discard it (but keep track for frequent dups) and return the decryption
key it was received with (via tagsReceived(...)).
|
void |
createSession(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
Associate a new session key with the specified target.
|
void |
failTags(net.i2p.data.PublicKey target)
Deprecated.
unused and rather drastic
|
void |
failTags(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
net.i2p.crypto.TagSetHandle ts)
Mark these tags as invalid, since the peer
has failed to ack them in time.
|
int |
getAvailableTags(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
Determine (approximately) how many available session tags for the current target
have been confirmed and are available
|
long |
getAvailableTimeLeft(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
Determine how long the available tags will be available for before expiring, in
milliseconds
|
net.i2p.data.SessionKey |
getCurrentKey(net.i2p.data.PublicKey target)
Retrieve the session key currently associated with encryption to the target,
or null if a new session key should be generated.
|
net.i2p.data.SessionKey |
getCurrentOrNewKey(net.i2p.data.PublicKey target)
Retrieve the session key currently associated with encryption to the target.
|
int |
getLowThreshold() |
int |
getTagsToSend()
How many to send, IF we need to.
|
void |
renderStatusHTML(Writer out) |
boolean |
shouldSendTags(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
int lowThreshold) |
void |
shutdown() |
void |
tagsAcked(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
net.i2p.crypto.TagSetHandle ts)
Mark these tags as acked, start to use them (if we haven't already)
If the set was previously failed, it will be added back in.
|
net.i2p.crypto.TagSetHandle |
tagsDelivered(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
Set<net.i2p.data.SessionTag> sessionTags)
Take note of the fact that the given sessionTags associated with the key for
encryption to the target have been sent.
|
void |
tagsReceived(net.i2p.data.SessionKey key,
Set<net.i2p.data.SessionTag> sessionTags)
Accept the given tags and associate them with the given key for decryption
|
void |
tagsReceived(net.i2p.data.SessionKey key,
Set<net.i2p.data.SessionTag> sessionTags,
long expire)
Accept the given tags and associate them with the given key for decryption
|
protected final net.i2p.I2PAppContext _context
public static final int MAX_INBOUND_SESSION_TAGS
public static final int DEFAULT_TAGS
- Tags are 32 bytes. So it previously added 3200 bytes to an initial message.
- Too many tags adds a huge overhead to short-duration connections
(like http, datagrams, etc.)
- Large messages have a much higher chance of being dropped due to
one of their 1KB fragments being discarded by a tunnel participant.
- This reduces the effective maximum datagram size because the client
doesn't know when tags will be bundled, so the tag size must be
subtracted from the maximum I2NP size or transport limit.
Issues with too small a value:
- When tags are sent, a reply leaseset (~1KB) is always bundled.
Maybe don't need to bundle more than every minute or so
rather than every time?
- Does the number of tags (and the threshold of 20) limit the effective
streaming lib window size? Should the threshold and the number of
sent tags be variable based on the message rate?
We have to be very careful if we implement an adaptive scheme,
since the key manager is per-router, not per-local-dest.
Or maybe that's a bad idea, and we need to move to a per-dest manager.
This needs further investigation.
So a value somewhat higher than the low threshold
seems appropriate.
Use care when adjusting these values. See ConnectionOptions in streaming,
and TransientSessionKeyManager in crypto, for more information.public static final int LOW_THRESHOLD
public TransientSessionKeyManager(net.i2p.I2PAppContext context)
public TransientSessionKeyManager(net.i2p.I2PAppContext context,
int tagsToSend,
int lowThreshold)
tagsToSend - how many to send at a time, may be lower or higher than lowThreshold. 1-128lowThreshold - below this, send more. 1-128public void shutdown()
shutdown in class net.i2p.crypto.SessionKeyManagerpublic net.i2p.data.SessionKey getCurrentKey(net.i2p.data.PublicKey target)
getCurrentKey in class net.i2p.crypto.SessionKeyManagerpublic net.i2p.data.SessionKey getCurrentOrNewKey(net.i2p.data.PublicKey target)
getCurrentOrNewKey in class net.i2p.crypto.SessionKeyManagertarget - public key to which the data should be encrypted, must be ELGAMAL_2048.IllegalArgumentException - on bad target EncTypepublic void createSession(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
createSession in class net.i2p.crypto.SessionKeyManagertarget - public key to which the data should be encrypted, must be ELGAMAL_2048.IllegalArgumentException - on bad target EncTypepublic net.i2p.data.SessionTag consumeNextAvailableTag(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
consumeNextAvailableTag in class net.i2p.crypto.SessionKeyManagerpublic int getTagsToSend()
getTagsToSend in class net.i2p.crypto.SessionKeyManagerpublic int getLowThreshold()
getLowThreshold in class net.i2p.crypto.SessionKeyManagerpublic boolean shouldSendTags(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
int lowThreshold)
shouldSendTags in class net.i2p.crypto.SessionKeyManagerpublic int getAvailableTags(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
getAvailableTags in class net.i2p.crypto.SessionKeyManagerpublic long getAvailableTimeLeft(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key)
getAvailableTimeLeft in class net.i2p.crypto.SessionKeyManagerpublic net.i2p.crypto.TagSetHandle tagsDelivered(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
Set<net.i2p.data.SessionTag> sessionTags)
tagsDelivered in class net.i2p.crypto.SessionKeyManager@Deprecated public void failTags(net.i2p.data.PublicKey target)
failTags in class net.i2p.crypto.SessionKeyManagerpublic void failTags(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
net.i2p.crypto.TagSetHandle ts)
failTags in class net.i2p.crypto.SessionKeyManagerpublic void tagsAcked(net.i2p.data.PublicKey target,
net.i2p.data.SessionKey key,
net.i2p.crypto.TagSetHandle ts)
tagsAcked in class net.i2p.crypto.SessionKeyManagerpublic void tagsReceived(net.i2p.data.SessionKey key,
Set<net.i2p.data.SessionTag> sessionTags)
tagsReceived in class net.i2p.crypto.SessionKeyManagersessionTags - modifiable; NOT copiedpublic void tagsReceived(net.i2p.data.SessionKey key,
Set<net.i2p.data.SessionTag> sessionTags,
long expire)
tagsReceived in class net.i2p.crypto.SessionKeyManagersessionTags - modifiable; NOT copied. Non-null, non-empty.expire - time from nowpublic net.i2p.data.SessionKey consumeTag(net.i2p.data.SessionTag tag)
consumeTag in class net.i2p.crypto.SessionKeyManagerpublic void renderStatusHTML(Writer out) throws IOException
renderStatusHTML in class net.i2p.crypto.SessionKeyManagerIOException