cryptix.security
Class BlockCipher

java.lang.Object
  |
  +--cryptix.security.BlockCipher
Direct Known Subclasses:
Blowfish, DES, IDEA, SPEED

public abstract class BlockCipher
extends java.lang.Object

This is an abstract superclass for ciphers that encrypt and decrypt a fixed length block with a secret key.

BlockCipher objects support only the Cryptix v2.2 API.

Note: compatibility with Cryptix 2.2 applies only to clients of this class. Subclasses must be rewritten as JCE algorithms.

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

$Revision: 1.5 $

Since:
Cryptix 2.2
Author:
Systemics Ltd, David Hopwood, Raif S. Naffah
See Also:
java.security.Cipher

Field Summary
protected  int blockSize
          Deprecated. The algorithm's block size in bytes.
protected  xjava.security.Cipher cipher
          Deprecated. The JCE cipher that is delegated to.
 
Constructor Summary
protected BlockCipher(xjava.security.Cipher cipher, byte[] userKey)
          Deprecated. Constructs a V2.2 block cipher from a JCE cipher.
 
Method Summary
 int blockLength()
          Deprecated. Use blockSize(), getPlaintextBlockSize() or getCiphertextBlockSize() instead.
 void decrypt(byte[] text)
          Deprecated. Use initDecrypt(key) and update(buf, 0, buf.length, text, 0) instead.
 void decrypt(byte[] in, byte[] out)
          Deprecated. Use initDecrypt(key) and update(in, 0, in.length, out, 0) instead.
 void decrypt(byte[] in, int inOffset, byte[] out, int outOffset)
          Deprecated. Use initDecrypt(key) and update(in, inOffset, blockSize, out, outOffset) instead.
 void encrypt(byte[] buf)
          Deprecated. Use initEncrypt(key) and update(buf, 0, buf.length, text, 0) instead.
 void encrypt(byte[] in, byte[] out)
          Deprecated. Use initEncrypt(key) and update(in, 0, in.length, out, 0) instead.
 void encrypt(byte[] in, int inOffset, byte[] out, int outOffset)
          Deprecated. Use initEncrypt(key) and update(in, inOffset, blockSize, out, outOffset) instead.
 int keyLength()
          Deprecated.  
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cipher

protected xjava.security.Cipher cipher
Deprecated. 
The JCE cipher that is delegated to.

blockSize

protected int blockSize
Deprecated. 
The algorithm's block size in bytes.
Constructor Detail

BlockCipher

protected BlockCipher(xjava.security.Cipher cipher,
                      byte[] userKey)
Deprecated. 
Constructs a V2.2 block cipher from a JCE cipher.
Parameters:
cipher - the java.security.Cipher object.
Method Detail

blockLength

public final int blockLength()
Deprecated. Use blockSize(), getPlaintextBlockSize() or getCiphertextBlockSize() instead.

Returns the block size of this cipher.
Returns:
the block size (in bytes) of this cipher.

keyLength

public final int keyLength()
Deprecated.  

Returns the key length for this cipher.

The JCE equivalent is to call getEncoded() on the Key object, and find the length of the resulting byte array. It is not possible to directly get the key object that has been used to initialize a Cipher.

Returns:
the key length (in bytes) of this cipher.

encrypt

public final void encrypt(byte[] buf)
Deprecated. Use initEncrypt(key) and update(buf, 0, buf.length, text, 0) instead.

Encrypts a block of data in place. The plaintext in buf is encrypted and written back as ciphertext. buf.length must be equal to the block size.
Parameters:
buf - the buffer holding the data
Throws:
CryptoError - if the buffer was the wrong length

encrypt

public final void encrypt(byte[] in,
                          byte[] out)
Deprecated. Use initEncrypt(key) and update(in, 0, in.length, out, 0) instead.

Encrypts a block of data. The plaintext in in is encrypted and the ciphertext is written into out. Note that in and out can be the same array. in.length and out.length must be equal to the block size.
Parameters:
in - the plaintext to be encrypted
out - the ciphertext result of the encryption
Throws:
CryptoError - if a buffer was the wrong length

encrypt

public void encrypt(byte[] in,
                    int inOffset,
                    byte[] out,
                    int outOffset)
Deprecated. Use initEncrypt(key) and update(in, inOffset, blockSize, out, outOffset) instead.

Encrypts a block of data within an array. The plaintext in in[inOffset..inOffset+blockSize-1] is encrypted, and the resulting ciphertext is written to out[outOffset..outOffset+blockSize-1]. Note that there must be sufficient bytes left in each array.

The in and out arrays can be the same, in which case the behaviour is the same as if the input array was copied before any output is written.

Parameters:
in - buffer holding the plaintext to be encrypted
inOffset - the start of plaintext within in
out - buffer to write the encrypted ciphertext to
outOffset - the start of ciphertext within out
Throws:
ArrayIndexOutOfBoundsException - if an offset was invalid.

decrypt

public final void decrypt(byte[] text)
Deprecated. Use initDecrypt(key) and update(buf, 0, buf.length, text, 0) instead.

Decrypts an array of data in place. The ciphertext in buf is decrypted and written back as plaintext. buf.length must be equal to the block size.
Parameters:
buf - the buffer holding the data
Throws:
CryptoError - if the buffer was the wrong length

decrypt

public final void decrypt(byte[] in,
                          byte[] out)
Deprecated. Use initDecrypt(key) and update(in, 0, in.length, out, 0) instead.

Decrypts a block of data. The ciphertext in in is decrypted and the plaintext is written into out. Note that in and out can be the same array. in.length and out.length must be equal to the block size.
Parameters:
in - the plaintext to be encrypted
out - the ciphertext result of the encryption
Throws:
CryptoError - if a buffer was the wrong length

decrypt

public void decrypt(byte[] in,
                    int inOffset,
                    byte[] out,
                    int outOffset)
Deprecated. Use initDecrypt(key) and update(in, inOffset, blockSize, out, outOffset) instead.

Decrypts a block of data within an array. The ciphertext in in[inOffset..inOffset+blockSize-1] is decrypted, and the resulting plaintext is written to out[outOffset..outOffset+blockSize-1]. Note that there must be sufficient bytes left in each array.

The in and out arrays can be the same, in which case the behaviour is the same as if the input array was copied before any output is written.

Parameters:
in - buffer holding the ciphertext to be decrypted
inOffset - the start of ciphertext within in
out - buffer to write the decrypted plaintext to
outOffset - the start of plaintext within out
Throws:
ArrayIndexOutOfBoundsException - if an offset was invalid.