jmathlib.toolbox.crypto
Class aes

java.lang.Object
  extended by jmathlib.core.interpreter.RootObject
      extended by jmathlib.core.functions.Function
          extended by jmathlib.core.functions.ExternalFunction
              extended by jmathlib.toolbox.crypto.aes
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ErrorCodes, TokenConstants

public class aes
extends ExternalFunction

An external function for computing a mesh of a matrix

See Also:
Serialized Form

Field Summary
static int BLOCK_BITS
          AES block size in bits (N.B. the Rijndael algorithm itself allows for other sizes).
static int BLOCK_SIZE
          AES block size in bytes (N.B. the Rijndael algorithm itself allows for other sizes).
static int DIR_BOTH
           
static int DIR_DECRYPT
           
static int DIR_ENCRYPT
           
private  int Nk
           
private  int Nr
          Number of rounds (depends on key size).
private  int Nw
           
private static int[] rcon
          Round constants
private  int[] rdk
          Decryption key schedule
private  int[] rek
          Encryption key schedule
private static byte[] Sd
           
private static byte[] Se
           
private static java.lang.String SS
          Substitution table (S-box).
private static int[] Td0
           
private static int[] Td1
           
private static int[] Td2
           
private static int[] Td3
           
private static int[] Te0
           
private static int[] Te1
           
private static int[] Te2
           
private static int[] Te3
           
 
Fields inherited from class jmathlib.core.functions.ExternalFunction
IMAG, REAL
 
Fields inherited from class jmathlib.core.functions.Function
lastModified, name, pathAndFileName
 
Fields inherited from interface jmathlib.core.constants.ErrorCodes
ERR_BRACKET_OPEN, ERR_BRACKET_ORDER, ERR_FUNCTION_NOT_FOUND, ERR_FUNCTION_NOT_IMPLEMENTED, ERR_INSUFFICIENT_PARAMETERS, ERR_INVALID_PARAMETER, ERR_LVALUE_REQUIRED, ERR_MATRIX_SINGULAR, ERR_NOT_SQUARE_MATRIX, ERR_OPNOTSUPPORTED, ERR_TOO_MANY_PARAMETERS, ERR_USER_ERROR, ERR_VARIABLE_NOTDEFINED, OK, OK_FUNCTION_PROCESS
 
Fields inherited from interface jmathlib.core.constants.TokenConstants
ADDSUB_PRIORITY, AND_PRIORITY, ANDAND_PRIORITY, ASSIGN_PRIORITY, BRACKET_PRIORITY, COMPARE_PRIORITY, CONCAT, MATRIX, MULDIV_PRIORITY, OR_PRIORITY, OROR_PRIORITY, PARAMETER, POWER_PRIORITY, RELATION_PRIORITY, SINGLE, ttDelimiter, ttNotSet, ttOperand, ttOperator
 
Constructor Summary
aes()
           
 
Method Summary
 int blockSize()
          Block size in bytes
 void decrypt(byte[] ct, byte[] pt)
          Decrypt exactly one block (BLOCK_SIZE bytes) of ciphertext.
 void encrypt(byte[] pt, byte[] ct)
          Encrypt exactly one block (BLOCK_SIZE bytes) of plaintext.
 OperandToken evaluate(Token[] operands, GlobalValues globals)
          returns two matrices
private  void expandKey(byte[] cipherKey)
          Expand a cipher key into a full encryption key schedule.
 void finalize()
          Destroy all sensitive information in this object.
private  void invertKey()
          Compute the decryption schedule from the encryption schedule .
 int keySize()
          Block size in bytes
 void makeKey(byte[] cipherKey, int keyBits)
          Setup the AES key schedule (any cipher direction).
 void makeKey(byte[] cipherKey, int keySize, int direction)
          Setup the AES key schedule for encryption, decryption, or both.
 
Methods inherited from class jmathlib.core.functions.ExternalFunction
getParamCount
 
Methods inherited from class jmathlib.core.functions.Function
debugLine, equals, getLastModified, getName, getNArgIn, getNArgOut, getNoOfLeftHandArguments, getPathAndFileName, setLastModified, setName, setNoOfLeftHandArguments, setPathAndFileName, throwMathLibException
 
Methods inherited from class jmathlib.core.interpreter.RootObject
clone, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_BITS

public static final int BLOCK_BITS
AES block size in bits (N.B. the Rijndael algorithm itself allows for other sizes).

See Also:
Constant Field Values

BLOCK_SIZE

public static final int BLOCK_SIZE
AES block size in bytes (N.B. the Rijndael algorithm itself allows for other sizes).

See Also:
Constant Field Values

DIR_DECRYPT

public static final int DIR_DECRYPT
See Also:
Constant Field Values

DIR_ENCRYPT

public static final int DIR_ENCRYPT
See Also:
Constant Field Values

DIR_BOTH

public static final int DIR_BOTH
See Also:
Constant Field Values

SS

private static final java.lang.String SS
Substitution table (S-box).

See Also:
Constant Field Values

Se

private static final byte[] Se

Te0

private static final int[] Te0

Te1

private static final int[] Te1

Te2

private static final int[] Te2

Te3

private static final int[] Te3

Sd

private static final byte[] Sd

Td0

private static final int[] Td0

Td1

private static final int[] Td1

Td2

private static final int[] Td2

Td3

private static final int[] Td3

rcon

private static final int[] rcon
Round constants


Nr

private int Nr
Number of rounds (depends on key size).


Nk

private int Nk

Nw

private int Nw

rek

private int[] rek
Encryption key schedule


rdk

private int[] rdk
Decryption key schedule

Constructor Detail

aes

public aes()
Method Detail

evaluate

public OperandToken evaluate(Token[] operands,
                             GlobalValues globals)
returns two matrices

Specified by:
evaluate in class Function
Parameters:
operands[0] - = x values (e.g. [-2:0.2:2])
operands[1] - = y values (e.g. [-2:0.2:2])
operands[2] - = y values (e.g. [-2:0.2:2])
Returns:
[X,Y] as matrices

blockSize

public final int blockSize()
Block size in bytes


keySize

public final int keySize()
Block size in bytes


expandKey

private final void expandKey(byte[] cipherKey)
Expand a cipher key into a full encryption key schedule.

Parameters:
cipherKey - the cipher key (128, 192, or 256 bits).

invertKey

private final void invertKey()
Compute the decryption schedule from the encryption schedule .


makeKey

public final void makeKey(byte[] cipherKey,
                          int keySize,
                          int direction)
                   throws java.lang.RuntimeException
Setup the AES key schedule for encryption, decryption, or both.

Parameters:
cipherKey - the cipher key (128, 192, or 256 bits).
keyBits - size of the cipher key in bits.
direction - cipher direction (DIR_ENCRYPT, DIR_DECRYPT, or DIR_BOTH).
Throws:
java.lang.RuntimeException

makeKey

public final void makeKey(byte[] cipherKey,
                          int keyBits)
                   throws java.lang.RuntimeException
Setup the AES key schedule (any cipher direction).

Parameters:
cipherKey - the cipher key (128, 192, or 256 bits).
keyBits - size of the cipher key in bits.
Throws:
java.lang.RuntimeException

encrypt

public final void encrypt(byte[] pt,
                          byte[] ct)
Encrypt exactly one block (BLOCK_SIZE bytes) of plaintext.

Parameters:
pt - plaintext block.
ct - ciphertext block.

decrypt

public final void decrypt(byte[] ct,
                          byte[] pt)
Decrypt exactly one block (BLOCK_SIZE bytes) of ciphertext.

Parameters:
ct - ciphertext block.
pt - plaintext block.

finalize

public final void finalize()
Destroy all sensitive information in this object.

Overrides:
finalize in class java.lang.Object

FOOTER

BOTTOM