Class BCLMSPrivateKey

java.lang.Object
org.bouncycastle.pqc.jcajce.provider.lms.BCLMSPrivateKey
All Implemented Interfaces:
Serializable, AsymmetricKey, DEREncodablePREVIEW, Key, PrivateKey, Destroyable, LMSKey, LMSPrivateKey

public class BCLMSPrivateKey extends Object implements LMSPrivateKey, Destroyable
See Also:
  • Constructor Details

  • Method Details

    • getIndex

      public long getIndex()
      Description copied from interface: LMSPrivateKey
      Return the index of the next signature.
      Specified by:
      getIndex in interface LMSPrivateKey
      Returns:
      the index number for the next signature.
    • getUsagesRemaining

      public long getUsagesRemaining()
      Description copied from interface: LMSPrivateKey
      Return the number of usages left for the private key.
      Specified by:
      getUsagesRemaining in interface LMSPrivateKey
      Returns:
      the number of times the key can be used before it is exhausted.
    • extractKeyShard

      public LMSPrivateKey extractKeyShard(int usageCount)
      Description copied from interface: LMSPrivateKey
      Return a key representing a shard of the key space that can be used usageCount times.

      Note: this will use the range [index...index + usageCount) for the current key.

      Specified by:
      extractKeyShard in interface LMSPrivateKey
      Parameters:
      usageCount - the number of usages the key should have.
      Returns:
      a key based on the current key that can be used usageCount times.
    • getAlgorithm

      public String getAlgorithm()
      Specified by:
      getAlgorithm in interface Key
    • getFormat

      public String getFormat()
      Specified by:
      getFormat in interface Key
    • getEncoded

      public byte[] getEncoded()
      Specified by:
      getEncoded in interface Key
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getLevels

      public int getLevels()
      Description copied from interface: LMSKey
      Return the number of levels (L) associated with the key.
      Specified by:
      getLevels in interface LMSKey
      Returns:
      L.
    • destroy

      public void destroy()
      Destroy this key, zeroizing the secret key material it holds.

      The master secret of every tree in the hierarchy is zeroized; the key identifiers, indexes, chaining signatures and cached tree nodes are retained, so getIndex(), getUsagesRemaining() and getLevels() keep working. After destruction isDestroyed() returns true, getEncoded() and extractKeyShard(int) throw IllegalStateException, the key can no longer be serialized, and a Signature refuses it at initSign. Shards extracted before destruction are independent copies and are unaffected. As the underlying HSSPrivateKeyParameters object is destroyed, keys sharing it are invalidated too.

      Specified by:
      destroy in interface Destroyable
    • isDestroyed

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