|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.crypto.AbstractCipher
Abstract base class for fundamental cipher (encryption) algorithms.
Cipher objects (of type javax.crypto.Cipher) are constructed from a
combination of a cipher SPI object, which is one of generic cipher algorithm
types derived from class CipherSpi
, and a primitive cipher
algorithm, which is a class derived from this class, AbstractCipher
.
Cipher algorithm implementations derived from this class are further divided
into two types, SymmetricCipher
and AsymmetricCipher
.
These two base classes implement the primitive encryption cipher algorithms
that serve as the foundation upon which the rest of this cryptographic package
is built. These two classes, in other words, are the fundamental encryption
algorithms for this entire package.
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
,
SymmetricCipher
,
CipherSpi
Field Summary | |
protected java.lang.String |
m_alg
Cipher algorithm name. |
protected boolean |
m_decrypt
Cipher is in decryption, not encryption, mode. |
protected boolean |
m_init
Cipher has been initialized. |
protected int |
m_keyLen
Cipher Key size (in bytes). |
Constructor Summary | |
protected |
AbstractCipher(java.lang.String alg)
Constructor. |
Method Summary | |
protected abstract void |
blockDecrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Decrypt a single block of ciphertext. |
protected abstract void |
blockEncrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Encrypt a single block of plaintext. |
protected abstract void |
clear()
Reset this cipher, wiping all sensitive information. |
protected void |
finalize()
Finalization. |
java.lang.String |
getAlgorithm()
Retrieve the algorithm name of this cipher. |
int |
getKeySize()
Retrieve the key size of this cipher. |
int[] |
getKeySizes()
Retrieve the key sizes supported by this cipher. |
protected abstract void |
initialize(byte[] key,
boolean decrypt)
Initialize this cipher. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String m_alg
protected int m_keyLen
protected boolean m_decrypt
protected boolean m_init
Constructor Detail |
protected AbstractCipher(java.lang.String alg)
alg
- Cryptographic cipher algorithm name.Method Detail |
public java.lang.String getAlgorithm()
public int getKeySize()
public int[] getKeySizes()
getKeySize()
protected abstract void initialize(byte[] key, boolean decrypt) throws java.security.InvalidKeyException
key
- The encryption key for this cipher.decrypt
- If true, this indicates that this cipher is to be initialized for
decrypting, otherwise it is to be initialized for encrypting.
java.security.InvalidKeyException
clear()
protected abstract void clear()
This method will be called after this cipher object is no longer needed. It should overwrite any sensitive data contained within this object (e.g., encryption key schedules). This cipher object can no longer be used after this method has been called.
initialize()
protected abstract void blockEncrypt(byte[] in, int inOff, byte[] out, int outOff)
in
- Plaintext block of bytes to encrypt.
(The size of the block is determined by the algorithm implementation.)inOff
- Index of the first byte in array in to encrypt.out
- Array that will be filled with the encrypted ciphertext bytes.
(The size of the block is determined by the algorithm implementation.)outOff
- Index of the first byte of array out to fill with the encrypted
ciphertext block.blockDecrypt()
,
initialize()
protected abstract void blockDecrypt(byte[] in, int inOff, byte[] out, int outOff)
in
- Ciphertext block of bytes to decrypt.
(The size of the block is determined by the algorithm implementation.)inOff
- Index of the first byte in array in to decrypt.out
- Array that will be filled with the decrypted plaintext bytes.
(The size of the block is determined by the algorithm implementation.)outOff
- Index of the first byte of array out to fill with the decrypted
plaintext block.blockEncrypt()
,
initialize()
protected void finalize() throws java.lang.Throwable
clear()
,
wiping all sensitive information prior to this object being
garbage-collected.
java.lang.Throwable
clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |