org.gregoire.util.crypto
Class Rijndael_Algorithm

java.lang.Object
  extended byorg.gregoire.util.crypto.Rijndael_Algorithm

public final class Rijndael_Algorithm
extends java.lang.Object

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.

Author:
Raif S. Naffah, Paulo S. L. M. Barreto License is apparently available from http://www.cryptix.org/docs/license.html

Constructor Summary
Rijndael_Algorithm()
           
 
Method Summary
static void blockDecrypt(byte[] in, byte[] result, int inOffset, java.lang.Object sessionKey)
          Convenience method to decrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).
static void blockDecrypt(byte[] in, byte[] result, int inOffset, java.lang.Object sessionKey, int blockSize)
          Decrypt exactly one block of ciphertext.
static void blockEncrypt(byte[] in, byte[] result, int inOffset, java.lang.Object sessionKey)
          Convenience method to encrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).
static void blockEncrypt(byte[] in, byte[] result, int inOffset, java.lang.Object sessionKey, int blockSize)
          Encrypt exactly one block of plaintext.
static int blockSize()
           
static int getRounds(int keySize, int blockSize)
          Return The number of rounds for a given Rijndael's key and block sizes.
static void main(java.lang.String[] args)
           
static java.lang.Object makeKey(byte[] k)
          Convenience method to expand a user-supplied key material into a session key, assuming Rijndael's default block size (128-bit).
static java.lang.Object makeKey(byte[] k, int blockSize)
          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

Rijndael_Algorithm

public Rijndael_Algorithm()
Method Detail

makeKey

public static final java.lang.Object makeKey(byte[] k)
                                      throws java.security.InvalidKeyException
Convenience method to expand a user-supplied key material into a session key, assuming Rijndael's default block size (128-bit).

Parameters:
k - The 128/192/256-bit user-key to use.
Throws:
java.security.InvalidKeyException - If the key is invalid.

blockEncrypt

public static final void blockEncrypt(byte[] in,
                                      byte[] result,
                                      int inOffset,
                                      java.lang.Object sessionKey)
Convenience method to encrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).

Parameters:
in - The plaintext.
result - The buffer into which to write the resulting ciphertext.
inOffset - Index of in from which to start considering data.
sessionKey - The session key to use for encryption.

blockDecrypt

public static final void blockDecrypt(byte[] in,
                                      byte[] result,
                                      int inOffset,
                                      java.lang.Object sessionKey)
Convenience method to decrypt exactly one block of plaintext, assuming Rijndael's default block size (128-bit).

Parameters:
in - The ciphertext.
result - the resulting ciphertext
inOffset - Index of in from which to start considering data.
sessionKey - The session key to use for decryption.

self_test

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


blockSize

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

makeKey

public static final java.lang.Object makeKey(byte[] k,
                                             int blockSize)
                                      throws java.security.InvalidKeyException
Expand a user-supplied key material into a session key.

Parameters:
k - The 128/192/256-bit user-key to use.
blockSize - The block size in bytes of this Rijndael.
Throws:
java.security.InvalidKeyException - If the key is invalid.

blockEncrypt

public static final void blockEncrypt(byte[] in,
                                      byte[] result,
                                      int inOffset,
                                      java.lang.Object sessionKey,
                                      int blockSize)
Encrypt exactly one block of plaintext.

Parameters:
in - The plaintext.
result - The buffer into which to write the resulting ciphertext.
inOffset - Index of in from which to start considering data.
sessionKey - The session key to use for encryption.
blockSize - The block size in bytes of this Rijndael.

blockDecrypt

public static final void blockDecrypt(byte[] in,
                                      byte[] result,
                                      int inOffset,
                                      java.lang.Object sessionKey,
                                      int blockSize)
Decrypt exactly one block of ciphertext.

Parameters:
in - The ciphertext.
result - The resulting ciphertext.
inOffset - Index of in from which to start considering data.
sessionKey - The session key to use for decryption.
blockSize - The block size in bytes of this Rijndael.

getRounds

public static final 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.

main

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


Copyright © Paul Gregoire, All Rights Reserved.