public class KeyFactorySpi extends java.security.KeyFactorySpi implements AsymmetricKeyInfoConverter
sm9sign and sm9encrypt): 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 getEncoded()).
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
getKeySpec 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
getKeySpec), or derive it afresh from the master private key via the master
key's generateUserKeyPair method.
| Constructor and Description |
|---|
KeyFactorySpi() |
| Modifier and Type | Method and Description |
|---|---|
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 BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo) and
any other generic BC path that resolves a key by its OID answer for SM9 rather than
returning null, as they did before. |
public java.security.PublicKey generatePublic(SubjectPublicKeyInfo keyInfo) throws java.io.IOException
AsymmetricKeyInfoConverter half, registered against both SM9 algorithm
identifiers so that BouncyCastleProvider.getPublicKey(SubjectPublicKeyInfo) 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 KeyFactory.SM9 path remains the way to
rebuild one.generatePublic in interface AsymmetricKeyInfoConverterjava.io.IOExceptionpublic java.security.PrivateKey generatePrivate(PrivateKeyInfo keyInfo) throws java.io.IOException
generatePrivate in interface AsymmetricKeyInfoConverterjava.io.IOExceptionprotected java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
engineGeneratePublic in class java.security.KeyFactorySpijava.security.spec.InvalidKeySpecExceptionprotected java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
engineGeneratePrivate in class java.security.KeyFactorySpijava.security.spec.InvalidKeySpecExceptionprotected java.security.spec.KeySpec engineGetKeySpec(java.security.Key key,
java.lang.Class keySpec)
throws java.security.spec.InvalidKeySpecException
engineGetKeySpec in class java.security.KeyFactorySpijava.security.spec.InvalidKeySpecExceptionprotected java.security.Key engineTranslateKey(java.security.Key key)
throws java.security.InvalidKeyException
engineTranslateKey in class java.security.KeyFactorySpijava.security.InvalidKeyException