Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cryptix.provider.elgamal
Class RawElGamalCipher

    java.lang.Object
      |
      +--xjava.security.IJCE_Traceable
            |
            +--xjava.security.Cipher
                  |
                  +--cryptix.provider.elgamal.RawElGamalCipher

public class RawElGamalCipher
extends Cipher
implements AsymmetricCipher, java.lang.Cloneable

The raw ElGamal encryption algorithm.

References:

1. Bruce Schneier, "Section 19.6 ElGamal," Applied Cryptography, 2nd edition, John Wiley & Sons, 1996.

Copyright © 1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.3 $

Since:
  Cryptix 2.2.2
Author:
  David Hopwood

Fields inherited from class xjava.security.Cipher
`DECRYPT, ENCRYPT, UNINITIALIZED`

Constructor Summary
`RawElGamalCipher()` Constructor for a RawElGamalCipher.

Method Summary
`protected int` | `engineCiphertextBlockSize()` SPI: Return the ciphertext block size, in bytes.
`protected java.lang.Object` | `engineGetParameter(java.lang.String param)` SPI: Return an algorithm-specific parameter.
`protected void` | `engineInitDecrypt(java.security.Key key)` SPI: Initializes the cipher for decryption, using the given private key.
`protected void` | `engineInitEncrypt(java.security.Key key)` SPI: Initializes the cipher for encryption, using the given public key.
`protected int` | `enginePlaintextBlockSize()` SPI: Return the plaintext block size, in bytes.
`protected void` | `engineSetParameter(java.lang.String param, java.lang.Object value)` SPI: Set an algorithm-specific parameter.
`protected int` | `engineUpdate(byte[] in, int inOffset, int inLen, byte[] out, int outOffset)` SPI: DOCUMENT ME
`static void` | `main(java.lang.String[] args)` Entry point for very basic `self_test`.
`static void` | `self_test(java.io.PrintWriter out)`

Methods inherited from class xjava.security.Cipher
`blockSize, clone, crypt, crypt, crypt, doFinal, doFinal, doFinal, doFinal, engineBlockSize, engineCrypt, engineInBufferSize, engineOutBufferSize, engineSetPaddingScheme, getAlgorithm, getAlgorithms, getAlgorithms, getCiphertextBlockSize, getInputBlockSize, getInstance, getInstance, getInstance, getMode, getOutputBlockSize, getPadding, getPaddingScheme, getParameter, getPlaintextBlockSize, getProvider, getState, inBufferSize, inBufferSizeFinal, initDecrypt, initEncrypt, isPaddingBlockCipher, outBufferSize, outBufferSizeFinal, setParameter, toString, update, update, update, update`

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

Constructor Detail

### RawElGamalCipher

    public RawElGamalCipher()

  Constructor for a RawElGamalCipher.

Method Detail

### engineInitEncrypt

    protected void engineInitEncrypt(java.security.Key key)
                              throws java.security.KeyException

  SPI: Initializes the cipher for encryption, using the given public key. The key object must implement java.security.interfaces.ElGamalPublicKey.
  Overrides:
    engineInitEncrypt in class Cipher
  Parameters:
    `key` - the public key
  Throws:
    java.security.InvalidKeyException - if !(key instanceof java.security.interfaces.ElGamalPublicKey), or the key is otherwise invalid

### engineInitDecrypt

    protected void engineInitDecrypt(java.security.Key key)
                              throws java.security.KeyException

  SPI: Initializes the cipher for decryption, using the given private key. The key object must implement java.security.interfaces.ElGamalPrivateKey.
  Overrides:
    engineInitDecrypt in class Cipher
  Parameters:
    `key` - the private key
  Throws:
    java.security.InvalidKeyException - if !(key instanceof java.security.interfaces.ElGamalPrivateKey), or the key is otherwise invalid

### enginePlaintextBlockSize

    protected int enginePlaintextBlockSize()

  SPI: Return the plaintext block size, in bytes. For ElGamal this is the number of bytes needed for a bit string one bit shorter than the prime, p.

  If the key has not been set, this method throws CryptixException (a subclass of ProviderException).

  Overrides:
    enginePlaintextBlockSize in class Cipher
  Returns:
    the plaintext block size

### engineCiphertextBlockSize

    protected int engineCiphertextBlockSize()

  SPI: Return the ciphertext block size, in bytes. For ElGamal this is double the number of bytes needed to represent p-1.

  If the key has not been set, this method throws CryptixException (a subclass of ProviderException).

  Overrides:
    engineCiphertextBlockSize in class Cipher
  Returns:
    the ciphertext block size

### engineSetParameter

    protected void engineSetParameter(java.lang.String param,
                                      java.lang.Object value)

  SPI: Set an algorithm-specific parameter.

  ElGamal has one algorithm-specific parameter called "random", of type java.util.Random, which specifies the source of random bits used to generate the k values needed for encryption. If this parameter is not set when `initKey` is called, the result of `new SecureRandom()` will be used.

  You can set the "random" parameter using the following code:

         try {
             elgamal.setParameter("random", existingSecureRandom);
         } catch (InvalidParameterException e) { /* ignore */ }
         elgamal.initEncrypt(publicKey);

  This is not useful if the cipher will only be used for decryption.

  Overrides:
    engineSetParameter in class Cipher
  Parameters:
    `param` - the string identifier of the parameter.
    `value` - the parameter value.
  Throws:
    java.security.InvalidParameterException - if (!(param.equals("random") && value instanceof java.util.Random))

### engineGetParameter

    protected java.lang.Object engineGetParameter(java.lang.String param)

  SPI: Return an algorithm-specific parameter.

  ElGamal has one algorithm-specific parameter called "random", as described above. It is guaranteed to be a subclass of java.util.Random. Calling this method with a param string other than "random" will return null.

  Overrides:
    engineGetParameter in class Cipher
  Parameters:
    `param` - the string name of the parameter.
  Returns:
    the object that represents the parameter value, or null if there is none.

### engineUpdate

    protected int engineUpdate(byte[] in,
                               int inOffset,
                               int inLen,
                               byte[] out,
                               int outOffset)

  SPI: DOCUMENT ME
  Overrides:
    engineUpdate in class Cipher
  Tags copied from class: Cipher
  Parameters:
    `in` - the input data.
    `inOffset` - the offset into in specifying where the data starts.
    `inLen` - the length of the subarray.
    `out` - the output array.
    `outOffset` - the offset indicating where to start writing into the out array.
  Returns:
    the number of bytes written.

### main

    public static final void main(java.lang.String[] args)

  Entry point for very basic `self_test`.

### self_test

    public static void self_test(java.io.PrintWriter out)
                          throws java.security.KeyException

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) 1995-2000 The Cryptix Foundation Ltd. All rights reserved.