cryptix.security
Class Blowfish

java.lang.Object
  extended bycryptix.security.BlockCipher
      extended bycryptix.security.Blowfish

public class Blowfish
extends BlockCipher

This class implements the Cryptix V2.2 API for the Blowfish block cipher. New code should use the JCA implementation of Blowfish, which can be obtained by calling Cipher.getInstance("Blowfish"), for example.

Blowfish was designed by Bruce Schneier. The algorithm is in the public domain.

This implementation throws a CryptoError if the user key length is out of range, or if any one of the two self-tests fail. The self-tests are as follows:

  1. encrypt 0 ten times using the initial S boxes and P values. Check the result against a known value. If equal decrypt the result 10 times and compare it to 0.
  2. complete the key expansion process and use the newly formed key to encrypt 10 times a block of all zeroes; decrypt the result 10 times and compare.

References:

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

  2. Bruce Schneier, "Description of a New Variable-Length Key, 64-Bit Cipher (Blowfish)," Fast Software Encryption Cambridge Security Workshop Proceedings, Springer-Verlag, 1004, pp 191-204.

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

$Revision: 1.9 $

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

Field Summary
static int BLOCK_LENGTH
          Deprecated. The length of a block (8 bytes for Blowfish).
static int BLOCK_LENGTH_MAX
          Deprecated.  
static int BLOCK_LENGTH_MIN
          Deprecated.  
static int KEY_LENGTH
          Deprecated. The default length of a user key (16 bytes for Blowfish).
static int KEY_LENGTH_MAX
          Deprecated.  
static int KEY_LENGTH_MIN
          Deprecated.  
static int KEY_LENGTH_MOD
          Deprecated.  
static int NUM_ROUNDS
          Deprecated. The 2.2 API only supports the default number of rounds, 16.
 
Fields inherited from class cryptix.security.BlockCipher
blockSize, cipher
 
Constructor Summary
Blowfish(byte[] userKey)
          Deprecated. This creates a Blowfish block cipher instance, with key data taken from a byte array of a user-defined length.
 
Method Summary
static void main(java.lang.String[] argv)
          Deprecated. Entry point for very basic self_test.
static void self_test()
          Deprecated. Do some basic tests.
 
Methods inherited from class cryptix.security.BlockCipher
blockLength, decrypt, decrypt, decrypt, encrypt, encrypt, encrypt, keyLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_LENGTH

public static final int BLOCK_LENGTH
Deprecated. 
The length of a block (8 bytes for Blowfish).

See Also:
Constant Field Values

BLOCK_LENGTH_MIN

public static final int BLOCK_LENGTH_MIN
Deprecated. 
See Also:
Constant Field Values

BLOCK_LENGTH_MAX

public static final int BLOCK_LENGTH_MAX
Deprecated. 
See Also:
Constant Field Values

KEY_LENGTH

public static final int KEY_LENGTH
Deprecated. 
The default length of a user key (16 bytes for Blowfish).

See Also:
Constant Field Values

KEY_LENGTH_MAX

public static final int KEY_LENGTH_MAX
Deprecated. 
See Also:
Constant Field Values

KEY_LENGTH_MIN

public static final int KEY_LENGTH_MIN
Deprecated. 
See Also:
Constant Field Values

KEY_LENGTH_MOD

public static final int KEY_LENGTH_MOD
Deprecated. 
See Also:
Constant Field Values

NUM_ROUNDS

public static final int NUM_ROUNDS
Deprecated. 
The 2.2 API only supports the default number of rounds, 16.

See Also:
Constant Field Values
Constructor Detail

Blowfish

public Blowfish(byte[] userKey)
Deprecated. 
This creates a Blowfish block cipher instance, with key data taken from a byte array of a user-defined length.

Parameters:
userKey - the user key.
Throws:
CryptoError - if an error occurs initialising the cipher.
Method Detail

main

public static void main(java.lang.String[] argv)
Deprecated. 
Entry point for very basic self_test.


self_test

public static void self_test()
                      throws CryptoError
Deprecated. 
Do some basic tests. Three of the certification data are included only, no output, success or exception. If you want more, write a test program!

Throws:
CryptoError
See Also:
cryptix.examples.TestBlowfish