For the latest news and information visit The GNU Crypto project

## gnu.crypto.key.dh
Class DiffieHellmanKeyAgreement

    java.lang.Object
      |
      +--gnu.crypto.key.BaseKeyAgreementParty
            |
            +--gnu.crypto.key.dh.DiffieHellmanKeyAgreement

All Implemented Interfaces:
  IKeyAgreementParty

Direct Known Subclasses:
  DiffieHellmanReceiver, DiffieHellmanSender

public abstract class DiffieHellmanKeyAgreement
extends BaseKeyAgreementParty

The basic version of the Diffie-Hellman key agreement is described in the Handbook of Applied Cryptography [HAC] as follows:

- An appropriate prime p and generator g of Zp* (2 <= g <= p-2) are selected and published.
- A and B each send the other one message over an open channel; as a result, they both can then compute a shared secret key K which they can use to protect their future communication.
- A chooses a random secret x, 1 <= x <= p-2, and sends B message (1) which is g^x mod p.
- B chooses a random secret y, 1 <= y <= p-2, and sends A message (2) which is g^y mod p.
- B receives message (1) and computes the shared key as K = (g^x)^y mod p.
- A receives message (2) and computes the shared key as K = (g^y)^x mod p.

RFC-2631 describes a Static-Static Mode of operations with Diffie-Hellman keypairs as follows:

     "In Static-Static mode, both the sender and the recipient have a
       static (and certified) key pair. Since the sender's and recipient's
       keys are therefore the same for each message, ZZ will be the same for
       each message. Thus, partyAInfo MUST be used (and different for each
       message) in order to ensure that different messages use different
       KEKs. Implementations MAY implement Static-Static mode."

Reference:

1. Diffie-Hellman Key Agreement Method
   Eric Rescorla.
2. [HAC]: Handbook of Applied Cryptography.
   CRC Press, Inc. ISBN 0-8493-8523-7, 1997
   Menezes, A., van Oorschot, P. and S. Vanstone.

Field Summary
`static java.lang.String` `KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY`
`protected DHPrivateKey` `ownerKey` The key agreement party's private key.
`static java.lang.String` `SOURCE_OF_RANDOMNESS`
`protected java.math.BigInteger` `ZZ` The shared secret key.

Fields inherited from class gnu.crypto.key.BaseKeyAgreementParty
`complete, initialised, irnd, name, rnd, step, TWO`

Constructor Summary
`protected` `DiffieHellmanKeyAgreement()`

Method Summary
`protected void` `engineReset()`
`protected byte[]` `engineSharedSecret()`

Methods inherited from class gnu.crypto.key.BaseKeyAgreementParty
`engineInit, engineProcessMessage, getSharedSecret, init, isComplete, name, nextRandomBytes, processMessage, reset`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SOURCE_OF_RANDOMNESS

    public static final java.lang.String SOURCE_OF_RANDOMNESS

See Also:
  Constant Field Values

### KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY

    public static final java.lang.String KA_DIFFIE_HELLMAN_OWNER_PRIVATE_KEY

See Also:
  Constant Field Values

### ownerKey

    protected DHPrivateKey ownerKey

  The key agreement party's private key.

### ZZ

    protected java.math.BigInteger ZZ

  The shared secret key.

Constructor Detail

### DiffieHellmanKeyAgreement

    protected DiffieHellmanKeyAgreement()

Method Detail

### engineSharedSecret

    protected byte[] engineSharedSecret()
                                 throws KeyAgreementException

  Specified by:
    `engineSharedSecret` in class `BaseKeyAgreementParty`
    `KeyAgreementException`

### engineReset

    protected void engineReset()

  Specified by:
    `engineReset` in class `BaseKeyAgreementParty`

For the latest news and information visit The GNU Crypto project

Copyright © 2001, 2002, 2003, 2004 Free Software Foundation, Inc.