net.i2p.crypto

## Class CryptixRijndael_Algorithm

- java.lang.Object
- - net.i2p.crypto.CryptixRijndael_Algorithm

-     public final class CryptixRijndael_Algorithm
      extends 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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static int[]` | `_alog`
    `(package private) static int` | `_BLOCK_SIZE`
    `(package private) static int` | `_debuglevel`
    `(package private) static PrintWriter` | `_err`
    `(package private) static boolean` | `_IN`
    `(package private) static int[]` | `_log`
    `(package private) static String` | `_NAME`
    `(package private) static boolean` | `_OUT`
    `(package private) static byte[]` | `_rcon`
    `(package private) static boolean` | `_RDEBUG`
    `(package private) static byte[]` | `_S`
    `(package private) static int[][][]` | `_shifts`
    `(package private) static byte[]` | `_Si`
    `(package private) static int[]` | `_T1`
    `(package private) static int[]` | `_T2`
    `(package private) static int[]` | `_T3`
    `(package private) static int[]` | `_T4`
    `(package private) static int[]` | `_T5`
    `(package private) static int[]` | `_T6`
    `(package private) static int[]` | `_T7`
    `(package private) static int[]` | `_T8`
    `(package private) static boolean` | `_TRACE`
    `(package private) static int[]` | `_U1`
    `(package private) static int[]` | `_U2`
    `(package private) static int[]` | `_U3`
    `(package private) static int[]` | `_U4`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CryptixRijndael_Algorithm()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `blockDecrypt(byte[] in, byte[] result, int inOffset, int outOffset, 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, int outOffset, Object sessionKey, int blockSize)` Decrypt exactly one block of ciphertext.
    `static void` | `blockEncrypt(byte[] in, byte[] result, int inOffset, int outOffset, 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, int outOffset, Object sessionKey, int blockSize)` Encrypt exactly one block of plaintext.
    `static int` | `blockSize()`
    `(package private) static void` | `debug(String s)`
    `static int` | `getRounds(int keySize, int blockSize)` Return The number of rounds for a given Rijndael's key and block sizes.
    `static void` | `main(String[] args)`
    `static 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 Object` | `makeKey(byte[] k, int blockSize)` Expand a user-supplied key material into a session key.
    `static Object` | `makeKey(byte[] k, int blockSize, CryptixAESKeyCache.KeyCacheEntry keyData)`
    `(package private) static int` | `mul(int a, int b)`
    `(package private) static int` | `mul4(int a, byte[] b)`
    `static boolean` | `self_test()` A basic symmetric encryption/decryption test.
    `(package private) static void` | `trace(boolean in, String s)`
    `(package private) static void` | `trace(String s)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _NAME

          static final String _NAME

      See Also:
        Constant Field Values

    - #### _IN

          static final boolean _IN

      See Also:
        Constant Field Values

    - #### _OUT

          static final boolean _OUT

      See Also:
        Constant Field Values

    - #### _RDEBUG

          static final boolean _RDEBUG

      See Also:
        Constant Field Values

    - #### _debuglevel

          static final int _debuglevel

      See Also:
        Constant Field Values

    - #### _err

          static final PrintWriter _err

    - #### _TRACE

          static final boolean _TRACE

      See Also:
        Constant Field Values

    - #### _BLOCK_SIZE

          static final int _BLOCK_SIZE

      See Also:
        Constant Field Values

    - #### _alog

          static final int[] _alog

    - #### _log

          static final int[] _log

    - #### _S

          static final byte[] _S

    - #### _Si

          static final byte[] _Si

    - #### _T1

          static final int[] _T1

    - #### _T2

          static final int[] _T2

    - #### _T3

          static final int[] _T3

    - #### _T4

          static final int[] _T4

    - #### _T5

          static final int[] _T5

    - #### _T6

          static final int[] _T6

    - #### _T7

          static final int[] _T7

    - #### _T8

          static final int[] _T8

    - #### _U1

          static final int[] _U1

    - #### _U2

          static final int[] _U2

    - #### _U3

          static final int[] _U3

    - #### _U4

          static final int[] _U4

    - #### _rcon

          static final byte[] _rcon

    - #### _shifts

          static final int[][][] _shifts

  - ### Constructor Detail

    - #### CryptixRijndael_Algorithm

          public CryptixRijndael_Algorithm()

  - ### Method Detail

    - #### debug

          static void debug(String s)

    - #### trace

          static void trace(boolean in,
                   String s)

    - #### trace

          static void trace(String s)

    - #### mul

          static final int mul(int a,
                int b)

    - #### mul4

          static final int mul4(int a,
                 byte[] b)

    - #### makeKey

          public static final Object makeKey(byte[] k)
                                      throws 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:
        `InvalidKeyException` - If the key is invalid.

    - #### blockEncrypt

          public static final void blockEncrypt(byte[] in,
                          byte[] result,
                          int inOffset,
                          int outOffset,
                          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 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,
                          int outOffset,
                          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 Object makeKey(byte[] k,
                       int blockSize)
                                      throws 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:
        `InvalidKeyException` - If the key is invalid.

    - #### makeKey

          public static final Object makeKey(byte[] k,
                       int blockSize,
                       CryptixAESKeyCache.KeyCacheEntry keyData)
                                      throws InvalidKeyException

      Throws:
        `InvalidKeyException`

    - #### blockEncrypt

          public static final void blockEncrypt(byte[] in,
                          byte[] result,
                          int inOffset,
                          int outOffset,
                          Object sessionKey,
                          int blockSize)

      Encrypt exactly one block of plaintext.
      Parameters:
        `in` - The plaintext.
        `result` - 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,
                          int outOffset,
                          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(String[] args)