Class RatchetSKM

    • Constructor Detail

      • RatchetSKM

        public RatchetSKM​(RouterContext context)
        The session key manager should only be constructed and accessed through the application context. This constructor should only be used by the appropriate application context itself.
    • Method Detail

      • shutdown

        public void shutdown()
        Description copied from class: SessionKeyManager
        Called when the system is closing down, instructing the session key manager to take whatever precautions are necessary (saving state, etc)
        Overrides:
        shutdown in class SessionKeyManager
      • createSession

        boolean createSession​(PublicKey target,
                              HandshakeState state)
        Inbound or outbound. Checks state.getRole() to determine. For outbound (NS sent), adds to list of pending inbound sessions and returns true. For inbound (NS rcvd), if no other pending outbound sessions, creates one and returns true, or false if one already exists.
      • updateSession

        boolean updateSession​(PublicKey target,
                              HandshakeState oldState,
                              HandshakeState state)
        Inbound or outbound. Checks state.getRole() to determine. For outbound (NSR rcvd by Alice), sets session to transition to ES mode outbound. For inbound (NSR sent by Bob), sets up inbound ES tagset.
        Parameters:
        oldState - null for inbound, pre-clone for outbound
        Returns:
        true if this was the first NSR received
      • consumeNextAvailableTag

        public RatchetEntry consumeNextAvailableTag​(PublicKey target)
        Outbound. Retrieve the next available session tag and key for sending a message to the target. If this returns null, no session is set up yet, and a New Session message should be sent. If this returns non-null, the tag in the RatchetEntry will be non-null. If the SessionKeyAndNonce contains a HandshakeState, then the session setup is in progress, and a New Session Reply message should be sent. Otherwise, an Existing Session message should be sent.
      • getTagsToSend

        public int getTagsToSend()
        How many to send, IF we need to.
        Overrides:
        getTagsToSend in class SessionKeyManager
        Returns:
        the configured value (not adjusted for current available)
      • getAvailableTags

        public int getAvailableTags​(PublicKey target,
                                    SessionKey key)
        Determine (approximately) how many available session tags for the current target have been confirmed and are available
        Overrides:
        getAvailableTags in class SessionKeyManager
      • tagsDelivered

        public 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. Whether to use the tags immediately (i.e. assume they will be received) or to wait until an ack, is implementation dependent.
        Overrides:
        tagsDelivered in class SessionKeyManager
        Parameters:
        sessionTags - ignored, must be null
        Returns:
        the TagSetHandle. Caller MUST subsequently call failTags() or tagsAcked() with this handle. May be null.
      • failTags

        @Deprecated
        public void failTags​(PublicKey target)
        Deprecated.
        unused and rather drastic
        Mark all of the tags delivered to the target up to this point as invalid, since the peer has failed to respond when they should have. This call essentially lets the system recover from corrupted tag sets and crashes
        Overrides:
        failTags in class SessionKeyManager
      • consumeTag

        public SessionKey consumeTag​(SessionTag tag)
        Description copied from class: SessionKeyManager
        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(...)). returns null if no session key matches
        Overrides:
        consumeTag in class SessionKeyManager
        Throws:
        UnsupportedOperationException - always
      • consumeTag

        public SessionKeyAndNonce consumeTag​(RatchetSessionTag tag)
        Inbound. Determine if we have received a session key associated with the given session tag, and if so, discard it and return the decryption key it was received with (via tagsReceived(...)). returns null if no session key matches If the return value has null data, it will have a non-null HandshakeState.
        Returns:
        a SessionKeyAndNonce or null