|
|||||||||
| Home >> All >> javax >> [ crypto overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.crypto
Class CipherSpi

java.lang.Objectjavax.crypto.CipherSpi
- Direct Known Subclasses:
- NullCipherImpl, NullCipherSpi
- public abstract class CipherSpi
- extends java.lang.Object
This class represents the Service Provider Interface (SPI) for cryptographic ciphers.
Providers of cryptographic ciphers must subclass this for every cipher they implement, implementing the abstract methods as appropriate, then provide an entry that points to the subclass in their implementation of java.security.Provider.
CipherSpi objects are instantiated along with Ciphers when
the Cipher.getInstance(java.lang.String) 55 methods are invoked.
Particular ciphers are referenced by a transformation, which
is a String consisting of the cipher's name or the ciper's name
followed by a mode and a padding. Transformations all follow the
general form:
- algorithm, or
- algorithm/mode/padding
Cipher names in the master java.security.Provider class may be:
- The algorithm's name, which uses a pluggable mode and padding:
Cipher.algorithm - The algorithm's name and the mode, which uses pluggable padding:
Cipher.algorithm/mode - The algorithm's name and the padding, which uses a pluggable
mode:
Cipher.algorithm//padding - The algorihtm's name, the mode, and the padding:
Cipher.algorithm/mode/padding
When any Cipher.getInstance(java.lang.String) 55 method is
invoked, the following happens if the transformation is simply
algorithm:
- If the provider defines a
CipherSpiimplementation for "algorithm", return it. Otherwise throw a java.security.NoSuchAlgorithmException.
If the transformation is of the form algorithm/mode/padding:
- If the provider defines a
CipherSpisubclass for "algorithm/mode/padding", return it. Otherwise go to step 2. - If the provider defines a
CipherSpisubclass for "algorithm/mode", instatiate it, callengineSetPadding(java.lang.String)55 for the padding name, and return it. Otherwise go to step 3. - If the provider defines a
CipherSpisubclass for "algorithm//padding", instatiate it, callengineSetMode(java.lang.String)55 for the mode name, and return it. Otherwise go to step 4. - If the provider defines a
CipherSpisubclass for "algorithm", instatiate it, callengineSetMode(java.lang.String)55 for the mode name, callengineSetPadding(java.lang.String)55 for the padding name, and return it. Otherwise throw a java.security.NoSuchAlgorithmException.
- Since:
- 1.4
| Constructor Summary | |
CipherSpi()
Create a new CipherSpi. |
|
| Method Summary | |
protected abstract byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLength)
Finishes a multi-part transformation or transforms a portion of a byte array, and returns the transformed bytes. |
protected abstract int |
engineDoFinal(byte[] input,
int inputOffset,
int inputLength,
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 |
engineDoFinal(java.nio.ByteBuffer input,
java.nio.ByteBuffer output)
|
protected abstract int |
engineGetBlockSize()
Returns the block size of the underlying cipher. |
protected abstract byte[] |
engineGetIV()
Returns the initializaiton vector this cipher was initialized with, if any. |
protected int |
engineGetKeySize(java.security.Key key)
Return the length of the given key in bits. |
protected abstract int |
engineGetOutputSize(int inputLength)
Returns the size, in bytes, an output buffer must be for a call to engineUpdate(byte[],int,int,byte[],int) 55 or engineDoFinal(byte[],int,int,byte[],int) 55 to succeed. |
protected abstract java.security.AlgorithmParameters |
engineGetParameters()
Returns the parameters that this cipher is using. |
protected abstract 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 abstract 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 abstract void |
engineInit(int opmode,
java.security.Key key,
java.security.SecureRandom random)
Initializes this cipher with an operation mode, key, and source of randomness. |
protected abstract void |
engineSetMode(java.lang.String mode)
Set the mode in which this cipher is to run. |
protected abstract void |
engineSetPadding(java.lang.String padding)
Set the method with which the input is to be padded. |
protected java.security.Key |
engineUnwrap(byte[] wrappedKey,
java.lang.String wrappedKeyAlgorithm,
int wrappedKeyType)
Unwraps a previously-wrapped key. |
protected abstract byte[] |
engineUpdate(byte[] input,
int inputOffset,
int inputLength)
Continue with a multi-part transformation, returning a new array of the transformed bytes. |
protected abstract int |
engineUpdate(byte[] input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset)
Continue with a multi-part transformation, storing the transformed bytes into the specified array. |
protected int |
engineUpdate(java.nio.ByteBuffer input,
java.nio.ByteBuffer output)
|
protected byte[] |
engineWrap(java.security.Key key)
Wrap a key. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
CipherSpi
public CipherSpi()
- Create a new CipherSpi.
| Method Detail |
engineDoFinal
protected abstract byte[] engineDoFinal(byte[] input,
int inputOffset,
int inputLength)
throws IllegalBlockSizeException,
BadPaddingException
- Finishes a multi-part transformation or transforms a portion of a
byte array, and returns the transformed bytes.
engineDoFinal
protected abstract int engineDoFinal(byte[] input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset)
throws IllegalBlockSizeException,
BadPaddingException,
ShortBufferException
- Finishes a multi-part transformation or transforms a portion of a
byte array, and stores the transformed bytes in the supplied array.
engineDoFinal
protected int engineDoFinal(java.nio.ByteBuffer input, java.nio.ByteBuffer output) throws BadPaddingException, IllegalBlockSizeException, ShortBufferException
- Since:
- 1.5
engineGetBlockSize
protected abstract int engineGetBlockSize()
- Returns the block size of the underlying cipher.
engineGetIV
protected abstract byte[] engineGetIV()
- Returns the initializaiton vector this cipher was initialized with,
if any.
engineGetKeySize
protected int engineGetKeySize(java.security.Key key) throws java.security.InvalidKeyException
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 abstract int engineGetOutputSize(int inputLength)
Returns the size, in bytes, an output buffer must be for a call to
engineUpdate(byte[],int,int,byte[],int)55 orengineDoFinal(byte[],int,int,byte[],int)55 to succeed.The actual output length may be smaller than the value returned by this method, as it considers the padding length as well. The length considered is the argument plus the length of any buffered, unprocessed bytes.
engineGetParameters
protected abstract java.security.AlgorithmParameters engineGetParameters()
- 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 abstract void engineInit(int opmode,
java.security.Key key,
java.security.SecureRandom random)
throws java.security.InvalidKeyException
- Initializes this cipher with an operation mode, key, 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 abstract void engineInit(int opmode,
java.security.Key key,
java.security.AlgorithmParameters params,
java.security.SecureRandom random)
throws java.security.InvalidAlgorithmParameterException,
java.security.InvalidKeyException
- 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 abstract void engineInit(int opmode,
java.security.Key key,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
throws java.security.InvalidAlgorithmParameterException,
java.security.InvalidKeyException
- 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.
engineSetMode
protected abstract void engineSetMode(java.lang.String mode) throws java.security.NoSuchAlgorithmException
- Set the mode in which this cipher is to run.
engineSetPadding
protected abstract void engineSetPadding(java.lang.String padding) throws NoSuchPaddingException
- Set the method with which the input is to be padded.
engineUnwrap
protected java.security.Key engineUnwrap(byte[] wrappedKey, java.lang.String wrappedKeyAlgorithm, int wrappedKeyType) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException
Unwraps a previously-wrapped key.
For compatibility this method is not declared
abstract, and the default implementation will throw an java.lang.UnsupportedOperationException.
engineUpdate
protected abstract byte[] engineUpdate(byte[] input,
int inputOffset,
int inputLength)
- Continue with a multi-part transformation, returning a new array of
the transformed bytes.
engineUpdate
protected abstract int engineUpdate(byte[] input,
int inputOffset,
int inputLength,
byte[] output,
int outputOffset)
throws ShortBufferException
- Continue with a multi-part transformation, storing the transformed
bytes into the specified array.
engineUpdate
protected int engineUpdate(java.nio.ByteBuffer input, java.nio.ByteBuffer output) throws ShortBufferException
- Since:
- 1.5
engineWrap
protected byte[] engineWrap(java.security.Key key) throws java.security.InvalidKeyException, IllegalBlockSizeException
Wrap a key.
For compatibility this method is not declared
abstract, and the default implementation will throw an java.lang.UnsupportedOperationException.
|
|||||||||
| Home >> All >> javax >> [ crypto overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
javax.crypto.CipherSpi