sam.cipher
Class Rijndael

java.lang.Object
  |
  +--sam.cipher.Cipher
        |
        +--sam.cipher.Rijndael

public class Rijndael
extends Cipher

Implementation of the Rijndael cipher. Retrofitted for personal use by Guillaume Lacôte. Rijndael --pronounced Reindaal-- is a variable block-size (128-, 192- and 256-bit), variable key-size (128-, 192- and 256-bit) symmetric cipher.

Rijndael was written by Vincent Rijmen and Joan Daemen.

Portions of this code are Copyright © 1997, 1998 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: $


Nested Class Summary
static class Rijndael.Key
          Key implementation that is adapted to the Rijndael cipher.
 
Nested classes inherited from class sam.cipher.Cipher
Cipher.ByteArrayFilter, Cipher.Error
 
Field Summary
 
Fields inherited from class sam.cipher.Cipher
DECRYPT, EMPTY, ENCRYPT, INVERSE, key, REGISTRY
 
Constructor Summary
Rijndael(sam.cipher.Key key)
           
 
Method Summary
protected  void decrypt(byte[] data, int offset, sam.cipher.Key sessionKey)
          Convenience method to decrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).
protected  void encrypt(byte[] data, int offset, sam.cipher.Key sessionKey)
          Convenience method to encrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).
protected  int getPreferredSize(int size)
          Specifiy preferred buffer size.
static int getRounds(int keySize, int blockSize)
          Return The number of rounds for a given Rijndael's key and block sizes.
 
Methods inherited from class sam.cipher.Cipher
cipher, cipher, fill, main, store, store, storeReversed, streamTest, test, unstoreInt, unstoreLong, unstoreReversedLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rijndael

public Rijndael(sam.cipher.Key key)
Method Detail

getPreferredSize

protected int getPreferredSize(int size)
Description copied from class: Cipher
Specifiy preferred buffer size.

May return a fixed value, ignoring suggested size (e.g. return 16;).

By default, this implementation simply returns its argument unchanged.

Overrides:
getPreferredSize in class Cipher
Parameters:
size - proposed buffer size (in bytes)
Returns:
adjusted buffer size (in bytes)

encrypt

protected void encrypt(byte[] data,
                       int offset,
                       sam.cipher.Key sessionKey)
Convenience method to encrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).

Specified by:
encrypt in class Cipher
Parameters:
sessionKey - The session key to use for encryption.

decrypt

protected void decrypt(byte[] data,
                       int offset,
                       sam.cipher.Key sessionKey)
Convenience method to decrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).

Specified by:
decrypt in class Cipher
Parameters:
data - The ciphertext.
sessionKey - The session key to use for decryption.

getRounds

public static int getRounds(int keySize,
                            int blockSize)
Return The number of rounds for a given Rijndael's key and block sizes.

Parameters:
keySize - The size of the user key material in bytes.
blockSize - The desired block size in bytes.
Returns:
The number of rounds for a given Rijndael's key and block sizes.