public class BCXMSSPrivateKey extends java.lang.Object implements java.security.PrivateKey, XMSSPrivateKey, javax.security.auth.Destroyable
| Constructor and Description |
|---|
BCXMSSPrivateKey(ASN1ObjectIdentifier treeDigest,
XMSSPrivateKeyParameters keyParams) |
BCXMSSPrivateKey(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
XMSSPrivateKeyParameters.equals(Object)
decides, this being the line that asks it. |
XMSSPrivateKey |
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.
|
java.lang.String |
getTreeDigest() |
long |
getUsagesRemaining()
Return the number of usages left for the private key.
|
int |
hashCode() |
boolean |
isDestroyed() |
public BCXMSSPrivateKey(ASN1ObjectIdentifier treeDigest, XMSSPrivateKeyParameters keyParams)
public BCXMSSPrivateKey(PrivateKeyInfo keyInfo) throws java.io.IOException
java.io.IOExceptionpublic long getIndex()
XMSSPrivateKeygetIndex in interface XMSSPrivateKeypublic long getUsagesRemaining()
XMSSPrivateKeygetUsagesRemaining in interface XMSSPrivateKeypublic XMSSPrivateKey extractKeyShard(int usageCount)
XMSSPrivateKeyNote: this will use the range [index...index + usageCount) for the current key.
extractKeyShard in interface XMSSPrivateKeyusageCount - 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)
XMSSPrivateKeyParameters.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 XMSSKeypublic void destroy()
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() 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 XMSSPrivateKeyParameters 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