Class LmsPrivateKeySpec

java.lang.Object
zeroecho.core.alg.lms.LmsPrivateKeySpec
All Implemented Interfaces:
Destroyable, AlgorithmKeySpec

public final class LmsPrivateKeySpec extends Object implements AlgorithmKeySpec, Destroyable
Encoded representation of an LMS private key in PKCS#8 format.

LMS private keys are stateful with a finite signing capacity. The PKCS#8 encoding captures the current leaf-index state. Callers must persist the updated key state after every signing operation to prevent key-state reuse. See LmsSignatureContext for lifecycle guidance.

This class implements Destroyable to allow zeroing of key material when the spec is no longer needed.

Since:
1.0
  • Constructor Details

    • LmsPrivateKeySpec

      public LmsPrivateKeySpec(byte[] pkcs8Der)
      Constructs a new spec from PKCS#8 DER encoded LMS private key bytes.
      Parameters:
      pkcs8Der - PKCS#8 DER bytes
      Throws:
      NullPointerException - if pkcs8Der is null
  • Method Details

    • pkcs8

      public byte[] pkcs8()
      Returns a defensive copy of the PKCS#8 encoded key bytes.
      Returns:
      PKCS#8 DER bytes
      Throws:
      IllegalStateException - if this spec has been destroyed
    • marshal

      public static PairSeq marshal(LmsPrivateKeySpec spec)
      Serializes this spec to a PairSeq.
      Parameters:
      spec - the spec to serialize
      Returns:
      serialized representation
    • unmarshal

      public static LmsPrivateKeySpec unmarshal(PairSeq p)
      Deserializes a spec from a PairSeq.
      Parameters:
      p - serialized representation
      Returns:
      reconstructed spec
      Throws:
      IllegalArgumentException - if required field is missing
    • destroy

      public void destroy()
      Specified by:
      destroy in interface Destroyable
    • isDestroyed

      public boolean isDestroyed()
      Specified by:
      isDestroyed in interface Destroyable
    • toString

      public String toString()
      Overrides:
      toString in class Object