|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjavax.crypto.Cipher
public class Cipher
| Field Summary | |
|---|---|
static int |
DECRYPT_MODE
Constant that initializes Ciper to decryption mode |
static int |
ENCRYPT_MODE
Constant that initializes Cipher to encryption mode |
static int |
PRIVATE_KEY
Constant that indicates key to be un-wrapped is a private key |
static int |
PUBLIC_KEY
Constant that indicates key to be un-wrapped is a public key |
static int |
SECRET_KEY
Constant that indicates key to be un-wrapped is a secret key |
static int |
UNWRAP_MODE
Constant that initializes Cipher to key-unwrapping mode |
static int |
WRAP_MODE
Constant that initializes Cipher to key-wrapping mode |
| Constructor Summary | |
|---|---|
protected |
Cipher(CipherSpi cipher,
Provider cipherProvider,
String cipherTransformation)
Creates a Cipher object |
| Method Summary | |
|---|---|
byte[] |
doFinal()
Finishes a multi-part encryption/decryption operation. |
byte[] |
doFinal(byte[] input)
Finishes a multi-part encryption/decryption operation. |
int |
doFinal(byte[] output,
int outputOffset)
Finishes a multi-part encryption/decryption operation. |
byte[] |
doFinal(byte[] input,
int start,
int end)
Finishes a multi-part encryption/decryption operation. |
int |
doFinal(byte[] input,
int start,
int end,
byte[] output)
Finishes a multi-part encryption/decryption operation. |
int |
doFinal(byte[] input,
int start,
int end,
byte[] output,
int outputStart)
Finishes a multi-part encryption/decryption operation. |
String |
getAlgorithm()
Returns the algorithm implemented by this Cipher |
int |
getBlockSize()
Returns the block size (in bytes) |
ExemptionMechanism |
getExemptionMechanism()
Returns the ExemptionMechanism in use with this Cipher |
static Cipher |
getInstance(String transformation)
Returns an instance of Cipher that provides the specified transformation To find a Cipher that implements the specified transformation, the configured providers are searched in the following order: 1) The default provider 2) Other providers in the order of preference (see java.security) |
static Cipher |
getInstance(String transformation,
Provider provider)
Returns an instance of Cipher that provides the specified transformation The specified provider is checked for an implementation of the specified algorithm that also supports the requirments of the transformation. |
static Cipher |
getInstance(String transformation,
String provider)
Returns an instance of Cipher that provides the specified transformation The specified provider is checked for an implementation of the specified algorithm that also supports the requirments of the transformation. |
byte[] |
getIV()
Returns the initialization vector in use with the Cipher (in a new buffer) |
int |
getOutputSize(int inputLen)
Returns the size of an output buffer needed to hold the result of the next call to update or doFinal, given the input length. |
AlgorithmParameters |
getParameters()
Returns the parameters in use with this Cipher. |
Provider |
getProvider()
Returns the provider of this Cipher |
void |
init(int opMode,
Certificate cert)
Initializes the Cipher to operate in opMode using a the public key of the Certificate. |
void |
init(int opMode,
Certificate cert,
SecureRandom random)
Initializes the Cipher to operate in opMode using a the public key of the Certificate. |
void |
init(int opMode,
Key key)
Initializes the Cipher to operate in opMode using the given Key. |
void |
init(int opMode,
Key key,
AlgorithmParameters params)
Initializes the Cipher to operate in opMode using the given Key. |
void |
init(int opMode,
Key key,
AlgorithmParameterSpec params)
Initializes the Cipher to operate in opMode using the given Key. |
void |
init(int opMode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
Initializes the Cipher to operate in opMode using the given Key. |
void |
init(int opMode,
Key key,
AlgorithmParameters params,
SecureRandom random)
Initializes the Cipher to operate in opMode using the given Key. |
void |
init(int opMode,
Key key,
SecureRandom random)
Initializes the Cipher to operate in opMode using the given Key. |
Key |
unwrap(byte[] input,
String algorithm,
int keyType)
Unwraps a key |
byte[] |
update(byte[] input)
Continues a multi-part encryption/decryption operation. |
byte[] |
update(byte[] input,
int start,
int end)
Continues a multi-part encryption/decrytpion 0operation. |
int |
update(byte[] input,
int start,
int end,
byte[] output)
Continues a multi-part encryption/decryption operation. |
int |
update(byte[] input,
int start,
int end,
byte[] output,
int outputStart)
Continues a multi-part encryption/decryption operation. |
byte[] |
wrap(Key key)
Wraps a key |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ENCRYPT_MODE
public static final int DECRYPT_MODE
public static final int WRAP_MODE
public static final int UNWRAP_MODE
public static final int PUBLIC_KEY
public static final int PRIVATE_KEY
public static final int SECRET_KEY
| Constructor Detail |
|---|
protected Cipher(CipherSpi cipher,
Provider cipherProvider,
String cipherTransformation)
cipher - implementor of SPI for ciphercipherProvider - provider of the ciphercipherTransformation - transformation to be applied with the cipher| Method Detail |
|---|
public static final Cipher getInstance(String transformation,
String provider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException
transformation - the transformation that should be supported by the Cipher implementationprovider - the name of a provider that provides support for transformation
NoSuchAlgorithmException - no provider implements the specified algorithm and/or transformation
NoSuchProviderException - the provider could not be found (it is not configured)
NoSuchPaddingException - no provider supports the padding algorithm specified in transformationpublic static final Cipher getInstance(String transformation,
Provider provider)
throws NoSuchAlgorithmException,
NoSuchPaddingException
transformation - the transformation that should be supported by the Cipher implementationprovider - a Provider that supports the supplied transformation
NoSuchAlgorithmException - no provider implements the specified algorithm and/or transformation
NoSuchPaddingException - no provider supports the padding algorithm specified in transformationpublic final Provider getProvider()
public final String getAlgorithm()
public final int getBlockSize()
public final int getOutputSize(int inputLen)
throws IllegalStateException
inputLen - length of input (in bytes)
IllegalStateException - Cipher is in incorrect statepublic final AlgorithmParameters getParameters()
public final void init(int opMode,
Key key,
SecureRandom random)
throws InvalidKeyException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )key - key to be used with Cipherrandom - source of random data
InvalidKeyException - key not valid for the Cipher or the operationpublic final void init(int opMode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )key - key to be used with Cipherparams - parameters to be used with Cipherrandom - source of random data
InvalidKeyException - key not valid for Cipher or operation
InvalidAlgorithmParameterException - parameters missing, invalid or not applicable to operationpublic final void init(int opMode,
Key key,
AlgorithmParameters params)
throws InvalidKeyException,
InvalidAlgorithmParameterException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )key - key to be used with Cipherparams - parameters to be used with Cipher
InvalidKeyException - key not valid for Cipher or operation
InvalidAlgorithmParameterException - parameters missing, invalid or not applicable to operationpublic final void init(int opMode,
Key key,
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )key - key to be used with Cipherparams - parameters to be used with Cipherrandom -
InvalidKeyException - key not valid for Cipher or operation
InvalidAlgorithmParameterException - parameters missing, invalid or not applicable to operationpublic final void init(int opMode,
Certificate cert)
throws InvalidKeyException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )cert - key to be used with Cipher
InvalidKeyException - key not valid for Cipher or operationpublic final void init(int opMode,
Certificate cert,
SecureRandom random)
throws InvalidKeyException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )cert - key to be used with Cipherrandom -
InvalidKeyException - key not valid for Cipher or operationpublic final byte[] update(byte[] input)
throws IllegalStateException
input - data to be processed
IllegalStateException - Cipher is not in a valid state for an updatepublic final byte[] update(byte[] input,
int start,
int end)
throws IllegalStateException
input - data to be encryptedstart - start offset of input in input bufferend - end offset of input in input buffer
IllegalStateException - Cipher is not in a valid state for an updatepublic final int update(byte[] input,
int start,
int end,
byte[] output)
throws IllegalStateException,
ShortBufferException
input - data to be encryptedstart - start offset of input in plaintext bufferend - end offset of input in plaintext bufferoutput - encrypted data or null if input length is 0 or there is
not enough data to fill a block (with block Cipher)
IllegalStateException - Cipher is not in a valid state for an update
ShortBufferException - cipherText buffer too short to contain result of the operationpublic final byte[] doFinal()
throws IllegalStateException,
IllegalBlockSizeException,
BadPaddingException
IllegalStateException - Cipher state not valid for doFinal operation
IllegalBlockSizeException - No padding has been requested (encryption-mode only) but input
is not a multiple of the block size
BadPaddingException - Failure in processing padding in input during decryption operationpublic final int doFinal(byte[] output,
int outputOffset)
throws IllegalStateException,
IllegalBlockSizeException,
ShortBufferException,
BadPaddingException
output - output bufferoutputOffset - offset to start output in output buffer
IllegalStateException - Cipher state not valid for doFinal operation
IllegalBlockSizeException - No padding has been requested (encryption-mode only)
but input is not a multiple of the block size
ShortBufferException - Not enough room available in output buffer to store
processed output
BadPaddingException - Failure in processing padding in input during
decryption operationpublic final byte[] doFinal(byte[] input)
throws IllegalStateException,
IllegalBlockSizeException,
BadPaddingException
input - data to be processed in addition to buffered input
IllegalStateException - Cipher state not valid for doFinal operation
IllegalBlockSizeException - No padding has been requested (encryption-mode only) but input
is not a multiple of the block size
BadPaddingException - Failure in processing padding in input during decryption operationpublic final byte[] doFinal(byte[] input,
int start,
int end)
throws IllegalStateException,
IllegalBlockSizeException,
BadPaddingException
input - data to be processed in addition to buffered inputstart - start offset of input in input bufferend - end offset of input in input buffer
IllegalStateException - Cipher state not valid for doFinal operation
IllegalBlockSizeException - No padding has been requested (encryption-mode only) but input
is not a multiple of the block size
BadPaddingException - Failure in processing padding in input during decryption operationpublic final int doFinal(byte[] input,
int start,
int end,
byte[] output)
throws IllegalStateException,
ShortBufferException,
IllegalBlockSizeException,
BadPaddingException
input - data to be processed in addition to buffered inputstart - start offset of input in input bufferend - end offset of input in input bufferoutput - buffer to which output should be written
IllegalStateException - Cipher state not valid for doFinal operation
IllegalBlockSizeException - No padding has been requested (encryption-mode only) but input
is not a multiple of the block size
ShortBufferException - Not enough room available in output buffer to store
processed output
BadPaddingException - Failure in processing padding in input during decryption operationpublic final byte[] wrap(Key key)
throws IllegalStateException,
IllegalBlockSizeException,
InvalidKeyException
key - key to be wrapped
IllegalStateException - Cipher not in proper state for key wrapping
IllegalBlockSizeException - If a block cipher is in use, no padding has been requested and the input
length is not a multiple of the block size
InvalidKeyException - It is not possible or safe to wrap this keypublic final Key unwrap(byte[] input,
String algorithm,
int keyType)
throws IllegalStateException,
InvalidKeyException,
NoSuchAlgorithmException
input - a wrapped keyalgorithm - the algorithm associated with the wrapped keykeyType - the type of key (must be PUBLIC_KEY, PRIVATE_KEY or SECRET_KEY)
IllegalStateException - Cipher not in proper state for key unwrapping
InvalidKeyException - input does not represent a wrapped key of keyType for algorithm
NoSuchAlgorithmException - no installed provider can provide a keyType of algorithmpublic final ExemptionMechanism getExemptionMechanism()
public final int doFinal(byte[] input,
int start,
int end,
byte[] output,
int outputStart)
throws IllegalStateException,
ShortBufferException,
IllegalBlockSizeException,
BadPaddingException
input - data to be processed in addition to buffered inputstart - start offset of input in input bufferend - end offset of input in input bufferoutput - buffer to which output should be writtenoutputStart - the start offset in the output buffer
IllegalStateException - Cipher state not valid for doFinal operation
IllegalBlockSizeException - No padding has been requested (encryption-mode only) but input
is not a multiple of the block size
ShortBufferException - Not enough room available in output buffer to store
processed output
BadPaddingException - Failure in processing padding in input during decryption operationpublic static final Cipher getInstance(String transformation)
throws NoSuchAlgorithmException,
NoSuchPaddingException
transformation - the transformation that should be supported by the Cipher implementation
NoSuchAlgorithmException - no provider implements the specified algorithm and/or transformation
NoSuchPaddingException - no provider supports the padding algorithm specified in transformationpublic final byte[] getIV()
public final void init(int opMode,
Key key)
throws InvalidKeyException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )key - key to be used with Cipher
InvalidKeyException - key not valid for the Cipher or the operationpublic final void init(int opMode,
Key key,
AlgorithmParameterSpec params)
throws InvalidKeyException,
InvalidAlgorithmParameterException
opMode - operation of Cipher (ENCRYPT_MODE, DECRYPT_MODE, ... )key - key to be used with Cipherparams - parameters to be used with Cipher
InvalidKeyException - key not valid for Cipher or operation
InvalidAlgorithmParameterException - parameters missing, invalid or not applicable to operationpublic final int update(byte[] input,
int start,
int end,
byte[] output,
int outputStart)
throws IllegalStateException,
ShortBufferException
input - data to be encryptedstart - start offset of input in plaintext bufferend - end offset of input in plaintext bufferoutput - encrypted data or null if input length is 0 or there is
not enough data to fill a block (with block Cipher)outputStart - start offset of processed output into output buffer
IllegalStateException - Cipher is not in a valid state for an update
ShortBufferException - cipherText buffer too short to contain result of the operation
|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||