net.i2p.crypto

## Class HKDF

- java.lang.Object
- - net.i2p.crypto.HKDF

-     public final class HKDF
      extends Object

  HMAC-based Key Derivation Function (HKDF) implementation using HMAC-SHA256. This class implements the HKDF algorithm as specified in RFC 5869 for deriving cryptographic keys from input key material. It provides secure key expansion functionality essential for I2P's cryptographic operations including session key generation and key derivation.

  Features and capabilities:

  - HMAC-SHA256 based derivation for cryptographic security
  - Support for one or two output keys with optional info parameter
  - Thread-safe operation with no internal state
  - Fixed 32-byte output size for consistency across I2P
  - Reusable instances for performance optimization
  See Also:
    RFC 5869 - HKDF

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HKDF(I2PAppContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `calculate(byte[] key, byte[] data, byte[] out)` One output, no info.
    `void` | `calculate(byte[] key, byte[] data, byte[] out, byte[] out2, int off2)` Two outputs, no info.
    `void` | `calculate(byte[] key, byte[] data, String info, byte[] out)` One output with info.
    `void` | `calculate(byte[] key, byte[] data, String info, byte[] out, byte[] out2, int off2)` Two outputs with info.

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

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

- - ### Constructor Detail

    - #### HKDF

          public HKDF(I2PAppContext context)

      Parameters:
        `context` - the app context

  - ### Method Detail

    - #### calculate

          public void calculate(byte[] key,
                                byte[] data,
                                byte[] out)

      One output, no info.
      Parameters:
        `key` - first 32 bytes used as the key
        `data` - the input data
        `out` - must be exactly 32 bytes

    - #### calculate

          public void calculate(byte[] key,
                                byte[] data,
                                byte[] out,
                                byte[] out2,
                                int off2)

      Two outputs, no info.
      Parameters:
        `key` - first 32 bytes used as the key
        `out` - 32 bytes will be copied to here
        `out2` - 32 bytes will be copied to here, may be the same as out
        `off2` - offset for copy to out2

    - #### calculate

          public void calculate(byte[] key,
                                byte[] data,
                                String info,
                                byte[] out)

      One output with info.
      Parameters:
        `key` - first 32 bytes used as the key
        `data` - the input data
        `info` - non-null ASCII, "" if none
        `out` - must be exactly 32 bytes

    - #### calculate

          public void calculate(byte[] key,
                                byte[] data,
                                String info,
                                byte[] out,
                                byte[] out2,
                                int off2)

      Two outputs with info.
      Parameters:
        `key` - first 32 bytes used as the key
        `info` - non-null ASCII, "" if none
        `out` - 32 bytes will be copied to here
        `out2` - 32 bytes will be copied to here, may be the same as out
        `off2` - offset for copy to out2