Bouncy Castle Cryptography Library 1.87

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

java.lang.Object
  extended byjavax.crypto.KeyGeneratorSpi
      extended byorg.bouncycastle.jcajce.provider.asymmetric.sm9.SM9KEMKeyGeneratorSpi

public class SM9KEMKeyGeneratorSpi
extends javax.crypto.KeyGeneratorSpi

JCA bridge for the SM9 key encapsulation mechanism (GM/T 0044.4-2016). Registered as ; initialise with: a KEMGenerateSpec to encapsulate - its must be the recipient's SM9EncUserPublicKey, from SM9EncMasterPublicKey.getUserPublicKey(byte[]); or a KEMExtractSpec to decapsulate - its must be the recipient's SM9EncUserPrivateKey, the KEM / decryption key from the KGC. The requested key length (the spec's ) 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 API, , with a KTSParameterSpec KDF). A spec that asks for something this cannot honour - a KDF other than the specs' default, or any otherInfo - is refused rather than quietly served as if it had not asked. returns a SecretKeyWithEncapsulation.

Usage warning: an identity's key should be used for this service or for , but not for both. A deployment needing both has its KGC publish a separate hid for each function, as it already does for the key exchange, so that the two keys are distinct. also refuses for decapsulation a key declared for decryption, and one that has been used for it - see SM9EncPrivateKeyParameters.recordUsage(int).


Constructor Summary
SM9KEMKeyGeneratorSpi()
           
 
Method Summary
protected  javax.crypto.SecretKey engineGenerateKey()
           
protected  void engineInit(java.security.spec.AlgorithmParameterSpec spec, java.security.SecureRandom random)
           
protected  void engineInit(int keySize, java.security.SecureRandom random)
           
protected  void engineInit(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)

engineInit

protected void engineInit(int keySize,
                          java.security.SecureRandom random)

engineInit

protected void engineInit(java.security.spec.AlgorithmParameterSpec spec,
                          java.security.SecureRandom random)
                   throws java.security.InvalidAlgorithmParameterException
Throws:
java.security.InvalidAlgorithmParameterException

engineGenerateKey

protected javax.crypto.SecretKey engineGenerateKey()

Bouncy Castle Cryptography Library 1.87