Sharkysoft home

lava.security.des
Class DesCbcEncoder

java.lang.Object
  |
  +--lava.security.des.DesCbcCoder
        |
        +--lava.security.des.DesCbcEncoder

public final class DesCbcEncoder
extends DesCbcCoder

DES encryption in Cipher Block Chaining (CBC) mode.

Details: DesCbcEncoder performs DES encryption in Cipher Block Chaining (CBC) mode. See superclass documention for more details.

Since:
1999.08.16
Author:
Sharky
See Also:
DesCbcDecoder

Constructor Summary
DesCbcEncoder(DesKey key, long iv)
          Specifies encryption key and initialization vector.
DesCbcEncoder(IBlockCipher64 engine, long iv)
          Specifies initialization vector and encryption function.
 
Method Summary
 void beginTransform()
          Resets transform.
 int continueTransform(byte[] input, byte[] output, int length)
          Encrypts blocks using byte arrays.
 int continueTransform(java.lang.Object input, java.lang.Object output, int length)
          Processes text.
 
Methods inherited from class lava.security.des.DesCbcCoder
completeTransform, getTransformInputWidth, getTransformOutputWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DesCbcEncoder

public DesCbcEncoder(IBlockCipher64 engine,
                     long iv)
Specifies initialization vector and encryption function.

Details: This constructor initializes a new instance with the given block cipher and initialization vector.

Parameters:
engine - the block cipher
iv - the initialization vector

DesCbcEncoder

public DesCbcEncoder(DesKey key,
                     long iv)
Specifies encryption key and initialization vector.

Details: This constructor initializes a standard DES CBC cipher with the given initialization vector and DES encryption key.

Parameters:
key - the encryption key
iv - the initialization vector
Method Detail

beginTransform

public final void beginTransform()
Description copied from interface: ITextTransform
Resets transform.

Details: beginTransform initializes this transform in preparation for processing a new input text stream.


continueTransform

public final int continueTransform(java.lang.Object input,
                                   java.lang.Object output,
                                   int length)
Description copied from interface: ITextTransform
Processes text.

Details: continueTransform consumes input text and produces output text. Input is retrieved from the provided source array (src), while output is stored in the provided destination array (dest). The return value normally indicates the number of symbols written into the destination array (see note below).

Depending on the particular transformation represented by this implementation, the number of output symbols produced per call may always be equal to the number of input symbols consumed (for example, if the transformation performs text compression). Similarly, a call to this method may cause the production of more elements than the supplied destination array can store. It is the caller's responsibility to make sure the supplied destination array is large enough to receive the symbols produced.

If the destination array is too short, the implementation may, at its option, discard the overflow. However, an implementation may also choose to retain the overflow portion and make it available in a subsequent call to this method. (Check the implementation documentation to see which approach is taken.) If the overflow is discarded, the return value must indicate the number of symbols written into the array plus the number of overflow symbols discarded.

It is legal to call this method with src set to null so long as length is also set to 0. This might be useful in situations where a transform is expected to produce output symbols even when the caller has no input symbols to supply (i.e., to recover buffered overflow from a previous call).

continueTransform always writes as much data into dest as can be computed from the current input history. However, because some data may not be computable until the transformation sees the last symbol (such as in checksum algorithms), it may be necessary to obtain the rest of the output data by calling completeTransform.

The results of continueTransform are undefined if it is called after completeTransform but before beginTransform.

Tags copied from interface: ITextTransform
Parameters:
src - the source array
dest - the destination array
length - number of symbols to process
Returns:
number of elements written into dest or discarded

continueTransform

public final int continueTransform(byte[] input,
                                   byte[] output,
                                   int length)
Encrypts blocks using byte arrays.

Details: This method is not part of the ITextTransform API, but it is provided to facilitate symbol processing where the symbols are stored in big endian byte arrays.

The length parameter and return value count bytes, not 64-bit blocks. Results are undefined if length is positive and not a multiple of 8.

Parameters:
input - the input blocks
output - buffer for output blocks
length - number of input array elements to process
Returns:
number of bytes written to output array

Sharkysoft home