public class BCXMSSMTPrivateKey extends java.lang.Object implements java.security.PrivateKey, XMSSMTPrivateKey, javax.security.auth.Destroyable
| Constructor and Description |
|---|
BCXMSSMTPrivateKey(ASN1ObjectIdentifier treeDigest,
XMSSMTPrivateKeyParameters keyParams) |
BCXMSSMTPrivateKey(PrivateKeyInfo keyInfo) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Destroy this key, zeroizing the secret key material it holds.
|
boolean |
equals(java.lang.Object o)
Whether these are the same key at the same position, which for a stateful key means the same
traversal state too - the whole of which
XMSSMTPrivateKeyParameters.equals(Object)
decides, this being the line that asks it. |
XMSSMTPrivateKey |
extractKeyShard(int usageCount)
Return a key representing a shard of the key space that can be used usageCount times.
|
java.lang.String |
getAlgorithm() |
byte[] |
getEncoded() |
java.lang.String |
getFormat() |
int |
getHeight() |
long |
getIndex()
Return the index of the next signature.
|
int |
getLayers() |
java.lang.String |
getTreeDigest() |
long |
getUsagesRemaining()
Return the number of usages left for the private key.
|
int |
hashCode() |
boolean |
isDestroyed() |
public BCXMSSMTPrivateKey(ASN1ObjectIdentifier treeDigest, XMSSMTPrivateKeyParameters keyParams)
public BCXMSSMTPrivateKey(PrivateKeyInfo keyInfo) throws java.io.IOException
java.io.IOExceptionpublic long getIndex()
XMSSMTPrivateKeygetIndex in interface XMSSMTPrivateKeypublic long getUsagesRemaining()
XMSSMTPrivateKeygetUsagesRemaining in interface XMSSMTPrivateKeypublic XMSSMTPrivateKey extractKeyShard(int usageCount)
XMSSMTPrivateKeyNote: this will use the range [index...index + usageCount) for the current key.
extractKeyShard in interface XMSSMTPrivateKeyusageCount - the number of usages the key should have.public java.lang.String getAlgorithm()
getAlgorithm in interface java.security.Keypublic java.lang.String getFormat()
getFormat in interface java.security.Keypublic byte[] getEncoded()
getEncoded in interface java.security.Keypublic boolean equals(java.lang.Object o)
XMSSMTPrivateKeyParameters.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. BCLMSPrivateKey is this same line over
HSSPrivateKeyParameters, 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 equals
says about two keys getEncoded() 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 does BCMLDSAPrivateKey
over its own parameters' encoding. A caller that does need the encodings to agree should
compare the encodings.
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String getTreeDigest()
getTreeDigest in interface XMSSMTKeypublic void destroy()
The secret key seed, the PRF key and the WOTS+ secrets retained by the per-layer BDS
traversal states are zeroized; the public seed, root, index and tree nodes are retained, so
getIndex(), getUsagesRemaining(), getHeight(),
getLayers() and getTreeDigest() keep working and hashCode() is
stable. 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 hold
their own copies of the seeds and are unaffected. As the underlying
XMSSMTPrivateKeyParameters object is destroyed, keys sharing it are invalidated too.
destroy in interface javax.security.auth.Destroyablepublic boolean isDestroyed()
isDestroyed in interface javax.security.auth.Destroyable