public class RatchetSKM extends SessionKeyManager implements SessionTagListener
| Modifier and Type | Field and Description |
|---|---|
protected RouterContext | _contextThe router context |
(package private) static long | SESSION_LIFETIME_MAX_MSKeep 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_MSHow long a session stays pending in ms. |
(package private) static long | SESSION_TAG_DURATION_MSLet 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)ECIES only. |
RatchetSKM(RouterContext context,
Destination dest,
EncType type)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)Process an ACK request |
boolean | addTag(RatchetSessionTag tag,
RatchetTagSet ts)Map the tag to this tagset. |
RatchetEntry | consumeNextAvailableTag(PublicKey target)Outbound. |
SessionTag | consumeNextAvailableTag(PublicKey target,
SessionKey key)Not supported for this key manager. |
SessionKeyAndNonce | consumeTag(RatchetSessionTag tag)Inbound. |
SessionKey | consumeTag(SessionTag tag)Not supported for this key manager. |
(package private) boolean | createSession(PublicKey target,
Destination d,
HandshakeState state,
ReplyCallback callback)Inbound or outbound. |
void | createSession(PublicKey target,
SessionKey key)Not supported for this key manager. |
void | expireTag(RatchetSessionTag tag,
RatchetTagSet ts)Remove the tag associated with this tagset. |
void | failTags(PublicKey target,
SessionKey key,
TagSetHandle ts)Not supported for this key manager. |
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)Not supported for this key manager. |
SessionKey | getCurrentOrNewKey(PublicKey target)Not supported for this key manager. |
Destination | getDestination()The local destination for this SKM |
(package private) Destination | getDestination(PublicKey target)The far-end destination for a public key. |
int | getLowThreshold()The configured threshold for sending more tags. |
int | getTagsToSend()How many to send, IF we need to. |
EncType | getType()The encryption type for this session key manager. |
(package private) boolean | isDuplicate(PublicKey pk)Check if a public key is a duplicate |
(package private) void | nextKeyReceived(PublicKey target,
NextSessionKey key)Process a received next key |
(package private) void | receivedACK(PublicKey target,
int id,
int n)Process a received ACK |
(package private) void | registerCallback(PublicKey target,
int id,
int n,
ReplyCallback callback)Register a callback for an ACK |
(package private) boolean | registerTimer(PublicKey target,
Destination d,
SimpleTimer2.TimedEvent timer)Side effect - binds this session to the supplied destination. |
void | renderStatusHTML(Writer out)Render the session status HTML. |
boolean | shouldSendTags(PublicKey target,
SessionKey key,
int lowThreshold)Whether to send more tags, always false here. |
void | shutdown()Cannot be restarted |
void | tagsAcked(PublicKey target,
SessionKey key,
TagSetHandle ts)Not supported for this key manager. |
TagSetHandle | tagsDelivered(PublicKey target,
SessionKey key,
Set<SessionTag> sessionTags)Not supported for this key manager. |
void | tagsReceived(SessionKey key,
RatchetSessionTag tag,
long expire)One time session |
void | tagsReceived(SessionKey key,
Set<SessionTag> sessionTags)Not supported for this key manager. |
void | tagsReceived(SessionKey key,
Set<SessionTag> sessionTags,
long expire)Not supported for this key manager. |
(package private) boolean | updateSession(PublicKey target,
HandshakeState oldState,
HandshakeState state,
ReplyCallback callback,
SplitKeys split)Inbound or outbound. |
createSession, failTags, shouldSendTagsprotected final RouterContext _context
static final long SESSION_LIFETIME_MAX_MS
static final long SESSION_PENDING_DURATION_MS
static final long SESSION_TAG_DURATION_MS
public RatchetSKM(RouterContext context)
context - the router contextpublic RatchetSKM(RouterContext context, Destination dest)
context - the router contextdest - null for router's SKM onlypublic RatchetSKM(RouterContext context, Destination dest, EncType type)
context - the router contextdest - null for router's SKM onlytype - the encryption typevoid ackRequested(PublicKey target, int id, int n)
target - the target public keyid - the ACK IDn - the ACK countpublic boolean addTag(RatchetSessionTag tag, RatchetTagSet ts)
addTag in interface SessionTagListenertag - the session tagts - the tag setpublic RatchetEntry consumeNextAvailableTag(PublicKey target)
target - the targetpublic SessionTag consumeNextAvailableTag(PublicKey target, SessionKey key)
consumeNextAvailableTag in class SessionKeyManagerUnsupportedOperationException - alwayspublic SessionKeyAndNonce consumeTag(RatchetSessionTag tag)
tag - the ratchet session tag to consumepublic SessionKey consumeTag(SessionTag tag)
consumeTag in class SessionKeyManagerUnsupportedOperationException - alwaysboolean createSession(PublicKey target, Destination d, HandshakeState state, ReplyCallback callback)
target - the target public keyd - null if unknownstate - the handshake statecallback - null for inbound, may be null for outboundpublic void createSession(PublicKey target, SessionKey key)
createSession in class SessionKeyManagerUnsupportedOperationException - alwayspublic void expireTag(RatchetSessionTag tag, RatchetTagSet ts)
expireTag in interface SessionTagListenertag - the session tagts - the tag setpublic void failTags(PublicKey target, SessionKey key, TagSetHandle ts)
failTags in class SessionKeyManagertarget - the targetkey - the session keyts - the tag set handleUnsupportedOperationException - alwayspublic int getAvailableTags(PublicKey target, SessionKey key)
getAvailableTags in class SessionKeyManagerpublic long getAvailableTimeLeft(PublicKey target, SessionKey key)
getAvailableTimeLeft in class SessionKeyManagerpublic SessionKey getCurrentKey(PublicKey target)
getCurrentKey in class SessionKeyManagerUnsupportedOperationException - alwayspublic SessionKey getCurrentOrNewKey(PublicKey target)
getCurrentOrNewKey in class SessionKeyManagerUnsupportedOperationException - alwayspublic Destination getDestination()
Destination getDestination(PublicKey target)
target - the target public keypublic int getLowThreshold()
getLowThreshold in class SessionKeyManagerpublic int getTagsToSend()
getTagsToSend in class SessionKeyManagerpublic EncType getType()
boolean isDuplicate(PublicKey pk)
pk - the public key to checkvoid nextKeyReceived(PublicKey target, NextSessionKey key)
target - the target public keykey - the next session keyvoid receivedACK(PublicKey target, int id, int n)
target - the target public keyid - the ACK IDn - the ACK countvoid registerCallback(PublicKey target, int id, int n, ReplyCallback callback)
target - the target public keyid - the callback IDn - the callback countcallback - the reply callbackboolean registerTimer(PublicKey target, Destination d, SimpleTimer2.TimedEvent timer)
target - the target public keyd - the far-end Destination for this PublicKey if known, or nulltimer - the timer eventpublic void renderStatusHTML(Writer out) throws IOException
renderStatusHTML in class SessionKeyManagerout - the writer to render toIOException - if an I/O error occurspublic boolean shouldSendTags(PublicKey target, SessionKey key, int lowThreshold)
shouldSendTags in class SessionKeyManagertarget - the targetkey - the session keylowThreshold - the low thresholdpublic void shutdown()
shutdown in class SessionKeyManagerpublic void tagsAcked(PublicKey target, SessionKey key, TagSetHandle ts)
tagsAcked in class SessionKeyManagertarget - the targetkey - the session keyts - the tag set handleUnsupportedOperationException - alwayspublic TagSetHandle tagsDelivered(PublicKey target, SessionKey key, Set<SessionTag> sessionTags)
tagsDelivered in class SessionKeyManagerUnsupportedOperationException - alwayspublic void tagsReceived(SessionKey key, RatchetSessionTag tag, long expire)
key - the session keytag - the ratchet session tagexpire - time from nowpublic void tagsReceived(SessionKey key, Set<SessionTag> sessionTags)
tagsReceived in class SessionKeyManagerUnsupportedOperationException - alwayspublic void tagsReceived(SessionKey key, Set<SessionTag> sessionTags, long expire)
tagsReceived in class SessionKeyManagersessionTags - modifiable; NOT copiedexpire - time from nowUnsupportedOperationException - alwaysboolean updateSession(PublicKey target, HandshakeState oldState, HandshakeState state, ReplyCallback callback, SplitKeys split)
target - the target public keyoldState - null for inbound, pre-clone for outboundstate - the handshake statecallback - the reply callbacksplit - the split keys