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
           
 
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)
          returns two matrices
 void finalize()
          Destroy all sensitive information in this object.
 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, getContextList, getDebug, getFunctionManager, getGlobalVariables, getGraphicsManager, getInterpreter, getPluginsManager, getVariable, getVariables, getWorkingDirectory, setConstants, setDebug, setWorkingDirectory, toString, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, 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
Constructor Detail

aes

public aes()
Method Detail

evaluate

public OperandToken evaluate(Token[] operands)
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


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