net.i2p.router.transport.udp

## Class SSU2Util

- java.lang.Object
- - net.i2p.router.transport.udp.SSU2Util

-     final class SSU2Util
      extends Object

  SSU2 Utils and constants

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `CHACHA_IV_LEN`
    `static byte` | `DATA_FLAG_BYTE`
    `static int` | `DATA_FOLLOWON_EXTRA_SIZE` 5 for flag and msg number in followon block
    `static int` | `DATA_HEADER_SIZE` 16 byte short header
    `static int` | `DEST_CONN_ID_OFFSET`
    `static int` | `FIRST_FRAGMENT_HEADER_SIZE` 3 byte block header
    `static int` | `FOLLOWON_FRAGMENT_HEADER_SIZE` 3 byte block header + 4 byte msg ID + 1 byte fragment info = 8
    `static int` | `HEADER_PROT_1_OFFSET`
    `static int` | `HEADER_PROT_2_OFFSET`
    `static int` | `HEADER_PROT_DATA_LEN`
    `static int` | `HEADER_PROT_SAMPLE_1_OFFSET`
    `static int` | `HEADER_PROT_SAMPLE_2_OFFSET`
    `static int` | `HEADER_PROT_SAMPLE_LEN`
    `static byte` | `HOLE_PUNCH_FLAG_BYTE`
    `static String` | `INFO_CONFIRMED`
    `static String` | `INFO_CREATED`
    `static String` | `INFO_DATA`
    `static int` | `INTRO_KEY_LEN`
    `static int` | `KEY_LEN` 32
    `static int` | `LONG_HEADER_FLAGS_OFFSET`
    `static int` | `LONG_HEADER_SIZE`
    `static int` | `MAC_LEN`
    `static int` | `MIN_DATA_LEN` 40
    `static int` | `MIN_HANDSHAKE_DATA_LEN` 88
    `static int` | `MIN_LONG_DATA_LEN` 56
    `static int` | `MIN_RETRY_LEN` 56
    `static int` | `MIN_SESSION_CREATED_LEN` 88
    `static int` | `MIN_SESSION_REQUEST_LEN` 88
    `static int` | `MIN_TOKEN_REQUEST_LEN` 56
    `static int` | `NETID_OFFSET`
    `static int` | `PADDING_MAX`
    `static int` | `PADDING_MAX_SESSION_CREATED`
    `static int` | `PADDING_MAX_SESSION_REQUEST`
    `static byte` | `PEER_TEST_FLAG_BYTE`
    `static byte[]` | `PEER_TEST_PROLOGUE`
    `static int` | `PKT_NUM_LEN`
    `static int` | `PKT_NUM_OFFSET`
    `static int` | `PROTOCOL_VERSION`
    `static int` | `REASON_AEAD`
    `static int` | `REASON_BANNED`
    `static int` | `REASON_FRAME_TIMEOUT`
    `static int` | `REASON_FRAMING`
    `static int` | `REASON_LIMITS`
    `static int` | `REASON_MSG1`
    `static int` | `REASON_MSG2`
    `static int` | `REASON_MSG3`
    `static int` | `REASON_NETID`
    `static int` | `REASON_OPTIONS`
    `static int` | `REASON_PADDING`
    `static int` | `REASON_PAYLOAD`
    `static int` | `REASON_REPLACED`
    `static int` | `REASON_S_MISMATCH`
    `static int` | `REASON_SHUTDOWN`
    `static int` | `REASON_SIGFAIL`
    `static int` | `REASON_SIGTYPE`
    `static int` | `REASON_SKEW`
    `static int` | `REASON_TERMINATION`
    `static int` | `REASON_TIMEOUT`
    `static int` | `REASON_TOKEN`
    `static int` | `REASON_UNSPEC`
    `static int` | `REASON_VERSION`
    `static int` | `RELAY_ACCEPT`
    `static int` | `RELAY_REJECT_BOB_BANNED_CHARLIE`
    `static int` | `RELAY_REJECT_BOB_LIMIT`
    `static int` | `RELAY_REJECT_BOB_NO_TAG`
    `static int` | `RELAY_REJECT_BOB_SIGFAIL`
    `static int` | `RELAY_REJECT_BOB_UNKNOWN_ALICE`
    `static int` | `RELAY_REJECT_BOB_UNSPEC`
    `static int` | `RELAY_REJECT_CHARLIE_ADDRESS`
    `static int` | `RELAY_REJECT_CHARLIE_BANNED`
    `static int` | `RELAY_REJECT_CHARLIE_CONNECTED`
    `static int` | `RELAY_REJECT_CHARLIE_LIMIT`
    `static int` | `RELAY_REJECT_CHARLIE_SIGFAIL`
    `static int` | `RELAY_REJECT_CHARLIE_UNKNOWN_ALICE`
    `static int` | `RELAY_REJECT_CHARLIE_UNSPEC`
    `static byte[]` | `RELAY_REQUEST_PROLOGUE`
    `static byte[]` | `RELAY_RESPONSE_PROLOGUE`
    `static byte` | `RETRY_FLAG_BYTE`
    `static byte` | `SESSION_CONFIRMED_FLAG_BYTE`
    `static byte` | `SESSION_CREATED_FLAG_BYTE`
    `static int` | `SESSION_HEADER_SIZE` 64
    `static byte` | `SESSION_REQUEST_FLAG_BYTE` The message types, 0-11, as bytes
    `static int` | `SHORT_HEADER_FLAGS_LEN`
    `static int` | `SHORT_HEADER_FLAGS_OFFSET`
    `static int` | `SHORT_HEADER_SIZE`
    `static int` | `SRC_CONN_ID_OFFSET`
    `static int` | `TEST_ACCEPT`
    `static int` | `TEST_REJECT_BOB_ADDRESS`
    `static int` | `TEST_REJECT_BOB_LIMIT`
    `static int` | `TEST_REJECT_BOB_NO_CHARLIE`
    `static int` | `TEST_REJECT_BOB_SIGFAIL`
    `static int` | `TEST_REJECT_BOB_UNSPEC`
    `static int` | `TEST_REJECT_CHARLIE_ADDRESS`
    `static int` | `TEST_REJECT_CHARLIE_BANNED`
    `static int` | `TEST_REJECT_CHARLIE_CONNECTED`
    `static int` | `TEST_REJECT_CHARLIE_LIMIT`
    `static int` | `TEST_REJECT_CHARLIE_SIGFAIL`
    `static int` | `TEST_REJECT_CHARLIE_UNKNOWN_ALICE`
    `static int` | `TEST_REJECT_CHARLIE_UNSPEC`
    `static int` | `TOKEN_OFFSET`
    `static byte` | `TOKEN_REQUEST_FLAG_BYTE`
    `static int` | `TOTAL_PROT_SAMPLE_LEN`
    `static int` | `TYPE_OFFSET`
    `static int` | `VERSION_OFFSET`
    `static byte[]` | `ZEROKEY`
    `static byte[]` | `ZEROLEN`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `createPeerTestData(I2PAppContext ctx, Hash h, Hash h2, PeerTestState.Role role, long nonce, byte[] ip, int port, SigningPrivateKey spk)` Make the data for the peer test block
    `static byte[]` | `createRelayRequestData(I2PAppContext ctx, Hash h, Hash h2, long nonce, long tag, byte[] ip, int port, SigningPrivateKey spk)` Make the data for the relay request block
    `static byte[]` | `createRelayResponseData(I2PAppContext ctx, Hash h, int code, long nonce, byte[] ip, int port, SigningPrivateKey spk, long token)` Make the data for the relay response block
    `static byte[]` | `hkdf(I2PAppContext ctx, byte[] key, String info)` 32 byte output, ZEROLEN data
    `static Signature` | `sign(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, int datalen, SigningPrivateKey spk)` Sign the relay or peer test data, using the prologue and hash as the initial data, and then the provided data.
    `static String` | `terminationCodeToString(int code)`
    `static boolean` | `validateSig(I2PAppContext ctx, byte[] prologue, Hash h, Hash h2, byte[] data, SigningPublicKey spk)` Validate the signed relay or peer test data, using the prologue and hash as the initial data, and then the provided data which ends with a signature of the specified type.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CHACHA_IV_LEN

          public static final int CHACHA_IV_LEN

      See Also:
        Constant Field Values

    - #### DATA_FLAG_BYTE

          public static final byte DATA_FLAG_BYTE

      See Also:
        Constant Field Values

    - #### DATA_FOLLOWON_EXTRA_SIZE

          public static final int DATA_FOLLOWON_EXTRA_SIZE

      5 for flag and msg number in followon block
      See Also:
        Constant Field Values

    - #### DATA_HEADER_SIZE

          public static final int DATA_HEADER_SIZE

      16 byte short header
      See Also:
        Constant Field Values

    - #### DEST_CONN_ID_OFFSET

          public static final int DEST_CONN_ID_OFFSET

      See Also:
        Constant Field Values

    - #### FIRST_FRAGMENT_HEADER_SIZE

          public static final int FIRST_FRAGMENT_HEADER_SIZE

      3 byte block header
      See Also:
        Constant Field Values

    - #### FOLLOWON_FRAGMENT_HEADER_SIZE

          public static final int FOLLOWON_FRAGMENT_HEADER_SIZE

      3 byte block header + 4 byte msg ID + 1 byte fragment info = 8
      See Also:
        Constant Field Values

    - #### HEADER_PROT_1_OFFSET

          public static final int HEADER_PROT_1_OFFSET

      See Also:
        Constant Field Values

    - #### HEADER_PROT_2_OFFSET

          public static final int HEADER_PROT_2_OFFSET

      See Also:
        Constant Field Values

    - #### HEADER_PROT_DATA_LEN

          public static final int HEADER_PROT_DATA_LEN

      See Also:
        Constant Field Values

    - #### HEADER_PROT_SAMPLE_1_OFFSET

          public static final int HEADER_PROT_SAMPLE_1_OFFSET

      See Also:
        Constant Field Values

    - #### HEADER_PROT_SAMPLE_2_OFFSET

          public static final int HEADER_PROT_SAMPLE_2_OFFSET

      See Also:
        Constant Field Values

    - #### HEADER_PROT_SAMPLE_LEN

          public static final int HEADER_PROT_SAMPLE_LEN

      See Also:
        Constant Field Values

    - #### HOLE_PUNCH_FLAG_BYTE

          public static final byte HOLE_PUNCH_FLAG_BYTE

      See Also:
        Constant Field Values

    - #### INFO_CONFIRMED

          public static final String INFO_CONFIRMED

      See Also:
        Constant Field Values

    - #### INFO_CREATED

          public static final String INFO_CREATED

      See Also:
        Constant Field Values

    - #### INFO_DATA

          public static final String INFO_DATA

      See Also:
        Constant Field Values

    - #### INTRO_KEY_LEN

          public static final int INTRO_KEY_LEN

      See Also:
        Constant Field Values

    - #### KEY_LEN

          public static final int KEY_LEN

      32

    - #### LONG_HEADER_FLAGS_OFFSET

          public static final int LONG_HEADER_FLAGS_OFFSET

      See Also:
        Constant Field Values

    - #### LONG_HEADER_SIZE

          public static final int LONG_HEADER_SIZE

      See Also:
        Constant Field Values

    - #### MAC_LEN

          public static final int MAC_LEN

      See Also:
        Constant Field Values

    - #### MIN_DATA_LEN

          public static final int MIN_DATA_LEN

      40
      See Also:
        Constant Field Values

    - #### MIN_HANDSHAKE_DATA_LEN

          public static final int MIN_HANDSHAKE_DATA_LEN

      88

    - #### MIN_LONG_DATA_LEN

          public static final int MIN_LONG_DATA_LEN

      56
      See Also:
        Constant Field Values

    - #### MIN_RETRY_LEN

          public static final int MIN_RETRY_LEN

      56
      See Also:
        Constant Field Values

    - #### MIN_SESSION_CREATED_LEN

          public static final int MIN_SESSION_CREATED_LEN

      88

    - #### MIN_SESSION_REQUEST_LEN

          public static final int MIN_SESSION_REQUEST_LEN

      88

    - #### MIN_TOKEN_REQUEST_LEN

          public static final int MIN_TOKEN_REQUEST_LEN

      56
      See Also:
        Constant Field Values

    - #### NETID_OFFSET

          public static final int NETID_OFFSET

      See Also:
        Constant Field Values

    - #### PADDING_MAX

          public static final int PADDING_MAX

      See Also:
        Constant Field Values

    - #### PADDING_MAX_SESSION_CREATED

          public static final int PADDING_MAX_SESSION_CREATED

      See Also:
        Constant Field Values

    - #### PADDING_MAX_SESSION_REQUEST

          public static final int PADDING_MAX_SESSION_REQUEST

      See Also:
        Constant Field Values

    - #### PEER_TEST_FLAG_BYTE

          public static final byte PEER_TEST_FLAG_BYTE

      See Also:
        Constant Field Values

    - #### PEER_TEST_PROLOGUE

          public static final byte[] PEER_TEST_PROLOGUE

    - #### PKT_NUM_LEN

          public static final int PKT_NUM_LEN

      See Also:
        Constant Field Values

    - #### PKT_NUM_OFFSET

          public static final int PKT_NUM_OFFSET

      See Also:
        Constant Field Values

    - #### PROTOCOL_VERSION

          public static final int PROTOCOL_VERSION

      See Also:
        Constant Field Values

    - #### REASON_AEAD

          public static final int REASON_AEAD

      See Also:
        Constant Field Values

    - #### REASON_BANNED

          public static final int REASON_BANNED

      See Also:
        Constant Field Values

    - #### REASON_FRAME_TIMEOUT

          public static final int REASON_FRAME_TIMEOUT

      See Also:
        Constant Field Values

    - #### REASON_FRAMING

          public static final int REASON_FRAMING

      See Also:
        Constant Field Values

    - #### REASON_LIMITS

          public static final int REASON_LIMITS

      See Also:
        Constant Field Values

    - #### REASON_MSG1

          public static final int REASON_MSG1

      See Also:
        Constant Field Values

    - #### REASON_MSG2

          public static final int REASON_MSG2

      See Also:
        Constant Field Values

    - #### REASON_MSG3

          public static final int REASON_MSG3

      See Also:
        Constant Field Values

    - #### REASON_NETID

          public static final int REASON_NETID

      See Also:
        Constant Field Values

    - #### REASON_OPTIONS

          public static final int REASON_OPTIONS

      See Also:
        Constant Field Values

    - #### REASON_PADDING

          public static final int REASON_PADDING

      See Also:
        Constant Field Values

    - #### REASON_PAYLOAD

          public static final int REASON_PAYLOAD

      See Also:
        Constant Field Values

    - #### REASON_REPLACED

          public static final int REASON_REPLACED

      See Also:
        Constant Field Values

    - #### REASON_S_MISMATCH

          public static final int REASON_S_MISMATCH

      See Also:
        Constant Field Values

    - #### REASON_SHUTDOWN

          public static final int REASON_SHUTDOWN

      See Also:
        Constant Field Values

    - #### REASON_SIGFAIL

          public static final int REASON_SIGFAIL

      See Also:
        Constant Field Values

    - #### REASON_SIGTYPE

          public static final int REASON_SIGTYPE

      See Also:
        Constant Field Values

    - #### REASON_SKEW

          public static final int REASON_SKEW

      See Also:
        Constant Field Values

    - #### REASON_TERMINATION

          public static final int REASON_TERMINATION

      See Also:
        Constant Field Values

    - #### REASON_TIMEOUT

          public static final int REASON_TIMEOUT

      See Also:
        Constant Field Values

    - #### REASON_TOKEN

          public static final int REASON_TOKEN

      See Also:
        Constant Field Values

    - #### REASON_UNSPEC

          public static final int REASON_UNSPEC

      See Also:
        Constant Field Values

    - #### REASON_VERSION

          public static final int REASON_VERSION

      See Also:
        Constant Field Values

    - #### RELAY_ACCEPT

          public static final int RELAY_ACCEPT

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_BOB_BANNED_CHARLIE

          public static final int RELAY_REJECT_BOB_BANNED_CHARLIE

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_BOB_LIMIT

          public static final int RELAY_REJECT_BOB_LIMIT

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_BOB_NO_TAG

          public static final int RELAY_REJECT_BOB_NO_TAG

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_BOB_SIGFAIL

          public static final int RELAY_REJECT_BOB_SIGFAIL

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_BOB_UNKNOWN_ALICE

          public static final int RELAY_REJECT_BOB_UNKNOWN_ALICE

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_BOB_UNSPEC

          public static final int RELAY_REJECT_BOB_UNSPEC

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_CHARLIE_ADDRESS

          public static final int RELAY_REJECT_CHARLIE_ADDRESS

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_CHARLIE_BANNED

          public static final int RELAY_REJECT_CHARLIE_BANNED

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_CHARLIE_CONNECTED

          public static final int RELAY_REJECT_CHARLIE_CONNECTED

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_CHARLIE_LIMIT

          public static final int RELAY_REJECT_CHARLIE_LIMIT

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_CHARLIE_SIGFAIL

          public static final int RELAY_REJECT_CHARLIE_SIGFAIL

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_CHARLIE_UNKNOWN_ALICE

          public static final int RELAY_REJECT_CHARLIE_UNKNOWN_ALICE

      See Also:
        Constant Field Values

    - #### RELAY_REJECT_CHARLIE_UNSPEC

          public static final int RELAY_REJECT_CHARLIE_UNSPEC

      See Also:
        Constant Field Values

    - #### RELAY_REQUEST_PROLOGUE

          public static final byte[] RELAY_REQUEST_PROLOGUE

    - #### RELAY_RESPONSE_PROLOGUE

          public static final byte[] RELAY_RESPONSE_PROLOGUE

    - #### RETRY_FLAG_BYTE

          public static final byte RETRY_FLAG_BYTE

      See Also:
        Constant Field Values

    - #### SESSION_CONFIRMED_FLAG_BYTE

          public static final byte SESSION_CONFIRMED_FLAG_BYTE

      See Also:
        Constant Field Values

    - #### SESSION_CREATED_FLAG_BYTE

          public static final byte SESSION_CREATED_FLAG_BYTE

      See Also:
        Constant Field Values

    - #### SESSION_HEADER_SIZE

          public static final int SESSION_HEADER_SIZE

      64

    - #### SESSION_REQUEST_FLAG_BYTE

          public static final byte SESSION_REQUEST_FLAG_BYTE

      The message types, 0-11, as bytes
      See Also:
        Constant Field Values

    - #### SHORT_HEADER_FLAGS_LEN

          public static final int SHORT_HEADER_FLAGS_LEN

      See Also:
        Constant Field Values

    - #### SHORT_HEADER_FLAGS_OFFSET

          public static final int SHORT_HEADER_FLAGS_OFFSET

      See Also:
        Constant Field Values

    - #### SHORT_HEADER_SIZE

          public static final int SHORT_HEADER_SIZE

      See Also:
        Constant Field Values

    - #### SRC_CONN_ID_OFFSET

          public static final int SRC_CONN_ID_OFFSET

      See Also:
        Constant Field Values

    - #### TEST_ACCEPT

          public static final int TEST_ACCEPT

      See Also:
        Constant Field Values

    - #### TEST_REJECT_BOB_ADDRESS

          public static final int TEST_REJECT_BOB_ADDRESS

      See Also:
        Constant Field Values

    - #### TEST_REJECT_BOB_LIMIT

          public static final int TEST_REJECT_BOB_LIMIT

      See Also:
        Constant Field Values

    - #### TEST_REJECT_BOB_NO_CHARLIE

          public static final int TEST_REJECT_BOB_NO_CHARLIE

      See Also:
        Constant Field Values

    - #### TEST_REJECT_BOB_SIGFAIL

          public static final int TEST_REJECT_BOB_SIGFAIL

      See Also:
        Constant Field Values

    - #### TEST_REJECT_BOB_UNSPEC

          public static final int TEST_REJECT_BOB_UNSPEC

      See Also:
        Constant Field Values

    - #### TEST_REJECT_CHARLIE_ADDRESS

          public static final int TEST_REJECT_CHARLIE_ADDRESS

      See Also:
        Constant Field Values

    - #### TEST_REJECT_CHARLIE_BANNED

          public static final int TEST_REJECT_CHARLIE_BANNED

      See Also:
        Constant Field Values

    - #### TEST_REJECT_CHARLIE_CONNECTED

          public static final int TEST_REJECT_CHARLIE_CONNECTED

      See Also:
        Constant Field Values

    - #### TEST_REJECT_CHARLIE_LIMIT

          public static final int TEST_REJECT_CHARLIE_LIMIT

      See Also:
        Constant Field Values

    - #### TEST_REJECT_CHARLIE_SIGFAIL

          public static final int TEST_REJECT_CHARLIE_SIGFAIL

      See Also:
        Constant Field Values

    - #### TEST_REJECT_CHARLIE_UNKNOWN_ALICE

          public static final int TEST_REJECT_CHARLIE_UNKNOWN_ALICE

      See Also:
        Constant Field Values

    - #### TEST_REJECT_CHARLIE_UNSPEC

          public static final int TEST_REJECT_CHARLIE_UNSPEC

      See Also:
        Constant Field Values

    - #### TOKEN_OFFSET

          public static final int TOKEN_OFFSET

      See Also:
        Constant Field Values

    - #### TOKEN_REQUEST_FLAG_BYTE

          public static final byte TOKEN_REQUEST_FLAG_BYTE

      See Also:
        Constant Field Values

    - #### TOTAL_PROT_SAMPLE_LEN

          public static final int TOTAL_PROT_SAMPLE_LEN

      See Also:
        Constant Field Values

    - #### TYPE_OFFSET

          public static final int TYPE_OFFSET

      See Also:
        Constant Field Values

    - #### VERSION_OFFSET

          public static final int VERSION_OFFSET

      See Also:
        Constant Field Values

    - #### ZEROKEY

          public static final byte[] ZEROKEY

    - #### ZEROLEN

          public static final byte[] ZEROLEN

  - ### Method Detail

    - #### createPeerTestData

          public static byte[] createPeerTestData(I2PAppContext ctx,
                                                  Hash h,
                                                  Hash h2,
                                                  PeerTestState.Role role,
                                                  long nonce,
                                                  byte[] ip,
                                                  int port,
                                                  SigningPrivateKey spk)

      Make the data for the peer test block
      Parameters:
        `h` - to be included in sig, not included in data
        `h2` - may be null, to be included in sig, not included in data
        `role` - unused
        `ip` - may be null
      Returns:
        null on failure

    - #### createRelayRequestData

          public static byte[] createRelayRequestData(I2PAppContext ctx,
                                                      Hash h,
                                                      Hash h2,
                                                      long nonce,
                                                      long tag,
                                                      byte[] ip,
                                                      int port,
                                                      SigningPrivateKey spk)

      Make the data for the relay request block
      Parameters:
        `h` - Bob hash to be included in sig, not included in data
        `h2` - Charlie hash to be included in sig, not included in data
        `ip` - non-null
      Returns:
        null on failure

    - #### createRelayResponseData

          public static byte[] createRelayResponseData(I2PAppContext ctx,
                                                       Hash h,
                                                       int code,
                                                       long nonce,
                                                       byte[] ip,
                                                       int port,
                                                       SigningPrivateKey spk,
                                                       long token)

      Make the data for the relay response block
      Parameters:
        `h` - Bob hash to be included in sig, not included in data
        `ip` - may be null
        `port` - ignored if ip is null
        `token` - if nonzero, append it
      Returns:
        null on failure

    - #### hkdf

          public static byte[] hkdf(I2PAppContext ctx,
                                    byte[] key,
                                    String info)

      32 byte output, ZEROLEN data

    - #### sign

          public static Signature sign(I2PAppContext ctx,
                                       byte[] prologue,
                                       Hash h,
                                       Hash h2,
                                       byte[] data,
                                       int datalen,
                                       SigningPrivateKey spk)

      Sign the relay or peer test data, using the prologue and hash as the initial data, and then the provided data.
      Parameters:
        `data` - if desired, leave room at end for sig
        `datalen` - the length of the data to be signed
        `h` - to be included in sig, not included in data
        `h2` - may be null, to be included in sig, not included in data
      Returns:
        null on failure

    - #### terminationCodeToString

          public static String terminationCodeToString(int code)

    - #### validateSig

          public static boolean validateSig(I2PAppContext ctx,
                                            byte[] prologue,
                                            Hash h,
                                            Hash h2,
                                            byte[] data,
                                            SigningPublicKey spk)

      Validate the signed relay or peer test data, using the prologue and hash as the initial data, and then the provided data which ends with a signature of the specified type.
      Parameters:
        `h2` - may be null
        `data` - not including relay response token