org.bouncycastle.jcajce.provider.asymmetric.sm9
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 as
. The protocol is two-round, so it maps onto the
API's two-phase form:
with this party's key-exchange user key (from
SM9EncMasterPrivateKey.generateExchangeKeyPair(byte[]))
and an SM9KeyExchangeSpec giving the role and the agreed key length.
- names the peer and returns
this party's ephemeral value R, whose Key.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.
- the peer's R, then
.
The peer's user public key is checked to carry the same hid and master public
key as this party's own key; the peer's identity is taken from it, so the peer
is named exactly once.
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 takes for SM2's confirmation tags.
|
Method Summary |
protected byte[] |
doCalcSecret()
|
protected void |
doInitFromKey(java.security.Key key,
java.security.spec.AlgorithmParameterSpec parameterSpec,
java.security.SecureRandom random)
|
protected java.security.Key |
engineDoPhase(java.security.Key key,
boolean lastPhase)
|
| Methods inherited from class org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi |
agreementCompleted, checkAgreementCompleted, checkKdfSalt, engineGenerateSecret, engineGenerateSecret, engineGenerateSecret, engineInit, engineInit, getAlgorithm, resetAgreement, trimZeroes |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KeyAgreementSpi
public KeyAgreementSpi()
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:
doInitFromKey in class BaseAgreementSpi
- Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
engineDoPhase
protected java.security.Key engineDoPhase(java.security.Key key,
boolean lastPhase)
throws java.security.InvalidKeyException,
java.lang.IllegalStateException
- Throws:
java.security.InvalidKeyException
java.lang.IllegalStateException
doCalcSecret
protected byte[] doCalcSecret()
- Specified by:
doCalcSecret in class BaseAgreementSpi