net.i2p.crypto

## Class SigContext.SigContextSpec

- java.lang.Object
- - net.i2p.crypto.SigContext.SigContextSpec

- All Implemented Interfaces:
    AlgorithmParameterSpec
  Enclosing class:
    SigContext

      public static class SigContext.SigContextSpec
      extends Object
      implements AlgorithmParameterSpec

  Algorithm parameter specification for personalized hash contexts in digital signatures. This class implements `AlgorithmParameterSpec` to provide context-specific data for cryptographic signature operations using personalized hash functions. The context data is used as domain separation to prevent signature replay attacks across different I2P protocols and data types.

  Purpose and Security:

  - Domain separation between different I2P protocols
  - Prevention of cross-protocol signature replay attacks
  - Implementation of Proposal 148 for enhanced signature security
  - Context-specific hash personalization for BLAKE signature engines

  Format and Validation:

  - Context data must be exactly 16 ASCII bytes
  - Null context indicates no personalization (SC_NONE)
  - Invalid lengths throw `IllegalArgumentException`
  - Data is stored as raw bytes for cryptographic operations

  Usage:

       // Get context specification for datagram signatures
       SigContextSpec spec = SigContext.SC_DATAGRAM.getSpec();

       // Apply to signature engine
       signatureEngine.setParameter(spec);

  Supported Contexts:

  - SC_DATAGRAM - Datagram protocol signatures
  - SC_I2CP - I2CP session configuration
  - SC_NETDB - Network database entries
  - SC_NTCP - NTCP handshake signatures
  - SC_SSU - SSU handshake signatures
  - SC_STREAMING - Streaming protocol signatures
  - SC_SU3 - SU3 file format signatures
  - SC_TEST - Test context for development

  Thread Safety: This class is immutable and thread-safe. The returned byte array should not be modified by callers.

  See Also:
    `AlgorithmParameterSpec`, `SigContext`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SigContextSpec(String context)` Creates a signature context specification from the given context string.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `getData()` Returns the raw context data for cryptographic operations.

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

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

- - ### Constructor Detail

    - #### SigContextSpec

          public SigContextSpec(String context)

      Creates a signature context specification from the given context string.
      Parameters:
        `context` - the ASCII context string, must be exactly 16 characters, or null for no context (SC_NONE)
      Throws:
        `IllegalArgumentException` - if the context string is not exactly 16 characters

  - ### Method Detail

    - #### getData

          public byte[] getData()

      Returns the raw context data for cryptographic operations. The returned array is the internal storage and should not be modified.
      Returns:
        the 16-byte context data as a byte array, or null if no context is set