java.lang.Object
net.i2p.crypto.SigContext.SigContextSpec
All Implemented Interfaces:
AlgorithmParameterSpec
Enclosing class:
SigContext

public static class SigContext.SigContextSpecextends 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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
    The context string as ASCII bytes, 16 of them.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a signature context specification from the given context string.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    byte[]
    Returns the raw context data for cryptographic operations.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • b

      private final byte[] b
      The context string as ASCII bytes, 16 of them.
  • Constructor Details

    • 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 Details

    • 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