Class SM9SigUserPrivateKeySpec
java.lang.Object
java.security.spec.EncodedKeySpec
org.bouncycastle.jcajce.spec.SM9SigUserPrivateKeySpec
- All Implemented Interfaces:
KeySpec
Key spec for rebuilding a user's SM9 signature private key (ds_A, GM/T 0044.2)
from its PKCS#8 encoding through
KeyFactory.SM9. The encoding alone does
not determine a usable key - the signer also needs the signature master public
key and the identity, neither of which is part of it - so the spec carries all
three, letting a stored user key be reconstituted without access to the master
private key.
This extends EncodedKeySpec rather than PKCS8EncodedKeySpec:
the encoded bytes are a real PKCS#8 encoding (reflected in getFormat()), but the
spec is not self-sufficient the way a plain PKCS8EncodedKeySpec is meant to be, and
subclassing the concrete JDK type would let generic code treat it as one.
The matching spec is returned by the factory's getKeySpec method, so a
user key round-trips: store getEncoded() (or ask for this spec), rebuild
with generatePrivate. The verification side needs no spec - a user's
public key is derived from the master public key and the identity via
SM9SigMasterPublicKey.getUserPublicKey(byte[]).
-
Constructor Summary
ConstructorsConstructorDescriptionSM9SigUserPrivateKeySpec(byte[] pkcs8Encoding, SM9SigMasterPublicKey masterPublicKey, byte[] identity) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Methods inherited from class EncodedKeySpec
getAlgorithm, getEncoded
-
Constructor Details
-
SM9SigUserPrivateKeySpec
public SM9SigUserPrivateKeySpec(byte[] pkcs8Encoding, SM9SigMasterPublicKey masterPublicKey, byte[] identity) - Parameters:
pkcs8Encoding- the user private key's PKCS#8 encoding, as returned by the key'sgetEncoded().masterPublicKey- the signature master public key the user key was derived under.identity- the user's identity.
-
-
Method Details
-
getMasterPublicKey
-
getIdentity
public byte[] getIdentity() -
getFormat
- Specified by:
getFormatin classEncodedKeySpec
-