Top Description Inners Fields Constructors Methods
org.bouncycastle.jcajce.provider.asymmetric.dh

public Class KeyAgreementSpi

extends BaseAgreementSpi
Class Inheritance
Known Direct Subclasses
org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithRFC2631KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA1KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA224KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA256KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA384KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA512KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA1CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA224CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA256CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA384CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHwithSHA512CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA1KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA224KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA256KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA384KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA512KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA1CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA224CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA256CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA384CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.DHUwithSHA512CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA1KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA224KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA256KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA384KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA512KDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA1CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA224CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA256CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA384CKDF, org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi.MQVwithSHA512CKDF
Imports
java.math.BigInteger, java.security.InvalidAlgorithmParameterException, .InvalidKeyException, .Key, .NoSuchAlgorithmException, .PrivateKey, .PublicKey, .SecureRandom, java.security.spec.AlgorithmParameterSpec, javax.crypto.SecretKey, .ShortBufferException, javax.crypto.interfaces.DHPrivateKey, .DHPublicKey, javax.crypto.spec.DHParameterSpec, .SecretKeySpec, org.bouncycastle.crypto.BasicAgreement, .DerivationFunction, org.bouncycastle.crypto.agreement.DHUnifiedAgreement, .MQVBasicAgreement, org.bouncycastle.crypto.agreement.kdf.ConcatenationKDFGenerator, .DHKEKGenerator, org.bouncycastle.crypto.generators.KDF2BytesGenerator, org.bouncycastle.crypto.params.DHMQVPrivateParameters, .DHMQVPublicParameters, .DHParameters, .DHPrivateKeyParameters, .DHPublicKeyParameters, .DHUPrivateParameters, .DHUPublicParameters, org.bouncycastle.crypto.util.DigestFactory, org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi, org.bouncycastle.jcajce.spec.DHDomainParameterSpec, .DHUParameterSpec, .MQVParameterSpec, .UserKeyingMaterialSpec, org.bouncycastle.util.BigIntegers

Diffie-Hellman key agreement. There's actually a better way of doing this if you are using long term public keys, see the light-weight version for details.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class
public static class

Field Summary

Modifier and TypeField and Description
private DHUParameterSpec
private BigInteger
g

private final BasicAgreement
private MQVParameterSpec
private static final BigInteger
private BigInteger
p

private byte[]
private static final BigInteger
private final DHUnifiedAgreement
private BigInteger
x

Inherited from org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi:
kaAlgorithmkdfukmParameters

Constructor Summary

AccessConstructor and Description
public
public
public
KeyAgreementSpi(String kaAlgorithm, DHUnifiedAgreement unifiedAgreement, DerivationFunction kdf)

public
KeyAgreementSpi(String kaAlgorithm, BasicAgreement mqvAgreement, DerivationFunction kdf)

Method Summary

Modifier and TypeMethod and Description
protected byte[]
protected byte[]
protected void
protected Key
engineDoPhase(Key
the key for this phase. For example, in the case of Diffie-Hellman between 2 parties, this would be the other party's Diffie-Hellman public key.
key
,
boolean
flag which indicates whether this is the last phase of this key agreement.
lastPhase
)

Implements abstract javax.crypto.KeyAgreementSpi.engineDoPhase.

Executes the next phase of this key agreement with the given key that was received from one of the other parties involved in this key agreement.
protected byte[]
engineGenerateSecret()

Overrides org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi.engineGenerateSecret.

Generates the shared secret and returns it in a new buffer.
protected int
engineGenerateSecret(byte[]
the buffer for the shared secret
sharedSecret
,
int
the offset in sharedSecret where the shared secret will be stored
offset
)

Overrides org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi.engineGenerateSecret.

Generates the shared secret, and places it into the buffer sharedSecret, beginning at offset inclusive.
protected SecretKey
engineGenerateSecret(String
the requested secret key algorithm
algorithm
)

Overrides org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi.engineGenerateSecret.

Creates the shared secret and returns it as a secret key object of the requested algorithm type.
protected void
engineInit(Key
the party's private information. For example, in the case of the Diffie-Hellman key agreement, this would be the party's own Diffie-Hellman private key.
key
,
SecureRandom
the source of randomness
random
)

Overrides org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi.engineInit.

Initializes this key agreement with the given key and source of randomness.
private DHPrivateKeyParameters
private DHPublicKeyParameters
Inherited from org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi:
engineInitgetAlgorithmgetKeySizetrimZeroes