Package org.bouncycastle.jcajce.spec
Class SM9SigUserPrivateKeySpec
- java.lang.Object
-
- java.security.spec.EncodedKeySpec
-
- org.bouncycastle.jcajce.spec.SM9SigUserPrivateKeySpec
-
- All Implemented Interfaces:
java.security.spec.KeySpec
public class SM9SigUserPrivateKeySpec extends java.security.spec.EncodedKeySpecKey spec for rebuilding a user's SM9 signature private key (ds_A, GM/T 0044.2) from its PKCS#8 encoding throughKeyFactory.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
EncodedKeySpecrather thanPKCS8EncodedKeySpec: the encoded bytes are a real PKCS#8 encoding (reflected ingetFormat()), 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
getKeySpecmethod, so a user key round-trips: storegetEncoded()(or ask for this spec), rebuild withgeneratePrivate. The verification side needs no spec - a user's public key is derived from the master public key and the identity viaSM9SigMasterPublicKey.getUserPublicKey(byte[]).
-
-
Constructor Summary
Constructors Constructor Description SM9SigUserPrivateKeySpec(byte[] pkcs8Encoding, SM9SigMasterPublicKey masterPublicKey, byte[] identity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetFormat()byte[]getIdentity()SM9SigMasterPublicKeygetMasterPublicKey()
-
-
-
Constructor Detail
-
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 Detail
-
getMasterPublicKey
public SM9SigMasterPublicKey getMasterPublicKey()
-
getIdentity
public byte[] getIdentity()
-
getFormat
public java.lang.String getFormat()
- Specified by:
getFormatin classjava.security.spec.EncodedKeySpec
-
-