Class SM9KeyExchangeSpec

java.lang.Object
org.bouncycastle.jcajce.spec.SM9KeyExchangeSpec
All Implemented Interfaces:
AlgorithmParameterSpec

public class SM9KeyExchangeSpec extends Object implements AlgorithmParameterSpec
Parameter spec for the SM9 key exchange protocol (GM/T 0044.3-2016) through KeyAgreement.SM9: the two things the protocol needs that the KeyAgreement API has no slot for - which role this party plays, and the length of the agreed key, which is an input to the GM/T 0044.3 key derivation rather than a truncation of its output.

Everything else the exchange needs comes from the key the KeyAgreement is initialised with (this party's key-exchange user key from SM9EncMasterPrivateKey.generateExchangeKeyPair(byte[])) or from the peer's key supplied to doPhase: the master public key and the hid ride on the user key, so this party's ephemeral value is generated inside the provider under its own master key and cannot be mis-bound to another.

The optional GM/T 0044.3 key-confirmation tags S_A / S_B have no channel in the KeyAgreement API; a caller needing them should use the lightweight SM9KeyExchange directly, as KeyAgreement.SM2 callers do for SM2's tags.

  • Constructor Details

    • SM9KeyExchangeSpec

      public SM9KeyExchangeSpec(boolean initiator)
      Base constructor, with the 128-bit key length of the GM/T 0044.5 worked examples.
      Parameters:
      initiator - whether this party is the initiator (user A).
    • SM9KeyExchangeSpec

      public SM9KeyExchangeSpec(boolean initiator, int keyLengthBits)
      Parameters:
      initiator - whether this party is the initiator (user A).
      keyLengthBits - the length of the agreed key in bits.
  • Method Details

    • isInitiator

      public boolean isInitiator()
    • getKeyLengthBits

      public int getKeyLengthBits()
      The agreed key length in bits - an input to the GM/T 0044.3 key derivation.