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

## xjava.security
Class Mode

    java.lang.Object
      |
      +--xjava.security.IJCE_Traceable
            |
            +--xjava.security.Cipher
                  |
                  +--xjava.security.Mode

Direct Known Subclasses:
  cryptix.provider.mode.FeedbackMode

public abstract class Mode
extends Cipher

This class is used to provide the functionality of an encryption mode, such as CBC, CFB, or OFB.

Modes are implemented as Ciphers with an additional engine method, `engineSetCipher`, that is called once to set the underlying cipher algorithm. The Mode class stores this cipher in the protected field `cipher`. Subclasses are expected to use this to implement their own `engineInitEncrypt`, `engineInitDecrypt` and `engineUpdate` methods.

This class is not supported in JavaSoft's version of JCE.

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

$Revision: 1.3 $

Since:
  IJCE 1.0.1
Author:
  David Hopwood, Raif S. Naffah
See Also:
  `java.security.Cipher`

Field Summary
`protected Cipher` | `cipher` A reference to the cipher currently operating in this mode.

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

Constructor Summary
`protected` | `Mode(boolean implBuffering, boolean implPadding, java.lang.String provider)` Constructor for a Mode.

Method Summary
`protected java.lang.Object` | `engineGetParameter(java.lang.String param)` SPI: Gets the value of the specified algorithm parameter.
`protected void` | `engineSetCipher(Cipher cipher)` SPI: Sets the underlying cipher.
`protected void` | `engineSetParameter(java.lang.String param, java.lang.Object value)` SPI: Sets the specified algorithm parameter to the specified value.
`static java.lang.String[]` | `getAlgorithms()` Gets the standard names of all Modes implemented by any installed provider.
`static java.lang.String[]` | `getAlgorithms(java.security.Provider provider)` Gets the standard names of all Modes implemented by a provider.
`static Cipher` | `getInstance(java.lang.String algorithm)` Generates a Mode object that implements the algorithm requested, as available in the environment.
`static Cipher` | `getInstance(java.lang.String algorithm, java.lang.String provider)` Generates a Mode object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider.
`java.lang.String` | `toString()`

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

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

Field Detail

### cipher

    protected Cipher cipher

  A reference to the cipher currently operating in this mode.

Constructor Detail

### Mode

    protected Mode(boolean implBuffering,
                   boolean implPadding,
                   java.lang.String provider)

  Constructor for a Mode. This constructor is only for use by subclasses, which should pass the correct arguments to convey their behaviour to the superclass. Applications typically do not use Mode classes directly; they should call one of the `Cipher.getInstance` factory methods instead.
  Parameters:
    `implBuffering` - if true, this argument indicates that data will be passed from update/crypt to engineUpdate/engineCrypt without modification.
    `implPadding` - if true, this argument indicates that the implementation can perform padding, and that the engineCrypt method will be called when padding is required.
    `provider` - the name of the provider of the underlying cryptographic engine.
  Throws:
    NullPointerException - if provider == null

Method Detail

### getInstance

    public static Cipher getInstance(java.lang.String algorithm)
                              throws java.security.NoSuchAlgorithmException

  Generates a Mode object that implements the algorithm requested, as available in the environment.

  See International JCE Standard Algorithm Names for a list of Mode algorithm names.

  Parameters:
    `algorithm` - the standard name or an alias for the algorithm.
  Returns:
    the new Mode object.
  Throws:
    java.security.NoSuchAlgorithmException - if the algorithm is not available in the environment.

### getInstance

    public static Cipher getInstance(java.lang.String algorithm,
                                     java.lang.String provider)
                              throws java.security.NoSuchAlgorithmException,
                                     java.security.NoSuchProviderException

  Generates a Mode object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider.

  See International JCE Standard Algorithm Names for a list of Mode algorithm names.

  Parameters:
    `algorithm` - the standard name or an alias for the algorithm.
    `provider` - the string name of the provider.
  Returns:
    the new KeyGenerator object.
  Throws:
    java.security.NoSuchAlgorithmException - if the algorithm is not available from the provider.
    java.security.NoSuchProviderException - if the provider is not available in the environment.

### getAlgorithms

    public static java.lang.String[] getAlgorithms(java.security.Provider provider)

  Gets the standard names of all Modes implemented by a provider.

### getAlgorithms

    public static java.lang.String[] getAlgorithms()

  Gets the standard names of all Modes implemented by any installed provider. Algorithm names are not duplicated if they are supported by more than one provider. The built-in mode "ECB" is included.

### toString

    public java.lang.String toString()

  Overrides:
    toString in class Cipher

### engineSetCipher

    protected void engineSetCipher(Cipher cipher)

  SPI: Sets the underlying cipher.

  For example, to create an IDEA cipher in CBC mode, the cipher for "IDEA" would be passed to the mode for "CBC" using this method. It is called once, immediately after the mode object is constructed.

  Subclasses that override this method (to do initialization that depends on the cipher being set) should call `super.engineSetCipher(cipher)` first.

  Parameters:
    `cipher` - the underlying cipher object
  Throws:
    NullPointerException - if cipher == null

### engineSetParameter

    protected void engineSetParameter(java.lang.String param,
                                      java.lang.Object value)
                               throws NoSuchParameterException,
                                      java.security.InvalidParameterException,
                                      InvalidParameterTypeException

  SPI: Sets the specified algorithm parameter to the specified value.

  This method supplies a general-purpose mechanism through which it is possible to set the various parameters of this object. The mode implementation should first check whether it recognizes the parameter name, and if not, call `super.engineSetParameter(param, value)`.

  A parameter may be any settable parameter for the algorithm, such as block size, a source of random bits for IV generation (if appropriate), or an indication of whether or not to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.

  The default implementation forwards the call to the underlying cipher.

  Overrides:
    engineSetParameter in class Cipher
  Parameters:
    `param` - the string name of the parameter.
    `value` - the parameter value.
  Throws:
    NoSuchParameterException - if there is no parameter with name param for this cipher implementation.
    java.security.InvalidParameterException - if the parameter exists but cannot be set (for example because the cipher is in the wrong state).
    InvalidParameterTypeException - if value is the wrong type for this parameter.

### engineGetParameter

    protected java.lang.Object engineGetParameter(java.lang.String param)
                                           throws NoSuchParameterException,
                                                  java.security.InvalidParameterException

  SPI: Gets the value of the specified algorithm parameter.

  This method supplies a general-purpose mechanism through which it is possible to get the various parameters of this object. The mode implementation should first check whether it recognizes the parameter name, and if not, return `super.engineGetParameter(param)`.

  A parameter may be any settable parameter for the algorithm, such as block size, a source of random bits for IV generation (if appropriate), or an indication of whether or not to perform a specific but optional computation. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.

  The default implementation forwards the call to the underlying cipher.

  Overrides:
    engineGetParameter in class Cipher
  Parameters:
    `param` - the string name of the parameter.
  Returns:
    the object that represents the parameter value.
  Throws:
    NoSuchParameterException - if there is no parameter with name param for this cipher implementation.
    java.security.InvalidParameterException - if the parameter exists but cannot be read.

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.