ccs.crypt
Class AESWrapper
java.lang.Object
ccs.crypt.AESWrapper
- All Implemented Interfaces:
- org.bouncycastle.crypto.BlockCipher
public class AESWrapper
- extends java.lang.Object
- implements org.bouncycastle.crypto.BlockCipher
A wrapper around the BouncyCastle AES engine (blend version). The wrapper
provides modified key handling to cope with arbitrary-length keys; AES
itself only supports 128, 192, or 256-bit keys. The rules are simple:
- Keys shorter than 8 bytes are disallowed by fiat.
- Keys whose lengths fall between the supported lengths are
padded to the next allowed length.
- Keys longer than 32 bytes are presumed to be pass-phrases; these
are hashed down to 160 bits, and then padded up to 192 bits.
The "blend" implementation strategy of AES was chosen over the other two -
"fast" and "light" - because, in tests, the light version was slowest by
a large margin, whereas the blend version was practically a dead heat
with the fast version and requires usefully less space.
Field Summary |
static int |
BASIC
Default key-transformation mode. |
static int |
DIGEST512
Key-transformation mode. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BASIC
public static final int BASIC
- Default key-transformation mode. A key which is exactly 16, 24 or 32
bytes long is used as-is. A key which is less than 8 bytes long is
disallowed. A key which falls between the lengths above is padded
to the next defined length. A key longer than 32 bytes is hashed down
to 20 bytes and padded back up to 24 bytes.
- See Also:
- Constant Field Values
DIGEST512
public static final int DIGEST512
- Key-transformation mode. As BASIC, except that a key which is exactly 64
bytes long (512 bits) is converted into a 32-byte key by XOR-ing the
two halves together.
- See Also:
- Constant Field Values
AESWrapper
public AESWrapper()
setKeyTransform
public void setKeyTransform(int keymode)
- Set the key-transformation mode.
- Parameters:
keymode
- One of the constants defined in this class.
init
public void init(boolean encrypting,
org.bouncycastle.crypto.CipherParameters params)
- Specified by:
init
in interface org.bouncycastle.crypto.BlockCipher
getAlgorithmName
public java.lang.String getAlgorithmName()
- Specified by:
getAlgorithmName
in interface org.bouncycastle.crypto.BlockCipher
getBlockSize
public int getBlockSize()
- Specified by:
getBlockSize
in interface org.bouncycastle.crypto.BlockCipher
processBlock
public int processBlock(byte[] in,
int inOff,
byte[] out,
int outOff)
throws org.bouncycastle.crypto.DataLengthException,
java.lang.IllegalStateException
- Specified by:
processBlock
in interface org.bouncycastle.crypto.BlockCipher
- Throws:
org.bouncycastle.crypto.DataLengthException
java.lang.IllegalStateException
reset
public void reset()
- Specified by:
reset
in interface org.bouncycastle.crypto.BlockCipher