For the latest news and information visit The GNU Crypto project

## gnu.crypto.key.dh
Class ElGamalKeyAgreement

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

All Implemented Interfaces:
  IKeyAgreementParty

Direct Known Subclasses:
  ElGamalReceiver, ElGamalSender

public abstract class ElGamalKeyAgreement
extends BaseKeyAgreementParty

The ElGamal key agreement, also known as the half-certified Diffie-Hellman key agreement, is described in the Handbook of Applied Cryptography [HAC] as follows:

- A sends to B a single message allowing one-pass key agreement.
- A obtains an authentic copy of B's public key (p, g, yb), where yb = g**xb.
- A chooses a random integer x, 1 <= x <= p-2, and sends B the message g**x. A computes the shared secret key K as yb**x.
- B computes the same key K on receipt of the previous message as (g**x)**xb.

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

     "In Ephemeral-Static mode, the recipient has a static (and certified)
     key pair, but the sender generates a new key pair for each message
     and sends it using the originatorKey production. If the sender's key
     is freshly generated for each message, the shared secret ZZ will be
     similarly different for each message and partyAInfo MAY be omitted,
     since it serves merely to decouple multiple KEKs generated by the
     same set of pairwise keys. If, however, the same ephemeral sender key
     is used for multiple messages (e.g. it is cached as a performance
     optimization) then a separate partyAInfo MUST be used for each
     message. All implementations of this standard MUST implement
     Ephemeral-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_ELGAMAL_RECIPIENT_PRIVATE_KEY`
`static java.lang.String` `KA_ELGAMAL_RECIPIENT_PUBLIC_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` `ElGamalKeyAgreement()`

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_ELGAMAL_RECIPIENT_PRIVATE_KEY

    public static final java.lang.String KA_ELGAMAL_RECIPIENT_PRIVATE_KEY

See Also:
  Constant Field Values

### KA_ELGAMAL_RECIPIENT_PUBLIC_KEY

    public static final java.lang.String KA_ELGAMAL_RECIPIENT_PUBLIC_KEY

See Also:
  Constant Field Values

### ZZ

    protected java.math.BigInteger ZZ

  The shared secret key.

Constructor Detail

### ElGamalKeyAgreement

    protected ElGamalKeyAgreement()

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.