public class KeyAgreementSpi extends BaseAgreementSpi
KeyAgreement.SM9. The protocol is two-round, so it maps onto the
KeyAgreement API's two-phase form:
init with this party's key-exchange user key (from
SM9EncMasterPrivateKey.generateExchangeKeyPair(byte[]))
and an SM9KeyExchangeSpec giving the role and the agreed key length.doPhase(peerUserPublicKey, false) - 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.doPhase(peerEphemeral, true) - the peer's R, then
generateSecret().
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.
kaAlgorithm, kdf, ukmParameters, ukmParametersSalt| Constructor and Description |
|---|
KeyAgreementSpi() |
| Modifier and Type | Method and Description |
|---|---|
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) |
agreementCompleted, checkAgreementCompleted, checkKdfSalt, engineGenerateSecret, engineGenerateSecret, engineGenerateSecret, engineInit, engineInit, getAlgorithm, resetAgreement, trimZeroesprotected void doInitFromKey(java.security.Key key,
java.security.spec.AlgorithmParameterSpec parameterSpec,
java.security.SecureRandom random)
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
doInitFromKey in class BaseAgreementSpijava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionprotected java.security.Key engineDoPhase(java.security.Key key,
boolean lastPhase)
throws java.security.InvalidKeyException,
java.lang.IllegalStateException
engineDoPhase in class javax.crypto.KeyAgreementSpijava.security.InvalidKeyExceptionjava.lang.IllegalStateExceptionprotected byte[] doCalcSecret()
doCalcSecret in class BaseAgreementSpi