Quadcap Embeddable Database

com.quadcap.crypto.Rijndael Class Reference

Inheritance diagram for com.quadcap.crypto.Rijndael:

com.quadcap.crypto.AbstractSymmetricKey com.quadcap.crypto.SymmetricKey com.quadcap.crypto.SymmetricKey List of all members.

Detailed Description

Rijndael --pronounced Reindaal-- is a symmetric cipher with a 128-bit block size and variable key-size (128-, 192- and 256-bit).

Rijndael was designed by Vincent Rijmen and Joan Daemen.

Version:
Revision
1.3
Author:
Raif S. Naffah

Paulo S. L. M. Barreto (pbarreto@cryptix.org)

Jeroen C. van Gelderen (gelderen@cryptix.org)

Edwin Woudt (edwin@cryptix.org)

Since:
Cryptix 3.1.3/3.2.0

Definition at line 74 of file Rijndael.java.

Public Member Functions

 Rijndael ()
 Default constructor.

void init (String s) throws Exception
 Initialize key from serialized representation.

void init (Random r)
 Initialize: Create a random key.

String toString ()
 Return the serialized form of the key.

void encrypt (ByteBuffer m, ByteBuffer c)
 Encrypt a buffer (must be multiple of 8 bytes).

void decrypt (ByteBuffer c, ByteBuffer m)
 Decrypt a buffer (must be a multiple of 8 bytes).

int getBlockSize ()
 The key's block size.


Protected Member Functions

void coreInit (byte[] userKey, boolean decrypt) throws Exception

Package Functions

final void init (byte[] k)
 Initialize from key bytes.


Static Package Functions

 [static initializer]

Package Attributes

byte[] keyBytes = null

Static Package Attributes

final int KEYSIZE = 16

Private Member Functions

void blockEncrypt (ByteBuffer in, ByteBuffer out)
 Encrypt exactly one block of plaintext.

void blockDecrypt (ByteBuffer in, ByteBuffer out)
 Decrypt exactly one block of plaintext.


Static Private Member Functions

int[] makeKey (byte[] keyBytes, boolean decrypt) throws Exception
 Expand a user-supplied key material into a session key.

void invertKey (int[] K)
final int getRounds (int keySize)
 Return The number of rounds for a given Rijndael keysize.


Private Attributes

boolean ROUNDS_12
boolean ROUNDS_14
boolean decrypt
 True if in decrypt mode.

int[] K
 Subkeys.

int limit
 (ROUNDS-1) * 4


Static Private Attributes

final int BLOCK_SIZE = 16
final String SS
final byte[] S
final int[] T1
final int[] U1
final byte[] rcon = new byte[30]


Constructor & Destructor Documentation

com.quadcap.crypto.Rijndael.Rijndael  ) 
 

Default constructor.

Definition at line 80 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.init().


Member Function Documentation

com.quadcap.crypto.Rijndael.[static initializer]  )  [static, package]
 

void com.quadcap.crypto.Rijndael.blockDecrypt ByteBuffer  in,
ByteBuffer  out
[private]
 

Decrypt exactly one block of plaintext.

Definition at line 356 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.blockDecrypt(), com.quadcap.crypto.Rijndael.K, com.quadcap.crypto.Rijndael.ROUNDS_12, and com.quadcap.crypto.Rijndael.ROUNDS_14.

Referenced by com.quadcap.crypto.Rijndael.blockDecrypt(), and com.quadcap.crypto.Rijndael.decrypt().

void com.quadcap.crypto.Rijndael.blockEncrypt ByteBuffer  in,
ByteBuffer  out
[private]
 

Encrypt exactly one block of plaintext.

Definition at line 287 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.blockEncrypt(), com.quadcap.crypto.Rijndael.K, com.quadcap.crypto.Rijndael.limit, com.quadcap.crypto.Rijndael.S, and com.quadcap.crypto.Rijndael.T1.

Referenced by com.quadcap.crypto.Rijndael.blockEncrypt(), and com.quadcap.crypto.Rijndael.encrypt().

void com.quadcap.crypto.Rijndael.coreInit byte[]  userKey,
boolean  decrypt
throws Exception [protected]
 

Definition at line 156 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.coreInit(), com.quadcap.crypto.Rijndael.getRounds(), com.quadcap.crypto.Rijndael.invertKey(), com.quadcap.crypto.Rijndael.K, com.quadcap.crypto.Rijndael.makeKey(), com.quadcap.crypto.Rijndael.ROUNDS_12, and com.quadcap.crypto.Rijndael.ROUNDS_14.

Referenced by com.quadcap.crypto.Rijndael.coreInit(), and com.quadcap.crypto.Rijndael.init().

void com.quadcap.crypto.Rijndael.decrypt ByteBuffer  c,
ByteBuffer  m
[virtual]
 

Decrypt a buffer (must be a multiple of 8 bytes).

Implements com.quadcap.crypto.AbstractSymmetricKey.

Definition at line 134 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.blockDecrypt(), and com.quadcap.crypto.Rijndael.decrypt.

void com.quadcap.crypto.Rijndael.encrypt ByteBuffer  m,
ByteBuffer  c
[virtual]
 

Encrypt a buffer (must be multiple of 8 bytes).

Implements com.quadcap.crypto.AbstractSymmetricKey.

Definition at line 125 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.blockEncrypt(), and com.quadcap.crypto.Rijndael.encrypt().

Referenced by com.quadcap.crypto.Rijndael.encrypt().

int com.quadcap.crypto.Rijndael.getBlockSize  )  [virtual]
 

The key's block size.

Implements com.quadcap.crypto.AbstractSymmetricKey.

Definition at line 176 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.BLOCK_SIZE.

final int com.quadcap.crypto.Rijndael.getRounds int  keySize  )  [static, private]
 

Return The number of rounds for a given Rijndael keysize.

Parameters:
keySize The size of the user key material in bytes. MUST be one of (16, 24, 32).
Returns:
The number of rounds.

Definition at line 614 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.getRounds().

Referenced by com.quadcap.crypto.Rijndael.coreInit(), com.quadcap.crypto.Rijndael.getRounds(), and com.quadcap.crypto.Rijndael.makeKey().

void com.quadcap.crypto.Rijndael.init Random  r  )  [virtual]
 

Initialize: Create a random key.

Implements com.quadcap.crypto.AbstractSymmetricKey.

Definition at line 109 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.KEYSIZE.

final void com.quadcap.crypto.Rijndael.init byte[]  k  )  [package]
 

Initialize from key bytes.

Definition at line 94 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.coreInit(), and com.quadcap.crypto.Rijndael.Rijndael().

void com.quadcap.crypto.Rijndael.init String  s  )  throws Exception [virtual]
 

Initialize key from serialized representation.

Implements com.quadcap.crypto.AbstractSymmetricKey.

Definition at line 85 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.init().

Referenced by com.quadcap.crypto.KeyFactory.createSymmetricKey(), and com.quadcap.crypto.Rijndael.init().

void com.quadcap.crypto.Rijndael.invertKey int[]  K  )  [static, private]
 

Definition at line 570 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.invertKey(), and com.quadcap.crypto.Rijndael.U1.

Referenced by com.quadcap.crypto.Rijndael.coreInit(), and com.quadcap.crypto.Rijndael.invertKey().

int [] com.quadcap.crypto.Rijndael.makeKey byte[]  keyBytes,
boolean  decrypt
throws Exception [static, private]
 

Expand a user-supplied key material into a session key.

Parameters:
key The 128/192/256-bit user-key to use.
Exceptions:
InvalidKeyException If the key is invalid.

Definition at line 516 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.getRounds(), com.quadcap.crypto.Rijndael.keyBytes, com.quadcap.crypto.Rijndael.makeKey(), com.quadcap.crypto.Rijndael.rcon, and com.quadcap.crypto.Rijndael.S.

Referenced by com.quadcap.crypto.Rijndael.coreInit(), and com.quadcap.crypto.Rijndael.makeKey().

String com.quadcap.crypto.Rijndael.toString  ) 
 

Return the serialized form of the key.

Implements com.quadcap.crypto.SymmetricKey.

Definition at line 118 of file Rijndael.java.

References com.quadcap.crypto.Rijndael.keyBytes.


Member Data Documentation

final int com.quadcap.crypto.Rijndael.BLOCK_SIZE = 16 [static, private]
 

Definition at line 178 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.getBlockSize().

boolean com.quadcap.crypto.Rijndael.decrypt [private]
 

True if in decrypt mode.

Definition at line 147 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.decrypt().

int [] com.quadcap.crypto.Rijndael.K [private]
 

Subkeys.

Definition at line 150 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.blockDecrypt(), com.quadcap.crypto.Rijndael.blockEncrypt(), and com.quadcap.crypto.Rijndael.coreInit().

byte [] com.quadcap.crypto.Rijndael.keyBytes = null [package]
 

Definition at line 75 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.makeKey(), and com.quadcap.crypto.Rijndael.toString().

final int com.quadcap.crypto.Rijndael.KEYSIZE = 16 [static, package]
 

Definition at line 140 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.init().

int com.quadcap.crypto.Rijndael.limit [private]
 

(ROUNDS-1) * 4

Definition at line 153 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.blockEncrypt().

final byte [] com.quadcap.crypto.Rijndael.rcon = new byte[30] [static, private]
 

Definition at line 218 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.makeKey().

boolean com.quadcap.crypto.Rijndael.ROUNDS_12 [private]
 

Definition at line 143 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.blockDecrypt(), and com.quadcap.crypto.Rijndael.coreInit().

boolean com.quadcap.crypto.Rijndael.ROUNDS_14 [private]
 

Definition at line 143 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.blockDecrypt(), and com.quadcap.crypto.Rijndael.coreInit().

final byte [] com.quadcap.crypto.Rijndael.S [static, private]
 

Initial value:

new byte[256] Si = new byte[256]

Definition at line 199 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.blockEncrypt(), and com.quadcap.crypto.Rijndael.makeKey().

final String com.quadcap.crypto.Rijndael.SS [static, private]
 

Initial value:

"\u637C\u777B\uF26B\u6FC5\u3001\u672B\uFED7\uAB76" + "\uCA82\uC97D\uFA59\u47F0\uADD4\uA2AF\u9CA4\u72C0" + "\uB7FD\u9326\u363F\uF7CC\u34A5\uE5F1\u71D8\u3115" + "\u04C7\u23C3\u1896\u059A\u0712\u80E2\uEB27\uB275" + "\u0983\u2C1A\u1B6E\u5AA0\u523B\uD6B3\u29E3\u2F84" + "\u53D1\u00ED\u20FC\uB15B\u6ACB\uBE39\u4A4C\u58CF" + "\uD0EF\uAAFB\u434D\u3385\u45F9\u027F\u503C\u9FA8" + "\u51A3\u408F\u929D\u38F5\uBCB6\uDA21\u10FF\uF3D2" + "\uCD0C\u13EC\u5F97\u4417\uC4A7\u7E3D\u645D\u1973" + "\u6081\u4FDC\u222A\u9088\u46EE\uB814\uDE5E\u0BDB" + "\uE032\u3A0A\u4906\u245C\uC2D3\uAC62\u9195\uE479" + "\uE7C8\u376D\u8DD5\u4EA9\u6C56\uF4EA\u657A\uAE08" + "\uBA78\u252E\u1CA6\uB4C6\uE8DD\u741F\u4BBD\u8B8A" + "\u703E\uB566\u4803\uF60E\u6135\u57B9\u86C1\u1D9E" + "\uE1F8\u9811\u69D9\u8E94\u9B1E\u87E9\uCE55\u28DF" + "\u8CA1\u890D\uBFE6\u4268\u4199\u2D0F\uB054\uBB16"

Definition at line 180 of file Rijndael.java.

final int [] com.quadcap.crypto.Rijndael.T1 [static, private]
 

Initial value:

new int[256] T2 = new int[256] T3 = new int[256] T4 = new int[256] T5 = new int[256] T6 = new int[256] T7 = new int[256] T8 = new int[256]

Definition at line 203 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.blockEncrypt().

final int [] com.quadcap.crypto.Rijndael.U1 [static, private]
 

Initial value:

new int[256] U2 = new int[256] U3 = new int[256] U4 = new int[256]

Definition at line 213 of file Rijndael.java.

Referenced by com.quadcap.crypto.Rijndael.invertKey().