public class SM9KeyExchangeSpec
extends java.lang.Object
implements java.security.spec.AlgorithmParameterSpec
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 and Description |
|---|
SM9KeyExchangeSpec(boolean initiator)
Base constructor, with the 128-bit key length of the GM/T 0044.5 worked
examples.
|
SM9KeyExchangeSpec(boolean initiator,
int keyLengthBits) |
| Modifier and Type | Method and Description |
|---|---|
int |
getKeyLengthBits()
The agreed key length in bits - an input to the GM/T 0044.3 key derivation.
|
boolean |
isInitiator() |
public SM9KeyExchangeSpec(boolean initiator)
initiator - whether this party is the initiator (user A).public SM9KeyExchangeSpec(boolean initiator,
int keyLengthBits)
initiator - whether this party is the initiator (user A).keyLengthBits - the length of the agreed key in bits, a positive whole number of
bytes - the key is handed back as bytes, and KEM.SM9-KEM takes the same
rule, so the two services no longer round a fractional-byte request in
opposite directions.