Bouncy Castle Cryptography Library 1.87

org.bouncycastle.jcajce.provider.asymmetric.sm9
Class KeyFactorySpi

java.lang.Object
  extended byjava.security.KeyFactorySpi
      extended byorg.bouncycastle.jcajce.provider.asymmetric.sm9.KeyFactorySpi
All Implemented Interfaces:
AsymmetricKeyInfoConverter

public class KeyFactorySpi
extends java.security.KeyFactorySpi
implements AsymmetricKeyInfoConverter

KeyFactory for the SM9 master keys ( and ): the master public and private keys round-trip through their JCA X.509 / PKCS#8 encodings (the GM/T 0080-2020 key material under the GM algorithm OID; the bare GM/T 0080-2020 form is the lightweight key-parameter class's ).

A user's identity-based key is not decodable in isolation - it additionally needs the master public key and the identity, and for an encryption key the hid and the usage (KEM / decryption or key exchange) too - so it does not decode from a plain PKCS#8 spec, and hands out no such spec for one. Rebuild a stored user key from its encoding plus that context with an SM9SigUserPrivateKeySpec / SM9EncUserPrivateKeySpec (also handed back by ), or derive it afresh from the master private key via the master key's method.


Constructor Summary
KeyFactorySpi()
           
 
Method Summary
protected  java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec)
           
protected  java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec)
           
protected  java.security.spec.KeySpec engineGetKeySpec(java.security.Key key, java.lang.Class keySpec)
           
protected  java.security.Key engineTranslateKey(java.security.Key key)
           
 java.security.PrivateKey generatePrivate(PrivateKeyInfo keyInfo)
           
 java.security.PublicKey generatePublic(SubjectPublicKeyInfo keyInfo)
          The AsymmetricKeyInfoConverter half, registered against both SM9 algorithm identifiers so that and any other generic BC path that resolves a key by its OID answer for SM9 rather than returning null, as they did before.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyFactorySpi

public KeyFactorySpi()
Method Detail

generatePublic

public java.security.PublicKey generatePublic(SubjectPublicKeyInfo keyInfo)
                                       throws java.io.IOException
The AsymmetricKeyInfoConverter half, registered against both SM9 algorithm identifiers so that and any other generic BC path that resolves a key by its OID answer for SM9 rather than returning null, as they did before. Only the master keys decode from an encoding alone; a user's identity-based key additionally needs the master public key, the identity and, for an encryption key, the hid, none of which the encoding carries, so it is reported as undecodable here and the spec-taking path remains the way to rebuild one.

Specified by:
generatePublic in interface AsymmetricKeyInfoConverter
Throws:
java.io.IOException

generatePrivate

public java.security.PrivateKey generatePrivate(PrivateKeyInfo keyInfo)
                                         throws java.io.IOException
Specified by:
generatePrivate in interface AsymmetricKeyInfoConverter
Throws:
java.io.IOException

engineGeneratePublic

protected java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec)
                                                throws java.security.spec.InvalidKeySpecException
Throws:
java.security.spec.InvalidKeySpecException

engineGeneratePrivate

protected java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec)
                                                  throws java.security.spec.InvalidKeySpecException
Throws:
java.security.spec.InvalidKeySpecException

engineGetKeySpec

protected java.security.spec.KeySpec engineGetKeySpec(java.security.Key key,
                                                      java.lang.Class keySpec)
                                               throws java.security.spec.InvalidKeySpecException
Throws:
java.security.spec.InvalidKeySpecException

engineTranslateKey

protected java.security.Key engineTranslateKey(java.security.Key key)
                                        throws java.security.InvalidKeyException
Throws:
java.security.InvalidKeyException

Bouncy Castle Cryptography Library 1.87