public class RatchetSKM extends SessionKeyManager implements SessionTagListener
Modifier and Type | Field and Description |
---|---|
protected I2PAppContext |
_context |
Constructor and Description |
---|
RatchetSKM(RouterContext context)
The session key manager should only be constructed and accessed through the
application context.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addTag(RatchetSessionTag tag,
RatchetTagSet ts)
Map the tag to this tagset.
|
RatchetEntry |
consumeNextAvailableTag(PublicKey target)
Outbound.
|
SessionTag |
consumeNextAvailableTag(PublicKey target,
SessionKey key)
Retrieve the next available session tag for identifying the use of the given
key when communicating with the target.
|
SessionKeyAndNonce |
consumeTag(RatchetSessionTag tag)
Inbound.
|
SessionKey |
consumeTag(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(...)).
|
(package private) boolean |
createSession(PublicKey target,
HandshakeState state)
Inbound or outbound.
|
void |
createSession(PublicKey target,
SessionKey key)
Associate a new session key with the specified target.
|
void |
expireTag(RatchetSessionTag tag,
RatchetTagSet ts)
Remove the tag associated with this tagset.
|
void |
failTags(PublicKey target)
Deprecated.
unused and rather drastic
|
void |
failTags(PublicKey target,
SessionKey key,
TagSetHandle ts)
Mark these tags as invalid, since the peer
has failed to ack them in time.
|
int |
getAvailableTags(PublicKey target,
SessionKey key)
Determine (approximately) how many available session tags for the current target
have been confirmed and are available
|
long |
getAvailableTimeLeft(PublicKey target,
SessionKey key)
Determine how long the available tags will be available for before expiring, in
milliseconds
|
SessionKey |
getCurrentKey(PublicKey target)
Retrieve the session key currently associated with encryption to the target,
or null if a new session key should be generated.
|
SessionKey |
getCurrentOrNewKey(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(PublicKey target,
SessionKey key,
int lowThreshold) |
void |
shutdown()
Called when the system is closing down, instructing the session key manager to take
whatever precautions are necessary (saving state, etc)
|
void |
tagsAcked(PublicKey target,
SessionKey key,
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.
|
TagSetHandle |
tagsDelivered(PublicKey target,
SessionKey key,
Set<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(SessionKey key,
Set<SessionTag> sessionTags)
Accept the given tags and associate them with the given key for decryption,
with the default expiration.
|
void |
tagsReceived(SessionKey key,
Set<SessionTag> sessionTags,
long expire)
Accept the given tags and associate them with the given key for decryption,
with specified expiration.
|
(package private) boolean |
updateSession(PublicKey target,
HandshakeState oldState,
HandshakeState state)
Inbound or outbound.
|
createSession, shouldSendTags
protected final I2PAppContext _context
public RatchetSKM(RouterContext context)
public void shutdown()
SessionKeyManager
shutdown
in class SessionKeyManager
public SessionKey getCurrentKey(PublicKey target)
SessionKeyManager
getCurrentKey
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic SessionKey getCurrentOrNewKey(PublicKey target)
SessionKeyManager
getCurrentOrNewKey
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic void createSession(PublicKey target, SessionKey key)
SessionKeyManager
createSession
in class SessionKeyManager
UnsupportedOperationException
- alwaysboolean createSession(PublicKey target, HandshakeState state)
boolean updateSession(PublicKey target, HandshakeState oldState, HandshakeState state)
oldState
- null for inbound, pre-clone for outboundpublic SessionTag consumeNextAvailableTag(PublicKey target, SessionKey key)
SessionKeyManager
consumeNextAvailableTag
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic RatchetEntry consumeNextAvailableTag(PublicKey target)
public int getTagsToSend()
getTagsToSend
in class SessionKeyManager
public int getLowThreshold()
getLowThreshold
in class SessionKeyManager
public boolean shouldSendTags(PublicKey target, SessionKey key, int lowThreshold)
shouldSendTags
in class SessionKeyManager
public int getAvailableTags(PublicKey target, SessionKey key)
getAvailableTags
in class SessionKeyManager
public long getAvailableTimeLeft(PublicKey target, SessionKey key)
getAvailableTimeLeft
in class SessionKeyManager
public TagSetHandle tagsDelivered(PublicKey target, SessionKey key, Set<SessionTag> sessionTags)
tagsDelivered
in class SessionKeyManager
sessionTags
- ignored, must be null@Deprecated public void failTags(PublicKey target)
failTags
in class SessionKeyManager
public void failTags(PublicKey target, SessionKey key, TagSetHandle ts)
failTags
in class SessionKeyManager
public void tagsAcked(PublicKey target, SessionKey key, TagSetHandle ts)
tagsAcked
in class SessionKeyManager
public void tagsReceived(SessionKey key, Set<SessionTag> sessionTags)
SessionKeyManager
tagsReceived
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic void tagsReceived(SessionKey key, Set<SessionTag> sessionTags, long expire)
SessionKeyManager
tagsReceived
in class SessionKeyManager
sessionTags
- modifiable; NOT copiedexpire
- time from nowUnsupportedOperationException
- alwayspublic SessionKey consumeTag(SessionTag tag)
SessionKeyManager
consumeTag
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic SessionKeyAndNonce consumeTag(RatchetSessionTag tag)
public boolean addTag(RatchetSessionTag tag, RatchetTagSet ts)
addTag
in interface SessionTagListener
public void expireTag(RatchetSessionTag tag, RatchetTagSet ts)
expireTag
in interface SessionTagListener
public void renderStatusHTML(Writer out) throws IOException
renderStatusHTML
in class SessionKeyManager
IOException