edu.rit.crypto.blockcipher
Class AES256CipherSmp
- java.lang.Object
-
- edu.rit.crypto.blockcipher.BlockCipher
-
- 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
Constructors Constructor and Description AES256CipherSmp(byte[] theKey)Construct a new AES-256 cipher object with the given secret key.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidencrypt(byte[] thePlaintext, byte[] theCiphertext)Encrypt the given plaintext block.voiderase()Erase this block cipher object's key material.voidsetKey(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
-
-
-
-
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:
java.lang.NullPointerException- (unchecked exception) Thrown if theKey is null.java.lang.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:
setKeyin classBlockCipher- Parameters:
theKey- Key (byte array).- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theKey is null.java.lang.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:
encryptin classBlockCipher- Parameters:
thePlaintext- Input plaintext block to be encrypted.theCiphertext- Output ciphertext block.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if thePlaintext is null or theCiphertext is null.java.lang.IllegalArgumentException- (unchecked exception) Thrown if thePlaintext.length < 16 or theCiphertext.length < 16.java.lang.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:
erasein classBlockCipher
-
-
DMelt 3.0 © DataMelt by jWork.ORG