|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.crypto.CipherSpi
Service Provider Interface (SPI) for the Cipher class.
Attention: This is not a SUN implementation!
This class has been developed by IAIK according to the documentation publically available.
For SUNīs documentation of this class see
http://java.sun.com/security/JCE1.2/spec/apidoc/index.html
This class represents the super SPI abstract class for cipher handling and has to be implemented by a
data en/decryption supporting provider for registering with the Java Security framework.
Within the IAIK provider environment this class is extended by the
iaik.security.cipher.BufferedCipher
class for providing an automatical
buffering mechanism.
This class contains a set of abstract engine methods which have to be implemented by
a provider and are called by their appertaining Cipher
equivalents for accessing provider specific
implementations.
Any application dealing en/decryption, uses the getInstance
method
of the Cipher
class for creating a cipher object.
KeyGenerator
,
SecretKey
,
AlgorithmParameters
,
AlgorithmParameterSpec
,
BufferedCipher
,
Cipher
Constructor Summary | |
CipherSpi()
Constructor used for dynamic instantiation. |
Method Summary | |
protected abstract byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen)
Returns the result of the last step of a multi-step en/decryption operation or the result of a single-step en/decryption operation by processing the given input data and any remaining buffered data. |
protected abstract int |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
Performs the last step of a multi-step en/decryption operation or a single-step en/decryption operation by processing the given input data and any remaining buffered data. |
protected abstract int |
engineGetBlockSize()
Returns the block size corresponding to this cipher. |
protected abstract byte[] |
engineGetIV()
Returns a byte array containing the initialization vector (IV). |
protected int |
engineGetKeySize(Key key)
New method in JCE 1.2.1 |
protected abstract int |
engineGetOutputSize(int inputLen)
Returns the output buffer size necessary for capturing the data resulting from the next update or doFinal operation including
any data currently being buffered. |
protected abstract AlgorithmParameters |
engineGetParameters()
Returns the parameters used with this cipher. |
protected abstract void |
engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
Initializes this cipher object with proper key and algorithm parameters, and some random seed. |
protected abstract void |
engineInit(int opmode,
Key key,
AlgorithmParameters params,
SecureRandom random)
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness. |
protected abstract void |
engineInit(int opmode,
Key key,
SecureRandom random)
Initializes this cipher object with a proper key and some random seed. |
protected abstract void |
engineSetMode(String mode)
Sets the mode of this cipher. |
protected abstract void |
engineSetPadding(String padding)
Sets the padding scheme of this cipher. |
protected Key |
engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
Engine method for key unwrapping. |
protected abstract byte[] |
engineUpdate(byte[] input,
int inputOffset,
int inputLen)
Returns the result of the next step of a multi-step en/decryption operation. |
protected abstract int |
engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
Performs the next step of a multi-step en/decryption operation. |
protected byte[] |
engineWrap(Key key)
Engine method for key wrapping. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CipherSpi()
Method Detail |
protected abstract void engineSetMode(String mode) throws NoSuchAlgorithmException
Cipher.getInstance(...)
without specifying a particular cipher mode, engineSetMode
is supplied with the
default "ECB" mode.mode
- the cipher modeNoSuchAlgorithmException
- if this cipher mode is not supportedBufferedCipher.engineSetMode(java.lang.String)
protected abstract void engineSetPadding(String padding) throws NoSuchPaddingException
Cipher.getInstance(...)
without specifying a particular padding scheme, engineSetMode
is supplied with the
default "NoPadding" scheme.padding
- the padding schemeNoSuchPaddingException
- if this padding scheme is not supportedBufferedCipher.engineSetPadding(java.lang.String)
protected abstract int engineGetBlockSize()
Cipher.getBlockSize()
,
BufferedCipher.engineGetBlockSize()
protected abstract int engineGetOutputSize(int inputLen)
update
or doFinal
operation including
any data currently being buffered.inputLen
- the number of bytes to processCipher.getOutputSize(int)
,
BufferedCipher.engineGetOutputSize(int)
protected abstract byte[] engineGetIV()
null
is returned.null
otherwise.Cipher.getIV()
,
BufferedCipher.engineGetIV()
protected abstract AlgorithmParameters engineGetParameters()
protected abstract void engineInit(int opmode, Key key, SecureRandom random) throws InvalidKeyException
opmode
parameter (either ENCRYPT_MODE or DECCRYPT_MODE).
e.g. cipher_obj.init(Cipher.ENCRYPT_MODE, key, random_seed);
The Cipher init
will call the proper CipherSpi engineInit
method.
If this cipher (including its underlying feedback or padding scheme) requires any random bytes, it will get them from random.
opmode
- the operation mode for which this cipher is used (ENCRYPT_MODE or DECRYPT_MODE)key
- the keyrandom
- the random seedInvalidKeyException
- if the given key cannot be used for initializing this cipherCipher.init(int, java.security.Key)
,
BufferedCipher.engineInit(int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)
protected abstract void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
opmode
parameter (either ENCRYPT_MODE or DECCRYPT_MODE).
e.g. cipher_obj.init(Cipher.ENCRYPT_MODE, key, alg_params, random_seed);
The Cipher init
will call the proper CipherSpi engineInit
method.
opmode
- the operation mode for which this cipher is used (ENCRYPT_MODE or DECRYPT_MODE)key
- the keyparams
- the algorithm parametersrandom
- the random seedInvalidKeyException
- if the given key cannot be used for initializing this cipherInvalidAlgorithmParameterException
- if the given algorithm parameters donīt match to this cipherCipher.init(int, java.security.Key)
,
BufferedCipher.engineInit(int, java.security.Key, java.security.spec.AlgorithmParameterSpec, java.security.SecureRandom)
protected abstract void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
opmode
- the operation mode of this cipher
(this is either ENCRYPT_MODE or DECRYPT_MODE)key
- the encryption keyparams
- the algorithm parametersrandom
- the source of randomnessInvalidKeyException
- if the given key is inappropriate for initializing thiscipherInvalidAlgorithmParameterException
- if the given algorithm parameters are inappropriate for this cipherprotected abstract byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
inputOffset
,
only the first inputLen
bytes are en/decrypted. The result is returned as a byte array.input
- the byte array holding the data to be processedinputOffset
- the offset indicating the start position within the input byte arrayinputLen
- the number of bytes to be processedCipher.update(byte[])
,
BufferedCipher.engineUpdate(byte[], int, int)
protected abstract int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException
inputOffset
,
only the first inputLen
bytes are en/decrypted. The result is stored in the given
output byte array, beginning at outputOffset
. The number of bytes stored in this
output byte array are returned.input
- the byte array holding the data to be processedinputOffset
- the offset indicating the start position within the input byte arrayinputLen
- the number of bytes to be processedoutput
- the byte array for holding the resultoutputOffset
- the offset indicating the start position within the output byte array
to which the en/decrypted data is writtenShortBufferException
- if the given output buffer is too small for holding the resultCipher.update(byte[])
,
BufferedCipher.engineUpdate(byte[], int, int)
protected abstract byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException
inputOffset
,
only the first inputLen
bytes are en/decrypted, including any buffered bytes of a previous
update
operation. If necessary, padding is performed. The result is returned as
a output byte array.input
- the byte array holding the data to be processedinputOffset
- the offset indicating the start position within the input byte arrayinputLen
- the number of bytes to be processedIllegalBlockSizeException
- if the total length of the processed data is not a multiple of the block size for a
(no padding performing) block cipherBadPaddingException
- if the decrypted data is not bounded by the proper padding bytes after data
decryption including (un)paddingCipher.doFinal()
protected abstract int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException
inputOffset
,
only the first inputLen
bytes are en/decrypted, including any buffered bytes of a previous
update
operation. If necessary, padding is performed. The result is stored in the
given output byte array, beginning at outputOffset
. The number of bytes stored in
this byte array are returned.input
- the byte array holding the data to be processedinputOffset
- the offset indicating the start position within the input byte arrayinputLen
- the number of bytes to be processedoutput
- the byte array for holding the resultoutputOffset
- the offset indicating the start position within the output byte array
to which the en/decrypted data is writtenShortBufferException
- if the given output buffer is too small for holding the resultIllegalBlockSizeException
- if the total length of the processed data is not a multiple of the block size for a
(no padding performing) block cipherBadPaddingException
- if the decrypted data is not bounded by the proper padding bytes after data
decryption including (un)paddingCipher.doFinal()
protected int engineGetKeySize(Key key) throws InvalidKeyException
protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyException
protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |