Class SM9KEMKeyGeneratorSpi


  • public class SM9KEMKeyGeneratorSpi
    extends javax.crypto.KeyGeneratorSpi
    JCA KeyGenerator bridge for the SM9 key encapsulation mechanism (GM/T 0044.4-2016). Registered as KeyGenerator.SM9-KEM; initialise with:
    • a KEMGenerateSpec to encapsulate - its PublicKey must be a BCSM9EncPublicKey (the recipient's master public key + identity); or
    • a KEMExtractSpec to decapsulate - its PrivateKey must be a BCSM9EncPrivateKey (the recipient's extracted decryption key).
    The requested key length (the spec's keySizeInBits) drives SM9's own GM/T 0044.4 KDF, which produces the shared key directly; the spec's generic KDF fields are therefore not applied (an external KDF on top would break interoperability with other GM/T 0044.4 implementations - callers who want one anyway can layer it via the javax.crypto.KEM API, KEM.SM9-KEM, with a KTSParameterSpec KDF). engineGenerateKey returns a SecretKeyWithEncapsulation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected javax.crypto.SecretKey engineGenerateKey()  
      protected void engineInit​(int keySize, java.security.SecureRandom random)  
      protected void engineInit​(java.security.SecureRandom random)  
      protected void engineInit​(java.security.spec.AlgorithmParameterSpec spec, java.security.SecureRandom random)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SM9KEMKeyGeneratorSpi

        public SM9KEMKeyGeneratorSpi()
    • Method Detail

      • engineInit

        protected void engineInit​(java.security.SecureRandom random)
        Specified by:
        engineInit in class javax.crypto.KeyGeneratorSpi
      • engineInit

        protected void engineInit​(int keySize,
                                  java.security.SecureRandom random)
        Specified by:
        engineInit in class javax.crypto.KeyGeneratorSpi
      • engineInit

        protected void engineInit​(java.security.spec.AlgorithmParameterSpec spec,
                                  java.security.SecureRandom random)
                           throws java.security.InvalidAlgorithmParameterException
        Specified by:
        engineInit in class javax.crypto.KeyGeneratorSpi
        Throws:
        java.security.InvalidAlgorithmParameterException
      • engineGenerateKey

        protected javax.crypto.SecretKey engineGenerateKey()
        Specified by:
        engineGenerateKey in class javax.crypto.KeyGeneratorSpi