Package org.bouncycastle.crypto.params
Class LMSPrivateKeyParameters
- java.lang.Object
-
- org.bouncycastle.crypto.params.AsymmetricKeyParameter
-
- org.bouncycastle.crypto.params.LMSKeyParameters
-
- org.bouncycastle.crypto.params.LMSPrivateKeyParameters
-
- All Implemented Interfaces:
javax.security.auth.Destroyable,CipherParameters,LMSContextBasedSigner,Encodable
public class LMSPrivateKeyParameters extends LMSKeyParameters implements LMSContextBasedSigner, javax.security.auth.Destroyable
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLMSPrivateKeyParameters(LMSigParameters lmsParameter, LMOtsParameters otsParameters, int maxQ)A key with no position, identifier or seed of its own - the placeholder an HSS hierarchy is built with for the levels below the root, each of which resetKeyToIndex replaces from the level above before the key is used.LMSPrivateKeyParameters(LMSigParameters lmsParameter, LMOtsParameters otsParameters, int q, byte[] I, int maxQ, byte[] masterSecret)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Destroy this key, zeroizing the master secret it holds.booleanequals(java.lang.Object o)LMSPrivateKeyParametersextractKeyShard(int usageCount)Return a key that can be used usageCount times.LMSContextgenerateLMSContext()byte[]generateSignature(LMSContext context)byte[]getEncoded()Return a byte array representing the implementing object.byte[]getI()intgetIndex()Return the key index (the q value).intgetIndexLimit()static LMSPrivateKeyParametersgetInstance(byte[] privEnc, byte[] pubEnc)static LMSPrivateKeyParametersgetInstance(java.lang.Object src)byte[]getMasterSecret()LMOtsParametersgetOtsParameters()LMSPublicKeyParametersgetPublicKey()LMSigParametersgetSigParameters()longgetUsagesRemaining()inthashCode()booleanisDestroyed()-
Methods inherited from class org.bouncycastle.crypto.params.AsymmetricKeyParameter
isPrivate
-
-
-
-
Constructor Detail
-
LMSPrivateKeyParameters
public LMSPrivateKeyParameters(LMSigParameters lmsParameter, LMOtsParameters otsParameters, int q, byte[] I, int maxQ, byte[] masterSecret)
-
LMSPrivateKeyParameters
protected LMSPrivateKeyParameters(LMSigParameters lmsParameter, LMOtsParameters otsParameters, int maxQ)
A key with no position, identifier or seed of its own - the placeholder an HSS hierarchy is built with for the levels below the root, each of which resetKeyToIndex replaces from the level above before the key is used. The sentinel values are deliberately ones the public constructor refuses, so a placeholder can never be mistaken for a key that was merely built carelessly; a subclass using this must not present the result as a usable key.
-
-
Method Detail
-
getInstance
public static LMSPrivateKeyParameters getInstance(byte[] privEnc, byte[] pubEnc) throws java.io.IOException
- Throws:
java.io.IOException
-
getInstance
public static LMSPrivateKeyParameters getInstance(java.lang.Object src) throws java.io.IOException
- Throws:
java.io.IOException
-
getIndex
public int getIndex()
Return the key index (the q value).- Returns:
- private key index number.
-
generateLMSContext
public LMSContext generateLMSContext()
- Specified by:
generateLMSContextin interfaceLMSContextBasedSigner
-
generateSignature
public byte[] generateSignature(LMSContext context)
- Specified by:
generateSignaturein interfaceLMSContextBasedSigner
-
extractKeyShard
public LMSPrivateKeyParameters extractKeyShard(int usageCount)
Return a key that can be used usageCount times.Note: this will use the range [index...index + usageCount) for the current key.
- Parameters:
usageCount- the number of usages the key should have.- Returns:
- a key based on the current key that can be used usageCount times.
-
getSigParameters
public LMSigParameters getSigParameters()
-
getOtsParameters
public LMOtsParameters getOtsParameters()
-
getI
public byte[] getI()
-
getMasterSecret
public byte[] getMasterSecret()
-
destroy
public void destroy()
Destroy this key, zeroizing the master secret it holds.The key identifier I, the parameter sets, the index and the cached Merkle tree nodes are retained - none of them is secret, and the public key stays derivable where the tree's root is already cached. After destruction
isDestroyed()returns true andgetMasterSecret(),getEncoded(),generateLMSContext()and the derivation of child trees throwIllegalStateException; a signature attempt fails before its one-time index is claimed. Note: keys repositioned within this tree or split off it withextractKeyShard(int)share its master secret array, so destroying this key invalidates them too.- Specified by:
destroyin interfacejavax.security.auth.Destroyable
-
isDestroyed
public boolean isDestroyed()
- Specified by:
isDestroyedin interfacejavax.security.auth.Destroyable
-
getIndexLimit
public int getIndexLimit()
-
getUsagesRemaining
public long getUsagesRemaining()
- Specified by:
getUsagesRemainingin interfaceLMSContextBasedSigner
-
getPublicKey
public LMSPublicKeyParameters getPublicKey()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getEncoded
public byte[] getEncoded() throws java.io.IOExceptionDescription copied from interface:EncodableReturn a byte array representing the implementing object.- Specified by:
getEncodedin interfaceEncodable- Specified by:
getEncodedin classLMSKeyParameters- Returns:
- a byte array representing the encoding.
- Throws:
java.io.IOException- if an issue arises generation the encoding.
-
-