## net.i2p.crypto
Class TransientSessionKeyManager

    java.lang.Object
      net.i2p.crypto.SessionKeyManager
          net.i2p.crypto.TransientSessionKeyManager

Direct Known Subclasses:
  PersistentSessionKeyManager

class TransientSessionKeyManager
extends SessionKeyManager

Implement the session key management, but keep everything in memory (don't write to disk). However, this being java, we cannot guarantee that the keys aren't swapped out to disk so this should not be considered secure in that sense.

Nested Class Summary
`(package private) class` `TransientSessionKeyManager.OutboundSession`
`(package private) static class` `TransientSessionKeyManager.TagSet`

Field Summary
`protected I2PAppContext` `_context`
`static int` `MAX_INBOUND_SESSION_TAGS`
`static long` `SESSION_LIFETIME_MAX_MS` Keep unused inbound session tags around for up to 12 minutes (2 minutes longer than session tags are used on the outbound side so that no reasonable network lag can cause failed decrypts)
`static long` `SESSION_TAG_DURATION_MS` Let session tags sit around for 10 minutes before expiring them.

Constructor Summary
`TransientSessionKeyManager(I2PAppContext context)` The session key manager should only be constructed and accessed through the application context.

Method Summary
`int` `aggressiveExpire()` Aggressively expire inbound tag sets and outbound sessions
`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.
`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(...)).
`void` `createSession(PublicKey target, SessionKey key)` Associate a new session key with the specified target.
`void` `failTags(PublicKey target)` 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.
`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.
`protected java.util.Set` `getInboundTagSets()` TagSet
`protected java.util.Set` `getOutboundSessions()` OutboundSession
`java.lang.String` `renderStatusHTML()`
`protected void` `setData(java.util.Set inboundTagSets, java.util.Set outboundSessions)`
`void` `tagsDelivered(PublicKey target, SessionKey key, java.util.Set 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, java.util.Set sessionTags)` Accept the given tags and associate them with the given key for decryption

Methods inherited from class net.i2p.crypto.SessionKeyManager
`createSession, shutdown`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _context

    protected I2PAppContext _context

### SESSION_TAG_DURATION_MS

    public static final long SESSION_TAG_DURATION_MS

  Let session tags sit around for 10 minutes before expiring them. We can now have such a large value since there is the persistent session key manager. This value is for outbound tags - inbound tags are managed by SESSION_LIFETIME_MAX_MS

  See Also:
    Constant Field Values

### SESSION_LIFETIME_MAX_MS

    public static final long SESSION_LIFETIME_MAX_MS

  Keep unused inbound session tags around for up to 12 minutes (2 minutes longer than session tags are used on the outbound side so that no reasonable network lag can cause failed decrypts)

  See Also:
    Constant Field Values

### MAX_INBOUND_SESSION_TAGS

    public static final int MAX_INBOUND_SESSION_TAGS

See Also:
  Constant Field Values

Constructor Detail

### TransientSessionKeyManager

    public TransientSessionKeyManager(I2PAppContext 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

### getInboundTagSets

    protected java.util.Set getInboundTagSets()

  TagSet

### getOutboundSessions

    protected java.util.Set getOutboundSessions()

  OutboundSession

### setData

    protected void setData(java.util.Set inboundTagSets,
                           java.util.Set outboundSessions)

### getCurrentKey

    public 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.

  Overrides:
    `getCurrentKey` in class `SessionKeyManager`

### createSession

    public void createSession(PublicKey target,
                              SessionKey key)

  Associate a new session key with the specified target. Metrics to determine when to expire that key begin with this call.

  Overrides:
    `createSession` in class `SessionKeyManager`

### consumeNextAvailableTag

    public 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. If this returns null, no tags are available so ElG should be used with the given key (a new sessionKey should NOT be used)

  Overrides:
    `consumeNextAvailableTag` in class `SessionKeyManager`

### 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`

### getAvailableTimeLeft

    public long getAvailableTimeLeft(PublicKey target,
                                     SessionKey key)

  Determine how long the available tags will be available for before expiring, in milliseconds

  Overrides:
    `getAvailableTimeLeft` in class `SessionKeyManager`

### tagsDelivered

    public void tagsDelivered(PublicKey target,
                              SessionKey key,
                              java.util.Set 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)

  Overrides:
    `tagsDelivered` in class `SessionKeyManager`

### failTags

    public void failTags(PublicKey target)

  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`

### tagsReceived

    public void tagsReceived(SessionKey key,
                             java.util.Set sessionTags)

  Accept the given tags and associate them with the given key for decryption

  Overrides:
    `tagsReceived` in class `SessionKeyManager`

### consumeTag

    public 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(...)). returns null if no session key matches

  Overrides:
    `consumeTag` in class `SessionKeyManager`

### aggressiveExpire

    public int aggressiveExpire()

  Aggressively expire inbound tag sets and outbound sessions

  Returns:
    number of tag sets expired

### renderStatusHTML

    public java.lang.String renderStatusHTML()