|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.crypto.AbstractCipher tribble.crypto.SymmetricCipher
Abstract base class for primitive symmetric cipher (encryption) algorithms. Symmetric ciphers use the same secret key for both encryption and decryption (hence the term symmetric).
Classes that extend this base class implement fundamental symmetric block ciphers, which comprise the foundation upon which this package is built.
Copyright ©2005 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code
provided that the original copyright and authorship notices remain
intact.
AsymmetricCipher
,
CipherSpi
Field Summary | |
protected int |
m_blockLen
Cipher block size (in bytes). |
Fields inherited from class tribble.crypto.AbstractCipher |
m_alg, m_decrypt, m_init, m_keyLen |
Constructor Summary | |
protected |
SymmetricCipher(java.lang.String alg,
int blockLen)
Constructor. |
Method Summary | |
protected abstract void |
blockDecrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Decrypt a block of ciphertext. |
protected abstract void |
blockEncrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Encrypt a block of plaintext. |
int |
getBlockSize()
Retrieve the block size of this cipher. |
protected static void |
test(SymmetricCipher ciph,
byte[] key,
byte[] input)
Test driver. |
protected static void |
test(SymmetricCipher ciph,
java.lang.String[] args)
Test driver. |
Methods inherited from class tribble.crypto.AbstractCipher |
clear, finalize, getAlgorithm, getKeySize, getKeySizes, initialize |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int m_blockLen
Constructor Detail |
protected SymmetricCipher(java.lang.String alg, int blockLen)
alg
- Cryptographic cipher algorithm name.blockLen
- Cipher block size (in bytes).Method Detail |
protected static void test(SymmetricCipher ciph, java.lang.String[] args) throws java.lang.Exception
Usage java tribble.crypto.SomeCipher [args...]
ciph
- Derived class cipher object to test.
java.lang.Exception
- Thrown if an error occurs in the encryption engine.protected static void test(SymmetricCipher ciph, byte[] key, byte[] input) throws java.lang.Exception
Usage java tribble.crypto.SomeCipher
ciph
- Derived class cipher object to test.key
- Symmetric key for the cipher.input
- Input test vector.
This array should be exactly the same length as the cipher block size.
java.lang.Exception
- Thrown if an error occurs in the encryption engine.public int getBlockSize()
protected abstract void blockEncrypt(byte[] in, int inOff, byte[] out, int outOff)
blockEncrypt
in class AbstractCipher
in
- Array containing a single block of plaintext bytes to encrypt.
The length of the block is exactly equal to the cipher block size
(m_blockLen
).inOff
- Index of the first byte of the plaintext block within array in to
encrypt.out
- Array that will be filled with the encrypted ciphertext block.
The length of the block is exactly equal to the cipher block size
(m_blockLen
).outOff
- Index of the first byte of array out to fill with the encrypted
ciphertext block.blockDecrypt()
protected abstract void blockDecrypt(byte[] in, int inOff, byte[] out, int outOff)
blockDecrypt
in class AbstractCipher
in
- Array containing a single block of ciphertext bytes to decrypt.
The length of the block is exactly equal to the cipher block size
(m_blockLen
).inOff
- Index of the first byte of the ciphertext block within array in
to decrypt.out
- Array that will be filled with the decrypted plaintext block.
The length of the block is exactly equal to the cipher block size
(m_blockLen
).outOff
- Index of the first byte of array out to fill with the decrypted
plaintext block.blockEncrypt()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |