net.i2p.router.crypto.ratchet

## Class SessionKeyAndNonce

- java.lang.Object
- - net.i2p.data.SimpleDataStructure
  - - net.i2p.data.SessionKey
    - - net.i2p.router.crypto.ratchet.SessionKeyAndNonce

- All Implemented Interfaces:
    DataStructure

      class SessionKeyAndNonce
      extends 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(). RatchetSKM puts it in a RatchetEntry and returns it to ECIESAEADEngine.

- - ### Field Summary

    - ### Fields inherited from class net.i2p.data.SessionKey

      `INVALID_KEY, KEYSIZE_BYTES`

    - ### Fields inherited from class net.i2p.data.SimpleDataStructure

      `_data`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SessionKeyAndNonce(byte[] data, int nonce)` For outbound Existing Session
    `SessionKeyAndNonce(byte[] data, int id, int nonce, PublicKey remoteKey)` For inbound Existing Session
    `SessionKeyAndNonce(HandshakeState state)` For New Session Replies

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `HandshakeState` | `getHandshakeState()` For inbound NSR only, else null.
    `int` | `getID()` For inbound ES, else 0
    `int` | `getNonce()` For ES, else 0
    `PublicKey` | `getRemoteKey()` For inbound ES, else null.
    `String` | `toString()`

    - ### Methods inherited from class net.i2p.data.SessionKey

      `getPreparedKey, length, setData, setPreparedKey`

    - ### Methods inherited from class net.i2p.data.SimpleDataStructure

      `calculateHash, equals, fromBase64, fromByteArray, getData, hashCode, read, readBytes, toBase64, toByteArray, writeBytes`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SessionKeyAndNonce

          public SessionKeyAndNonce(byte[] data,
                                    int nonce)

      For outbound Existing Session

    - #### SessionKeyAndNonce

          public SessionKeyAndNonce(byte[] data,
                                    int id,
                                    int nonce,
                                    PublicKey remoteKey)

      For inbound Existing Session

    - #### SessionKeyAndNonce

          public SessionKeyAndNonce(HandshakeState state)

      For New Session Replies

  - ### Method Detail

    - #### getHandshakeState

          public HandshakeState getHandshakeState()

      For inbound NSR only, else null. MUST be cloned before processing NSR.

    - #### getID

          public int getID()

      For inbound ES, else 0

    - #### getNonce

          public int getNonce()

      For ES, else 0

    - #### getRemoteKey

          public PublicKey getRemoteKey()

      For inbound ES, else null. For NSR, use getHansdhakeState().getRemotePublicKey().getPublicKey().

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `SimpleDataStructure`