public class RatchetSKM extends SessionKeyManager implements SessionTagListener
Modifier and Type | Field and Description |
---|---|
protected RouterContext |
_context |
(package private) static long |
SESSION_LIFETIME_MAX_MS
Keep unused inbound session tags around for this long (a few minutes longer than
session tags are used on the outbound side so that no reasonable network lag
can cause failed decrypts)
This is also the max idle time for an outbound session.
|
(package private) static long |
SESSION_PENDING_DURATION_MS |
(package private) static long |
SESSION_TAG_DURATION_MS
Let outbound session tags sit around for this long before expiring them.
|
Constructor and Description |
---|
RatchetSKM(RouterContext context)
For the router SKM only.
|
RatchetSKM(RouterContext context,
Destination dest)
The session key manager is constructed and accessed through the
client manager.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
ackRequested(PublicKey target,
int id,
int n) |
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,
Destination d,
HandshakeState state,
ReplyCallback callback)
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) |
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.
|
Destination |
getDestination() |
(package private) Destination |
getDestination(PublicKey target) |
int |
getLowThreshold() |
int |
getTagsToSend()
How many to send, IF we need to.
|
(package private) boolean |
isDuplicate(PublicKey pk) |
(package private) void |
nextKeyReceived(PublicKey target,
NextSessionKey key) |
(package private) void |
receivedACK(PublicKey target,
int id,
int n) |
(package private) void |
registerCallback(PublicKey target,
int id,
int n,
ReplyCallback callback) |
(package private) boolean |
registerTimer(PublicKey target,
Destination d,
SimpleTimer2.TimedEvent timer)
Side effect - binds this session to the supplied destination.
|
void |
renderStatusHTML(Writer out) |
boolean |
shouldSendTags(PublicKey target,
SessionKey key,
int lowThreshold) |
void |
shutdown()
Cannot be restarted
|
void |
tagsAcked(PublicKey target,
SessionKey key,
TagSetHandle ts) |
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 definitely been received at the target (aka call this
method after receiving an ack to a message delivering them)
|
void |
tagsReceived(SessionKey key,
RatchetSessionTag tag,
long expire)
One time session
|
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,
ReplyCallback callback,
SplitKeys split)
Inbound or outbound.
|
createSession, shouldSendTags
protected final RouterContext _context
static final long SESSION_TAG_DURATION_MS
static final long SESSION_LIFETIME_MAX_MS
static final long SESSION_PENDING_DURATION_MS
public RatchetSKM(RouterContext context)
public RatchetSKM(RouterContext context, Destination dest)
dest
- null for router's SKM onlypublic void shutdown()
shutdown
in class SessionKeyManager
public Destination getDestination()
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 isDuplicate(PublicKey pk)
boolean createSession(PublicKey target, Destination d, HandshakeState state, ReplyCallback callback)
d
- null if unknowncallback
- null for inbound, may be null for outboundboolean updateSession(PublicKey target, HandshakeState oldState, HandshakeState state, ReplyCallback callback, SplitKeys split)
oldState
- null for inbound, pre-clone for outboundvoid nextKeyReceived(PublicKey target, NextSessionKey key)
boolean registerTimer(PublicKey target, Destination d, SimpleTimer2.TimedEvent timer)
d
- the far-end Destination for this PublicKey if known, or nullDestination getDestination(PublicKey target)
public 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)
SessionKeyManager
tagsDelivered
in class SessionKeyManager
UnsupportedOperationException
- always@Deprecated public void failTags(PublicKey target)
failTags
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic void failTags(PublicKey target, SessionKey key, TagSetHandle ts)
failTags
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic void tagsAcked(PublicKey target, SessionKey key, TagSetHandle ts)
tagsAcked
in class SessionKeyManager
UnsupportedOperationException
- alwayspublic 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 void tagsReceived(SessionKey key, RatchetSessionTag tag, long expire)
expire
- time from nowpublic 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
void registerCallback(PublicKey target, int id, int n, ReplyCallback callback)
void receivedACK(PublicKey target, int id, int n)
void ackRequested(PublicKey target, int id, int n)
public void renderStatusHTML(Writer out) throws IOException
renderStatusHTML
in class SessionKeyManager
IOException