|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.crypto.AbstractCipher tribble.crypto.AsymmetricCipher
Asymmetric (public key) block cipher base class.
This base class provides the foundation for cipher (encryption) algorithm implementations having fixed-length blocks and key lengths, and which utilize a public/private (asymmetric) key pair for encryption and decryption.
Copyright ©2003-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.
SymmetricCipher
,
CipherSpi
Field Summary |
Fields inherited from class tribble.crypto.AbstractCipher |
m_alg, m_decrypt, m_init, m_keyLen |
Constructor Summary | |
protected |
AsymmetricCipher(java.lang.String alg)
Constructor. |
protected |
AsymmetricCipher(java.lang.String alg,
int blockLen)
Constructor. |
Method Summary | |
protected abstract void |
blockDecrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Decrypt a single block of bytes using this cipher. |
protected abstract void |
blockEncrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Encrypt a single block of bytes using this cipher. |
abstract int |
getCipherBlockSize()
Retrieve the ciphertext block size (in bytes) of this cipher. |
abstract int |
getPlainBlockSize()
Retrieve the plaintext block size (in bytes) of this cipher. |
protected abstract void |
initialize(java.security.spec.KeySpec key,
boolean decrypt)
Initialize this cipher. |
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 |
Constructor Detail |
protected AsymmetricCipher(java.lang.String alg)
alg
- Cryptographic cipher algorithm name.protected AsymmetricCipher(java.lang.String alg, int blockLen)
alg
- Cryptographic cipher algorithm name.blockLen
- Cipher block size (in bytes), which is ignored.Method Detail |
public abstract int getPlainBlockSize()
getCipherBlockSize()
public abstract int getCipherBlockSize()
getPlainBlockSize()
protected abstract void initialize(java.security.spec.KeySpec key, boolean decrypt) throws java.security.InvalidKeyException
key
- The asymmetric (public or private) key for this cipher.
This is either a java.security.PublicKey or a
java.security.PrivateKey object.decrypt
- Specifies that this cipher is to be set up in decryption mode.
java.security.InvalidKeyException
protected abstract void blockEncrypt(byte[] in, int inOff, byte[] out, int outOff)
blockEncrypt
in class AbstractCipher
in
- Plaintext block of bytes to encrypt.
The length of this block is the value returned by
getPlainBlockSize()
.inOff
- Index of the first byte in array in to encrypt.out
- Array that will be filled with the encrypted ciphertext bytes.
The length of this block is the value returned by
getCipherBlockSize()
.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)
blockDecrypt
in class AbstractCipher
in
- Ciphertext block of bytes to decrypt.
The length of this block is the value returned by
getCipherBlockSize()
.inOff
- Index of the first byte in array in to decrypt.out
- Array that will be filled with the decrypted plaintext bytes.
The length of this block is the value returned by
getPlainBlockSize()
.outOff
- Index of the first byte of array out to fill with the decrypted
plaintext block.blockEncrypt()
,
initialize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |