edu.rit.crypto.blockcipher
Class AES256CipherSmp

java.lang.Object
  extended by edu.rit.crypto.blockcipher.BlockCipher
      extended by edu.rit.crypto.blockcipher.AES256CipherSmp

public class AES256CipherSmp
extends BlockCipher

Class AES256CipherSmp provides a BlockCipher using the Advanced Encryption Standard (AES) with a 128-bit (16-byte) block length and a 256-bit (32-byte) key length. The AES specification may be found at http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf.

Unlike class AES256Cipher, class AES256CipherSmp includes extra padding in the memory layout to avoid cache interference when running a program with multiple threads on an SMP parallel computer.

Note: However, class AES256CipherSmp is not multiple thread safe.


Constructor Summary
AES256CipherSmp(byte[] theKey)
          Construct a new AES-256 cipher object with the given secret key.
 
Method Summary
 void encrypt(byte[] thePlaintext, byte[] theCiphertext)
          Encrypt the given plaintext block.
 void erase()
          Erase this block cipher object's key material.
protected  void finalize()
          Finalize this block cipher object.
 void setKey(byte[] theKey)
          Set the key to be used for all subsequent encryptions and decryptions.
 
Methods inherited from class edu.rit.crypto.blockcipher.BlockCipher
encrypt, getBlockLength, getKeyLength
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AES256CipherSmp

public AES256CipherSmp(byte[] theKey)
Construct a new AES-256 cipher object with the given secret key. After the constructor returns, theKey is no longer needed and may be erased (set to all 0s). The length of theKey must be at least 32. Only the first 32 bytes are used.

Parameters:
theKey - Key (byte array).
Throws:
NullPointerException - (unchecked exception) Thrown if theKey is null.
IllegalArgumentException - (unchecked exception) Thrown if theKey.length < 32.
Method Detail

setKey

public void setKey(byte[] theKey)
Set the key to be used for all subsequent encryptions and decryptions. After this method returns, theKey is no longer needed and may be erased (set to all 0s). The length of theKey must be at least 32. Only the first 32 bytes are used.

Specified by:
setKey in class BlockCipher
Parameters:
theKey - Key (byte array).
Throws:
NullPointerException - (unchecked exception) Thrown if theKey is null.
IllegalArgumentException - (unchecked exception) Thrown if theKey.length < 32.

encrypt

public void encrypt(byte[] thePlaintext,
                    byte[] theCiphertext)
Encrypt the given plaintext block. On input, thePlaintext contains the plaintext. On output, the contents of theCiphertext have been replaced by the ciphertext. thePlaintext and theCiphertext may be the same block. The length of thePlaintext must be at least 16. Only the first 16 bytes are read. The length of theCiphertext must be at least 16. Only the first 16 bytes are written.

Specified by:
encrypt in class BlockCipher
Parameters:
thePlaintext - Input plaintext block to be encrypted.
theCiphertext - Output ciphertext block.
Throws:
NullPointerException - (unchecked exception) Thrown if thePlaintext is null or theCiphertext is null.
IllegalArgumentException - (unchecked exception) Thrown if thePlaintext.length < 16 or theCiphertext.length < 16.
IllegalStateException - (unchecked exception) Thrown if the key has been erased and not re-set.

erase

public void erase()
Erase this block cipher object's key material.

Specified by:
erase in class BlockCipher

finalize

protected void finalize()
Finalize this block cipher object. This block cipher object is erased if it is not already erased.

Overrides:
finalize in class Object


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.