Class SM9SigUserPrivateKeySpec

java.lang.Object
java.security.spec.EncodedKeySpec
org.bouncycastle.jcajce.spec.SM9SigUserPrivateKeySpec
All Implemented Interfaces:
KeySpec

public class SM9SigUserPrivateKeySpec extends EncodedKeySpec
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 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's getEncoded().
      masterPublicKey - the signature master public key the user key was derived under.
      identity - the user's identity.
  • Method Details