Package zeroecho.core.spec


package zeroecho.core.spec
Specifications for keys and per-operation parameters.

This package defines lightweight, strongly typed specifications used when creating cryptographic contexts. Key specifications describe how a key should be generated or imported for a particular family, while context specifications supply optional, per-operation parameters (for example, padding or nonce strategy). Algorithms that need no extra parameters use a singleton placeholder.

Key elements

  • AlgorithmKeySpec - marker interface for algorithm-specific key specs used by key builders.
  • ContextSpec - marker interface for per-operation parameters supplied to context creation.
  • VoidSpec - singleton context spec used when an algorithm requires no additional parameters.

Typical usage

// Algorithm requires no per-operation parameters.
zeroecho.core.context.CryptoContext ctx =
    algo.createContext(zeroecho.core.KeyUsage.SIGN, privateKey, zeroecho.core.spec.VoidSpec.INSTANCE);

// Algorithm with parameters: pass an algorithm-specific ContextSpec implementation.
// Example: RSA with OAEP/PSS, AEAD tag length, etc.
// zeroecho.core.context.CryptoContext ctx =
//     algo.createContext(zeroecho.core.KeyUsage.ENCRYPT, key, someAlgorithmSpecificSpec);

Design notes

  • Specification types should be immutable and safe to share across operations.
  • Key specifications and context specifications keep configuration separate from runtime state, improving clarity and reuse.
  • Callers should prefer library-provided spec classes and avoid implementing the marker interfaces directly unless extending the library with new families.
Since:
1.0