|
|||||||||
Home >> All >> cryptix >> jce >> provider >> [ cipher overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
cryptix.jce.provider.cipher
Class BlockCipher

java.lang.Objectjavax.crypto.CipherSpi
cryptix.jce.provider.cipher.BlockCipher
- Direct Known Subclasses:
- Blowfish, CAST5, DES, IDEA, MARS, RC2, RC6, Rijndael, Serpent, SKIPJACK, Square, TripleDES, Twofish
- public abstract class BlockCipher
- extends javax.crypto.CipherSpi
A fully constructed Cipher instance looks like this:
+------------------------------------------+ | CipherSpi (API methods) | | | | +--------------------------------------+ | | | Padding | | | | | | | | +----------------------------------+ | | | | | Mode | | | | | | | | | | | | +------------------------------+ | | | | | | | CipherSpi | | | | | | | | (blockcipher implementation) | | | | | | | | | | | | | | | +------------------------------+ | | | | | | | | | | | +----------------------------------+ | | | | | | | +--------------------------------------+ | | | +------------------------------------------+
- Version:
- $Revision: 1.15 $
Field Summary | |
private java.lang.String |
algorithm
What algorithm is used |
private int |
BLOCK_SIZE
Our blocksize |
private java.security.Key |
key
Our key. |
private Mode |
mode
|
private Padding |
padding
|
private int |
state
State |
private static int |
STATE_DECRYPT
|
private static int |
STATE_ENCRYPT
|
private static int |
STATE_UNINITIALIZED
|
Constructor Summary | |
protected |
BlockCipher(int blockSize)
Construct a new BlockCipher (CipherSpi) with an zero-length name "" and given block size. |
protected |
BlockCipher(java.lang.String algorithm,
int blockSize)
Construct a new BlockCipher (CipherSpi) with the given name and block size. |
Method Summary | |
java.lang.Object |
clone()
Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons). |
(package private) abstract void |
coreCrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
Encrypt a given buffer. |
(package private) int |
coreGetBlockSize()
|
(package private) abstract void |
coreInit(java.security.Key key,
boolean decrypt)
|
protected byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen)
Implemented in terms of engineDoFinal(byte[], int, int, byte[], int) |
protected int |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
Finishes a multi-part transformation or transforms a portion of a byte array, and stores the transformed bytes in the supplied array. |
protected int |
engineGetBlockSize()
Returns the block size of the underlying cipher. |
protected byte[] |
engineGetIV()
Returns a copy of the initialization vector (IV) used in this cipher. |
protected int |
engineGetKeySize(java.security.Key key)
Return the length of the given key in bits. |
protected int |
engineGetOutputSize(int inputLen)
Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes). |
protected java.security.AlgorithmParameters |
engineGetParameters()
Returns the parameters that this cipher is using. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes this cipher with an operation mode, key, parameters, and source of randomness. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.AlgorithmParameters params,
java.security.SecureRandom random)
Initializes this cipher with an operation mode, key, parameters, and source of randomness. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.SecureRandom random)
Initialize this blockcipher for encryption or decryption. |
protected void |
engineSetMode(java.lang.String mode)
Set the mode in which this cipher is to run. |
protected void |
engineSetPadding(java.lang.String padding)
Set the method with which the input is to be padded. |
protected byte[] |
engineUpdate(byte[] input,
int inputOffset,
int inputLen)
Implemented in terms of engineUpdate(byte[], int, int, byte[], int) |
protected int |
engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
Continue with a multi-part transformation, storing the transformed bytes into the specified array. |
Methods inherited from class javax.crypto.CipherSpi |
engineDoFinal, engineUnwrap, engineUpdate, engineWrap |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
state
private int state
- State
STATE_UNINITIALIZED
private static final int STATE_UNINITIALIZED
- See Also:
- Constant Field Values
STATE_DECRYPT
private static final int STATE_DECRYPT
- See Also:
- Constant Field Values
STATE_ENCRYPT
private static final int STATE_ENCRYPT
- See Also:
- Constant Field Values
BLOCK_SIZE
private final int BLOCK_SIZE
- Our blocksize
key
private java.security.Key key
- Our key. We need it when we reset ourselves.
algorithm
private java.lang.String algorithm
- What algorithm is used
padding
private Padding padding
mode
private Mode mode
Constructor Detail |
BlockCipher
protected BlockCipher(int blockSize)
- Construct a new BlockCipher (CipherSpi) with an zero-length name ""
and given block size.
BlockCipher
protected BlockCipher(java.lang.String algorithm, int blockSize)
- Construct a new BlockCipher (CipherSpi) with the given name and
block size.
Method Detail |
clone
public final java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Always throws a CloneNotSupportedException (cloning of ciphers is not
supported for security reasons).
engineSetMode
protected final void engineSetMode(java.lang.String mode) throws java.security.NoSuchAlgorithmException
- Description copied from class:
javax.crypto.CipherSpi
- Set the mode in which this cipher is to run.
engineSetPadding
protected final void engineSetPadding(java.lang.String padding) throws javax.crypto.NoSuchPaddingException
- Description copied from class:
javax.crypto.CipherSpi
- Set the method with which the input is to be padded.
engineGetBlockSize
protected final int engineGetBlockSize()
- Description copied from class:
javax.crypto.CipherSpi
- Returns the block size of the underlying cipher.
engineGetKeySize
protected int engineGetKeySize(java.security.Key key) throws java.security.InvalidKeyException
- Description copied from class:
javax.crypto.CipherSpi
Return the length of the given key in bits.
For compatibility this method is not declared
abstract
, and the default implementation will throw an java.lang.UnsupportedOperationException. Concrete subclasses should override this method to return the correct value.
engineGetOutputSize
protected final int engineGetOutputSize(int inputLen)
- Returns the length in bytes that an output buffer would need to be in
order to hold the result of the next update or doFinal operation, given
the input length
inputLen
(in bytes). This call takes into account any unprocessed (buffered) data from a previous update call(s), and padding. The actual output length of the nextupdate or doFinal
call may be smaller than the length returned by this method. For ciphers with a padding, calling the update method will generally return less data than predicted by this function.
engineGetIV
protected final byte[] engineGetIV()
- Returns a copy of the initialization vector (IV) used in this cipher.
engineGetParameters
protected final java.security.AlgorithmParameters engineGetParameters()
- Description copied from class:
javax.crypto.CipherSpi
- Returns the parameters that this cipher is using. This may be the
parameters used to initialize this cipher, or it may be parameters
that have been initialized with random values.
engineInit
protected final void engineInit(int opmode, java.security.Key key, java.security.SecureRandom random) throws java.security.InvalidKeyException
- Initialize this blockcipher for encryption or decryption.
If the cipher requires randomness, it is taken from
random
. Randomness is required for modes that use IVs and might be required for some padding schemes.
engineInit
protected final void engineInit(int opmode, java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
- Description copied from class:
javax.crypto.CipherSpi
- Initializes this cipher with an operation mode, key, parameters,
and source of randomness. If this cipher requires any other
initializing data, for example an initialization vector, then it should
generate it from the provided source of randomness.
engineInit
protected final void engineInit(int opmode, java.security.Key key, java.security.AlgorithmParameters params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
- Description copied from class:
javax.crypto.CipherSpi
- Initializes this cipher with an operation mode, key, parameters,
and source of randomness. If this cipher requires any other
initializing data, for example an initialization vector, then it should
generate it from the provided source of randomness.
engineUpdate
protected final int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws javax.crypto.ShortBufferException
- Description copied from class:
javax.crypto.CipherSpi
- Continue with a multi-part transformation, storing the transformed
bytes into the specified array.
engineUpdate
protected final byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
- Implemented in terms of engineUpdate(byte[], int, int, byte[], int)
engineDoFinal
protected final int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws javax.crypto.ShortBufferException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
- Description copied from class:
javax.crypto.CipherSpi
- Finishes a multi-part transformation or transforms a portion of a
byte array, and stores the transformed bytes in the supplied array.
engineDoFinal
protected final byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
- Implemented in terms of engineDoFinal(byte[], int, int, byte[], int)
coreInit
abstract void coreInit(java.security.Key key, boolean decrypt) throws java.security.InvalidKeyException
coreCrypt
abstract void coreCrypt(byte[] in, int inOffset, byte[] out, int outOffset)
- Encrypt a given buffer. in and out can point to the same buffer if
(outOffset == inOffset) || (outOffset >= (inOffset+coreGetBlockSize))
That is: the buffers may not partially overlap...
coreGetBlockSize
int coreGetBlockSize()
|
|||||||||
Home >> All >> cryptix >> jce >> provider >> [ cipher overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |