Class KeyAgreementSpi
- java.lang.Object
-
- javax.crypto.KeyAgreementSpi
-
- org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi
-
- org.bouncycastle.jcajce.provider.asymmetric.sm9.KeyAgreementSpi
-
public class KeyAgreementSpi extends BaseAgreementSpi
JCA adapter for the SM9 key exchange protocol (GM/T 0044.3-2016), registered asKeyAgreement.SM9. The protocol is two-round, so it maps onto theKeyAgreementAPI'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
SM9KeyExchangeonly - the same positionKeyAgreement.SM2takes for SM2's confirmation tags.
-
-
Field Summary
-
Fields inherited from class org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi
kaAlgorithm, kdf, ukmParameters, ukmParametersSalt
-
-
Constructor Summary
Constructors Constructor Description KeyAgreementSpi()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]doCalcSecret()protected voiddoInitFromKey(java.security.Key key, java.security.spec.AlgorithmParameterSpec parameterSpec, java.security.SecureRandom random)protected java.security.KeyengineDoPhase(java.security.Key key, boolean lastPhase)-
Methods inherited from class org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi
engineGenerateSecret, engineGenerateSecret, engineGenerateSecret, engineInit, engineInit, getAlgorithm, trimZeroes
-
-
-
-
Method Detail
-
doInitFromKey
protected void doInitFromKey(java.security.Key key, java.security.spec.AlgorithmParameterSpec parameterSpec, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException- Specified by:
doInitFromKeyin classBaseAgreementSpi- Throws:
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterException
-
engineDoPhase
protected java.security.Key engineDoPhase(java.security.Key key, boolean lastPhase) throws java.security.InvalidKeyException, java.lang.IllegalStateException- Specified by:
engineDoPhasein classjavax.crypto.KeyAgreementSpi- Throws:
java.security.InvalidKeyExceptionjava.lang.IllegalStateException
-
doCalcSecret
protected byte[] doCalcSecret()
- Specified by:
doCalcSecretin classBaseAgreementSpi
-
-