Class KeyAgreementSpi
java.lang.Object
javax.crypto.KeyAgreementSpi
org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi
org.bouncycastle.jcajce.provider.asymmetric.sm9.KeyAgreementSpi
JCA adapter for the SM9 key exchange protocol (GM/T 0044.3-2016), registered as
KeyAgreement.SM9. The protocol is two-round, so it maps onto the
KeyAgreement API's two-phase form:
initwith this party's key-exchange user key (fromSM9EncMasterPrivateKey.generateExchangeKeyPair(byte[])) and anSM9KeyExchangeSpecgiving the role and the agreed key length.doPhase(peerUserPublicKey, false)- names the peer and returns this party's ephemeral value R, whoseKey.getEncoded()is the 64-byte x || y form to send. The ephemeral is generated here, inside the provider, under the master public key carried on this party's own user key, so it cannot be mis-bound to a different master key.doPhase(peerEphemeral, true)- the peer's R, thengenerateSecret().
The optional GM/T 0044.3 key-confirmation tags S_A / S_B have no channel in
this API and are available from the lightweight
SM9KeyExchange only - the same
position KeyAgreement.SM2 takes for SM2's confirmation tags.
-
Field Summary
Fields inherited from class BaseAgreementSpi
kaAlgorithm, kdf, ukmParameters, ukmParametersSalt -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]protected voiddoInitFromKey(Key key, AlgorithmParameterSpec parameterSpec, SecureRandom random) protected KeyengineDoPhase(Key key, boolean lastPhase) Methods inherited from class BaseAgreementSpi
engineGenerateSecret, engineGenerateSecret, engineGenerateSecret, engineInit, engineInit, getAlgorithm, trimZeroes
-
Constructor Details
-
KeyAgreementSpi
public KeyAgreementSpi()
-
-
Method Details
-
doInitFromKey
protected void doInitFromKey(Key key, AlgorithmParameterSpec parameterSpec, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException - Specified by:
doInitFromKeyin classBaseAgreementSpi- Throws:
InvalidKeyExceptionInvalidAlgorithmParameterException
-
engineDoPhase
protected Key engineDoPhase(Key key, boolean lastPhase) throws InvalidKeyException, IllegalStateException - Specified by:
engineDoPhasein classKeyAgreementSpi- Throws:
InvalidKeyExceptionIllegalStateException
-
doCalcSecret
protected byte[] doCalcSecret()- Specified by:
doCalcSecretin classBaseAgreementSpi
-