Class HybridKexExporter

java.lang.Object
zeroecho.sdk.hybrid.kex.HybridKexExporter
All Implemented Interfaces:
AutoCloseable, Destroyable

public final class HybridKexExporter extends Object implements Destroyable, AutoCloseable
Deterministic exporter for deriving multiple independent keys from a single hybrid KEX.

Many protocols require more than one key from a single handshake (for example, separate traffic keys for each direction, confirmation keys, or application exporters). This class provides a minimal key schedule API over HKDF-SHA256.

Construction

The exporter is seeded by a caller-supplied secret (typically the output of HybridKexContext.deriveSecret()). The exporter then derives sub-keys by varying HKDF info.

Security notes

  • Use distinct labels per purpose (for example "app/tx" vs "app/rx").
  • Bind transcript/context by including it in the info bytes.
Since:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    HybridKexExporter(byte[] rootSecret, byte[] salt)
    Creates an exporter seeded from a root secret.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this exporter by destroying its retained secret material.
    void
    Overwrites the exporter root secret and salt.
    byte[]
    export(String label, byte[] info, int outLenBytes)
    Derives outLenBytes bytes for a specific purpose.
    byte[]
    export(String label, int outLenBytes)
    Derives outLenBytes bytes for a specific purpose using only the label.
    boolean
    Reports whether this exporter has been destroyed.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HybridKexExporter

      public HybridKexExporter(byte[] rootSecret, byte[] salt)
      Creates an exporter seeded from a root secret.
      Parameters:
      rootSecret - root secret (must not be null)
      salt - optional HKDF salt (may be null)
  • Method Details

    • export

      public byte[] export(String label, byte[] info, int outLenBytes)
      Derives outLenBytes bytes for a specific purpose.
      Parameters:
      label - ASCII/UTF-8 label identifying the purpose (must not be null)
      info - optional additional binding info (may be null)
      outLenBytes - output length in bytes (1..8160)
      Returns:
      derived bytes
      Throws:
      IllegalArgumentException - if outLenBytes is out of range
      Since:
      1.0
    • export

      public byte[] export(String label, int outLenBytes)
      Derives outLenBytes bytes for a specific purpose using only the label.

      Equivalent to export(label, null, outLenBytes). Use the three-argument form to additionally bind a transcript or context value.

      Parameters:
      label - ASCII/UTF-8 label identifying the purpose (must not be null)
      outLenBytes - output length in bytes (1..8160)
      Returns:
      derived bytes
      Throws:
      IllegalArgumentException - if outLenBytes is out of range
      IllegalStateException - if the exporter has been destroyed
      Since:
      1.0
    • destroy

      public void destroy()
      Overwrites the exporter root secret and salt.

      Destruction is idempotent. All subsequent export or diagnostic access fails with IllegalStateException.

      Specified by:
      destroy in interface Destroyable
    • isDestroyed

      public boolean isDestroyed()
      Reports whether this exporter has been destroyed.
      Specified by:
      isDestroyed in interface Destroyable
      Returns:
      true after destruction
    • close

      public void close()
      Closes this exporter by destroying its retained secret material.
      Specified by:
      close in interface AutoCloseable