jrun.security
Class Twofish_Algorithm

java.lang.Object
  |
  +--jrun.security.Twofish_Algorithm

public final class Twofish_Algorithm
extends java.lang.Object

Twofish is an AES candidate algorithm. It is a balanced 128-bit Feistel cipher, consisting of 16 rounds. In each round, a 64-bit S-box value is computed from 64 bits of the block, and this value is xored into the other half of the block. The two half-blocks are then exchanged, and the next round begins. Before the first round, all input bits are xored with key- dependent "whitening" subkeys, and after the final round the output bits are xored with other key-dependent whitening subkeys; these subkeys are not used anywhere else in the algorithm.

Twofish was submitted by Bruce Schneier, Doug Whiting, John Kelsey, Chris Hall and David Wagner.

Reference:

  1. TWOFISH2.C -- Optimized C API calls for TWOFISH AES submission, Version 1.00, April 1998, by Doug Whiting.

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

$Revision: $

Author:
Raif S. Naffah According to the cryptix website

Constructor Summary
Twofish_Algorithm()
           
 
Method Summary
static byte[] blockDecrypt(byte[] in, int inOffset, java.lang.Object sessionKey)
          Decrypt exactly one block of ciphertext.
static byte[] blockEncrypt(byte[] in, int inOffset, java.lang.Object sessionKey)
          Encrypt exactly one block of plaintext.
static int blockSize()
           
static void main(java.lang.String[] args)
           
static java.lang.Object makeKey(byte[] k)
          Expand a user-supplied key material into a session key.
static boolean self_test()
          A basic symmetric encryption/decryption test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Twofish_Algorithm

public Twofish_Algorithm()
Method Detail

makeKey

public static java.lang.Object makeKey(byte[] k)
                                throws java.security.InvalidKeyException
Expand a user-supplied key material into a session key.
Parameters:
key - The 64/128/192/256-bit user-key to use.
Returns:
This cipher's round keys.
Throws:
java.security.InvalidKeyException - If the key is invalid.

blockEncrypt

public static byte[] blockEncrypt(byte[] in,
                                  int inOffset,
                                  java.lang.Object sessionKey)
Encrypt exactly one block of plaintext.
Parameters:
in - The plaintext.
inOffset - Index of in from which to start considering data.
sessionKey - The session key to use for encryption.
Returns:
The ciphertext generated from a plaintext using the session key.

blockDecrypt

public static byte[] blockDecrypt(byte[] in,
                                  int inOffset,
                                  java.lang.Object sessionKey)
Decrypt exactly one block of ciphertext.
Parameters:
in - The ciphertext.
inOffset - Index of in from which to start considering data.
sessionKey - The session key to use for decryption.
Returns:
The plaintext generated from a ciphertext using the session key.

self_test

public static boolean self_test()
A basic symmetric encryption/decryption test.

blockSize

public static int blockSize()
Returns:
The length in bytes of the Algorithm input block.

main

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


Copyright � 2002 Macromedia Corporation. All Rights Reserved.