Class BCXMSSPrivateKey
- All Implemented Interfaces:
Serializable, AsymmetricKey, DEREncodablePREVIEW, Key, PrivateKey, Destroyable, XMSSKey, XMSSPrivateKey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBCXMSSPrivateKey(ASN1ObjectIdentifier treeDigest, XMSSPrivateKeyParameters keyParams) BCXMSSPrivateKey(PrivateKeyInfo keyInfo) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroy this key, zeroizing the secret key material it holds.booleanWhether these are the same key at the same position, which for a stateful key means the same traversal state too - the whole of whichXMSSPrivateKeyParameters.equals(Object)decides, this being the line that asks it.extractKeyShard(int usageCount) Return a key representing a shard of the key space that can be used usageCount times.byte[]intlonggetIndex()Return the index of the next signature.longReturn the number of usages left for the private key.inthashCode()booleanMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AsymmetricKey
getParams
-
Constructor Details
-
BCXMSSPrivateKey
-
BCXMSSPrivateKey
- Throws:
IOException
-
-
Method Details
-
getIndex
public long getIndex()Description copied from interface:XMSSPrivateKeyReturn the index of the next signature.- Specified by:
getIndexin interfaceXMSSPrivateKey- Returns:
- the index number for the next signature.
-
getUsagesRemaining
public long getUsagesRemaining()Description copied from interface:XMSSPrivateKeyReturn the number of usages left for the private key.- Specified by:
getUsagesRemainingin interfaceXMSSPrivateKey- Returns:
- the number of times the key can be used before it is exhausted.
-
extractKeyShard
Description copied from interface:XMSSPrivateKeyReturn 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:
extractKeyShardin interfaceXMSSPrivateKey- 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
- Specified by:
getAlgorithmin interfaceKey
-
getFormat
-
getEncoded
public byte[] getEncoded()- Specified by:
getEncodedin interfaceKey
-
equals
Whether these are the same key at the same position, which for a stateful key means the same traversal state too - the whole of whichXMSSPrivateKeyParameters.equals(Object)decides, this being the line that asks it.It was written out here, over the accessors, and none of it belonged here: the fields it reads are the key parameters' own, the monitor a signature is taken under is the key parameters' own, and each accessor hands out a clone rather than a value that could be held still beside another key's.
BCLMSPrivateKeyis this same line overHSSPrivateKeyParameters, which is where the other stateful family in this provider keeps the same reasoning.The tree digest this class carries alongside the key parameters is not compared, because comparing it decides nothing: it is
keyParams.getParameters().getTreeDigestOID()at every route a key here is constructed by, and that is the OID the key parameters compare.The PKCS#8 attributes are not compared either, and that one does change what
equalssays about two keysgetEncoded()writes differently: attributes travel into the encoding, so one key loaded from a PKCS#8 carrying a friendlyName and one built from the same secret without it are equal here and encode to different bytes. That is the answer this class wants. What a stateful key is asked here is whether this is the same key at the same position - the question a one-time key signing twice is the failure of, RFC 8391 sec. 1.1 - and a label a caller attached on the way through a keystore moves neither the secret nor the index.BCLMSPrivateKey, which carries attributes the same way and is where this comparison came from, leaves them out for the same reason, as doesBCMLDSAPrivateKeyover its own parameters' encoding. A caller that does need the encodings to agree should compare the encodings. -
hashCode
-
getHeight
-
getTreeDigest
- Specified by:
getTreeDigestin interfaceXMSSKey
-
destroy
public void destroy()Destroy this key, zeroizing the secret key material it holds.The secret key seed, the PRF key and the WOTS+ secret retained by the BDS traversal state are zeroized; the public seed, root, index and tree nodes are retained, so
getIndex(),getUsagesRemaining(),getHeight()andgetTreeDigest()keep working andhashCode()is stable. After destructionisDestroyed()returns true,getEncoded()andextractKeyShard(int)throwIllegalStateException, the key can no longer be serialized, and a Signature refuses it at initSign. Shards extracted before destruction hold their own copies of the seeds and are unaffected. As the underlyingXMSSPrivateKeyParametersobject is destroyed, keys sharing it are invalidated too.- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-