java.lang.Object
net.i2p.data.SimpleDataStructure
net.i2p.data.SessionKey
net.i2p.router.crypto.ratchet.SessionKeyAndNonce
All Implemented Interfaces:
DataStructure

class SessionKeyAndNonceextends SessionKey
Session key with nonce and optional handshake state for ratchet message encryption and decryption operations, supporting nonces up to 65535

This is what is returned from RatchetTagSet.consume(RatchetSessionTag). RatchetSKM puts it in a RatchetEntry and returns it to ECIESAEADEngine.

  • Field Details

    • _id

      private final int _id
      The session's id.
    • _nonce

      private final int _nonce
      The nonce for the session's next message.
    • _state

      private final HandshakeState _state
      The handshake state the keys came from.
    • _remoteKey

      private final PublicKey _remoteKey
      The remote peer's key, for a reply.
  • Constructor Details

    • SessionKeyAndNonce

      public SessionKeyAndNonce(byte[] data, int nonce)
      For outbound Existing Session.
      Parameters:
      data - the AEAD session key, handed to the superclass
      nonce - message nonce, 0 to 65535
    • SessionKeyAndNonce

      public SessionKeyAndNonce(byte[] data, int id, int nonce, PublicKey remoteKey)
      For inbound Existing Session.
      Parameters:
      data - the AEAD session key, handed to the superclass
      id - index of the session within the inbound tag set
      nonce - message nonce, 0 to 65535
      remoteKey - the sender's static public key
    • SessionKeyAndNonce

      public SessionKeyAndNonce(HandshakeState state)
      For New Session Replies.
      Parameters:
      state - the noise handshake state carried over into the new session
  • Method Details

    • getNonce

      public int getNonce()
      For ES, else 0.
      Returns:
      the message nonce in the range 0 to 65535 that this session key is paired with, or 0 when no established session key is held yet
    • getID

      public int getID()
      For inbound ES, else 0.
      Returns:
      the session ID
    • getRemoteKey

      public PublicKey getRemoteKey()
      For inbound ES, else null. For NSR, use getHandshakeState().getRemotePublicKey().getPublicKey().
      Returns:
      the remote key
    • getHandshakeState

      public HandshakeState getHandshakeState()
      For inbound NSR only, else null. MUST be cloned before processing NSR.
      Returns:
      the handshake state
    • toString

      public String toString()
      Description copied from class: SimpleDataStructure
      Returns a string representation of this data structure.
      Overrides:
      toString in class SimpleDataStructure