net.i2p.crypto

## Class CryptixRijndael_Algorithm

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

-     public final class CryptixRijndael_Algorithm
      extends Object

  Rijndael AES algorithm implementation. Supports 128, 192, and 256-bit keys with 128-bit block size.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CryptixRijndael_Algorithm()`

  - ### Method Summary

    All Methods Static Methods Concrete 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()`
    `static int` | `getRounds(int keySize, int blockSize)` Return The number of rounds for a given Rijndael's key and block sizes.
    `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, net.i2p.crypto.CryptixAESKeyCache.KeyCacheEntry keyData)` Expand a user-supplied key material into a session key.

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

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

- - ### Constructor Detail

    - #### CryptixRijndael_Algorithm

          public CryptixRijndael_Algorithm()

  - ### Method Detail

    - #### 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. This is a CryptixAESKeyCache.KeyCacheEntry. We use the Kd field, for decryption. The actual parameter type is opaque, changed in 0.9.31, and is subject to change again.

    - #### 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. This is a CryptixAESKeyCache.KeyCacheEntry. We use the Kd field, for decryption. The actual parameter type is opaque, changed in 0.9.31, and is subject to change again.
        `blockSize` - The block size in bytes of this Rijndael.

    - #### 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. This is a CryptixAESKeyCache.KeyCacheEntry. We use the Ke field for encryption. The actual parameter type is opaque, changed in 0.9.31, and is subject to change again.

    - #### 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. This is a CryptixAESKeyCache.KeyCacheEntry. We use the Ke field for encryption. The actual parameter type is opaque, changed in 0.9.31, and is subject to change again.
        `blockSize` - The block size in bytes of this Rijndael.

    - #### blockSize

          public static final int blockSize()

      Returns:
        The default length in bytes of the Algorithm input block.

    - #### 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.

    - #### 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.
      Returns:
        an array of two int[][] containing { Ke, Kd }
      Throws:
        `InvalidKeyException` - If the key is invalid.

    - #### 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, must be 16, 24, or 32.
      Returns:
        a CryptixAESKeyCache.KeyCacheEntry containing { Ke, Kd }. The actual return type is opaque, changed in 0.9.31, and is subject to change again.
      Throws:
        `InvalidKeyException` - If the key is invalid.

    - #### makeKey

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

      Expand a user-supplied key material into a session key. Not for external use, not a public API.
      Parameters:
        `k` - The 128/192/256-bit user-key to use.
        `blockSize` - The block size in bytes of this Rijndael, must be 16, 24, or 32.
        `keyData` - a cached data structure to fill in, or null.
      Returns:
        a CryptixAESKeyCache.KeyCacheEntry containing { Ke, Kd }. If keyData is non-null, this is keyData. If keyData is null, this is newly allocated.
      Throws:
        `InvalidKeyException` - If the key is invalid.