Bouncy Castle Cryptography Library 1.77.0

org.bouncycastle.jcajce.provider.asymmetric.dh
Class KeyAgreementSpi

java.lang.Object
  |
  +--javax.crypto.KeyAgreementSpi
        |
        +--org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi
              |
              +--org.bouncycastle.jcajce.provider.asymmetric.dh.KeyAgreementSpi
Direct Known Subclasses:
KeyAgreementSpi.DHUwithSHA1CKDF, KeyAgreementSpi.DHUwithSHA1KDF, KeyAgreementSpi.DHUwithSHA224CKDF, KeyAgreementSpi.DHUwithSHA224KDF, KeyAgreementSpi.DHUwithSHA256CKDF, KeyAgreementSpi.DHUwithSHA256KDF, KeyAgreementSpi.DHUwithSHA384CKDF, KeyAgreementSpi.DHUwithSHA384KDF, KeyAgreementSpi.DHUwithSHA512CKDF, KeyAgreementSpi.DHUwithSHA512KDF, KeyAgreementSpi.DHwithRFC2631KDF, KeyAgreementSpi.DHwithSHA1CKDF, KeyAgreementSpi.DHwithSHA1KDF, KeyAgreementSpi.DHwithSHA224CKDF, KeyAgreementSpi.DHwithSHA224KDF, KeyAgreementSpi.DHwithSHA256CKDF, KeyAgreementSpi.DHwithSHA256KDF, KeyAgreementSpi.DHwithSHA384CKDF, KeyAgreementSpi.DHwithSHA384KDF, KeyAgreementSpi.DHwithSHA512CKDF, KeyAgreementSpi.DHwithSHA512KDF, KeyAgreementSpi.MQVwithSHA1CKDF, KeyAgreementSpi.MQVwithSHA1KDF, KeyAgreementSpi.MQVwithSHA224CKDF, KeyAgreementSpi.MQVwithSHA224KDF, KeyAgreementSpi.MQVwithSHA256CKDF, KeyAgreementSpi.MQVwithSHA256KDF, KeyAgreementSpi.MQVwithSHA384CKDF, KeyAgreementSpi.MQVwithSHA384KDF, KeyAgreementSpi.MQVwithSHA512CKDF, KeyAgreementSpi.MQVwithSHA512KDF

public class KeyAgreementSpi
extends BaseAgreementSpi

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.


Inner Class Summary
static class KeyAgreementSpi.DHUwithSHA1CKDF
           
static class KeyAgreementSpi.DHUwithSHA1KDF
           
static class KeyAgreementSpi.DHUwithSHA224CKDF
           
static class KeyAgreementSpi.DHUwithSHA224KDF
           
static class KeyAgreementSpi.DHUwithSHA256CKDF
           
static class KeyAgreementSpi.DHUwithSHA256KDF
           
static class KeyAgreementSpi.DHUwithSHA384CKDF
           
static class KeyAgreementSpi.DHUwithSHA384KDF
           
static class KeyAgreementSpi.DHUwithSHA512CKDF
           
static class KeyAgreementSpi.DHUwithSHA512KDF
           
static class KeyAgreementSpi.DHwithRFC2631KDF
           
static class KeyAgreementSpi.DHwithSHA1CKDF
           
static class KeyAgreementSpi.DHwithSHA1KDF
           
static class KeyAgreementSpi.DHwithSHA224CKDF
           
static class KeyAgreementSpi.DHwithSHA224KDF
           
static class KeyAgreementSpi.DHwithSHA256CKDF
           
static class KeyAgreementSpi.DHwithSHA256KDF
           
static class KeyAgreementSpi.DHwithSHA384CKDF
           
static class KeyAgreementSpi.DHwithSHA384KDF
           
static class KeyAgreementSpi.DHwithSHA512CKDF
           
static class KeyAgreementSpi.DHwithSHA512KDF
           
static class KeyAgreementSpi.MQVwithSHA1CKDF
           
static class KeyAgreementSpi.MQVwithSHA1KDF
           
static class KeyAgreementSpi.MQVwithSHA224CKDF
           
static class KeyAgreementSpi.MQVwithSHA224KDF
           
static class KeyAgreementSpi.MQVwithSHA256CKDF
           
static class KeyAgreementSpi.MQVwithSHA256KDF
           
static class KeyAgreementSpi.MQVwithSHA384CKDF
           
static class KeyAgreementSpi.MQVwithSHA384KDF
           
static class KeyAgreementSpi.MQVwithSHA512CKDF
           
static class KeyAgreementSpi.MQVwithSHA512KDF
           
 
Fields inherited from class org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi
kaAlgorithm, kdf, ukmParameters
 
Constructor Summary
KeyAgreementSpi()
           
KeyAgreementSpi(java.lang.String kaAlgorithm, BasicAgreement mqvAgreement, DerivationFunction kdf)
           
KeyAgreementSpi(java.lang.String kaAlgorithm, DerivationFunction kdf)
           
KeyAgreementSpi(java.lang.String kaAlgorithm, DHUnifiedAgreement unifiedAgreement, DerivationFunction kdf)
           
 
Method Summary
protected  byte[] bigIntToBytes(java.math.BigInteger r)
           
protected  byte[] doCalcSecret()
           
protected  void doInitFromKey(java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)
           
protected  java.security.Key engineDoPhase(java.security.Key key, boolean lastPhase)
           
protected  byte[] engineGenerateSecret()
           
protected  int engineGenerateSecret(byte[] sharedSecret, int offset)
           
protected  javax.crypto.SecretKey engineGenerateSecret(java.lang.String algorithm)
           
protected  void engineInit(java.security.Key key, java.security.SecureRandom random)
           
 
Methods inherited from class org.bouncycastle.jcajce.provider.asymmetric.util.BaseAgreementSpi
engineInit, getAlgorithm, getKeySize, trimZeroes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyAgreementSpi

public KeyAgreementSpi()

KeyAgreementSpi

public KeyAgreementSpi(java.lang.String kaAlgorithm,
                       DerivationFunction kdf)

KeyAgreementSpi

public KeyAgreementSpi(java.lang.String kaAlgorithm,
                       DHUnifiedAgreement unifiedAgreement,
                       DerivationFunction kdf)

KeyAgreementSpi

public KeyAgreementSpi(java.lang.String kaAlgorithm,
                       BasicAgreement mqvAgreement,
                       DerivationFunction kdf)
Method Detail

bigIntToBytes

protected byte[] bigIntToBytes(java.math.BigInteger r)

engineDoPhase

protected java.security.Key engineDoPhase(java.security.Key key,
                                          boolean lastPhase)
                                   throws java.security.InvalidKeyException,
                                          java.lang.IllegalStateException
Overrides:
engineDoPhase in class javax.crypto.KeyAgreementSpi

engineGenerateSecret

protected byte[] engineGenerateSecret()
                               throws java.lang.IllegalStateException
Overrides:
engineGenerateSecret in class BaseAgreementSpi

engineGenerateSecret

protected int engineGenerateSecret(byte[] sharedSecret,
                                   int offset)
                            throws java.lang.IllegalStateException,
                                   javax.crypto.ShortBufferException
Overrides:
engineGenerateSecret in class BaseAgreementSpi

engineGenerateSecret

protected javax.crypto.SecretKey engineGenerateSecret(java.lang.String algorithm)
                                               throws java.security.NoSuchAlgorithmException
Overrides:
engineGenerateSecret in class BaseAgreementSpi

doInitFromKey

protected void doInitFromKey(java.security.Key key,
                             java.security.spec.AlgorithmParameterSpec params,
                             java.security.SecureRandom random)
                      throws java.security.InvalidKeyException,
                             java.security.InvalidAlgorithmParameterException
Overrides:
doInitFromKey in class BaseAgreementSpi

engineInit

protected void engineInit(java.security.Key key,
                          java.security.SecureRandom random)
                   throws java.security.InvalidKeyException
Overrides:
engineInit in class BaseAgreementSpi

doCalcSecret

protected byte[] doCalcSecret()
Overrides:
doCalcSecret in class BaseAgreementSpi

Bouncy Castle Cryptography Library 1.77.0