public abstract class AbstractAESWrapCipherSpi extends CipherSpi
com.sun.crypto.provider.AESWrapCipher.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractAESWrapCipherSpi() |
| Modifier and Type | Method and Description |
|---|---|
static int |
addExact(int x,
int y)
Returns the sum of its arguments, throwing an exception if the result overflows an
int. |
protected byte[] |
engineDoFinal(byte[] in,
int inOffset,
int inLen)
This operation is not supported by this cipher.
|
protected int |
engineDoFinal(byte[] in,
int inOffset,
int inLen,
byte[] out,
int outOffset)
This operation is not supported by this cipher.
|
protected int |
engineGetBlockSize()
Returns the block size (in bytes).
|
protected byte[] |
engineGetIV()
Returns the initialization vector (IV) which is null for this cipher.
|
protected int |
engineGetOutputSize(int inputLen)
Returns the length in bytes that an output buffer would need to be given the input length
inputLen
(in bytes). |
protected abstract void |
engineInit(boolean decrypting,
SecretKey key)
Initializes the AES Key Wrap cipher with the given key.
|
protected void |
engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
Initializes this cipher with a key, a set of algorithm parameters, and a source of randomness.
|
protected void |
engineInit(int opmode,
Key key,
SecureRandom random)
Initializes this cipher with a key and a source of randomness.
|
protected Key |
engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
Unwrap a previously wrapped key.
|
protected byte[] |
engineUpdate(byte[] in,
int inOffset,
int inLen)
This operation is not supported by this cipher.
|
protected int |
engineUpdate(byte[] in,
int inOffset,
int inLen,
byte[] out,
int outOffset)
This operation is not supported by this cipher.
|
protected byte[] |
engineWrap(Key key)
Wrap a key.
|
protected abstract SecretKey |
unwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
Unwrap a previously wrapped key.
|
protected abstract byte[] |
wrap(SecretKey key)
Wrap a key.
|
engineUpdateAADpublic static int addExact(int x,
int y)
int.x - the first valuey - the second valueArithmeticException - if the result overflows an intprotected byte[] engineDoFinal(byte[] in,
int inOffset,
int inLen)
throws IllegalBlockSizeException,
BadPaddingException
engineDoFinal in class CipherSpiin - the input bufferinOffset - the offset in in where the input startsinLen - the input length.IllegalStateException - upon invocation of this method.IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the
total input length of the data processed by this cipher is not a multiple of block size; or if
this encryption algorithm is unable to process the input data provided.BadPaddingException - if this cipher is in decryption mode, and (un)padding has been requested, but the decrypted data
is not bounded by the appropriate padding bytesAEADBadTagException - if this cipher is decrypting in an AEAD mode (such as GCM/CCM), and the received authentication
tag does not match the calculated valueprotected int engineDoFinal(byte[] in,
int inOffset,
int inLen,
byte[] out,
int outOffset)
throws IllegalBlockSizeException,
ShortBufferException,
BadPaddingException
engineDoFinal in class CipherSpiin - the input buffer.inOffset - the offset in in where the input starts.inLen - the input length.out - the buffer for the result.outOffset - the ofset in out where the result is stored.IllegalStateException - upon invocation of this method.IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested (only in encryption mode), and the
total input length of the data processed by this cipher is not a multiple of block size; or if
this encryption algorithm is unable to process the input data provided.ShortBufferException - if the given output buffer is too small to hold the resultBadPaddingException - if this cipher is in decryption mode, and (un)padding has been requested, but the decrypted data
is not bounded by the appropriate padding bytesAEADBadTagException - if this cipher is decrypting in an AEAD mode (such as GCM/CCM), and the received authentication
tag does not match the calculated valueprotected int engineGetBlockSize()
engineGetBlockSize in class CipherSpiprotected byte[] engineGetIV()
engineGetIV in class CipherSpiprotected int engineGetOutputSize(int inputLen)
inputLen
(in bytes).
The actual output length of the next update or doFinal call may be smaller than the
length returned by this method.
engineGetOutputSize in class CipherSpiinputLen - the input length (in bytes)protected abstract void engineInit(boolean decrypting,
SecretKey key)
throws InvalidKeyException
decrypting - flag indicating wrap or unwrap modekey - the key (never null)InvalidKeyException - if the given key is inappropriate for initializing this cipherprotected void engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
The cipher only supports the following two operation modes: Cipher.WRAP_MODE and Cipher.UNWRAP_MODE.
For modes other than the above two, UnsupportedOperationException will be thrown.
engineInit in class CipherSpiopmode - the operation mode of this cipher. Only WRAP_MODE or UNWRAP_MODE) are
accepted.key - the secret key.params - the algorithm parameters; must be null for this cipher.random - the source of randomness.InvalidKeyException - if the given key is inappropriate for initializing this cipherInvalidAlgorithmParameterException - if the given algorithm parameters is not null.protected void engineInit(int opmode,
Key key,
SecureRandom random)
throws InvalidKeyException
The cipher only supports the following two operation modes: Cipher.WRAP_MODE and Cipher.UNWRAP_MODE.
For modes other than the above two, UnsupportedOperationException will be thrown.
engineInit in class CipherSpiopmode - the operation mode of this cipher. Only WRAP_MODE or UNWRAP_MODE) are
accepted.key - the secret key.random - the source of randomness.InvalidKeyException - if the given key is inappropriate for initializing this cipher.UnsupportedOperationException - if opmode is not WRAP_MODE or UNWRAP_MODE.protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException
engineUnwrap in class CipherSpiwrappedKey - the key to be unwrapped.wrappedKeyAlgorithm - the algorithm the wrapped key is for.wrappedKeyType - the type of the wrapped key. This is one of Cipher.SECRET_KEY,
Cipher.PRIVATE_KEY, or Cipher.PUBLIC_KEY.NoSuchAlgorithmException - if no installed providers can create keys of type wrappedKeyType for the
wrappedKeyAlgorithm.InvalidKeyException - if wrappedKey does not represent a wrapped key of type wrappedKeyType
for the wrappedKeyAlgorithm.protected byte[] engineUpdate(byte[] in,
int inOffset,
int inLen)
engineUpdate in class CipherSpiin - the input buffer.inOffset - the offset in in where the input starts.inLen - the input length.IllegalStateException - upon invocation of this method.protected int engineUpdate(byte[] in,
int inOffset,
int inLen,
byte[] out,
int outOffset)
throws ShortBufferException
engineUpdate in class CipherSpiin - the input buffer.inOffset - the offset in in where the input starts.inLen - the input length.out - the buffer for the result.outOffset - the offset in out where the result is stored.IllegalStateException - upon invocation of this method.ShortBufferException - if the given output buffer is too small to hold the resultprotected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyException
engineWrap in class CipherSpikey - the key to be wrapped.IllegalBlockSizeException - if this cipher is a block cipher, no padding has been requested, and the length of the encoding of
the key to be wrapped is not a multiple of the block size.InvalidKeyException - if it is impossible or unsafe to wrap the key with this cipher (e.g., a hardware protected key is
being passed to a software only cipher).protected abstract SecretKey unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException
wrappedKey - the key to be unwrapped.wrappedKeyAlgorithm - the algorithm the wrapped key is for.wrappedKeyType - the type of the wrapped key. This is one of Cipher.SECRET_KEY,
Cipher.PRIVATE_KEY, or Cipher.PUBLIC_KEY.NoSuchAlgorithmException - if no installed providers can create keys of type wrappedKeyType for the
wrappedKeyAlgorithm.InvalidKeyException - if wrappedKey does not represent a wrapped key of type wrappedKeyType
for the wrappedKeyAlgorithm.protected abstract byte[] wrap(SecretKey key) throws InvalidKeyException, IllegalBlockSizeException
key - the key to be wrapped.InvalidKeyException - if it is impossible to wrap the key with this cipher.IllegalBlockSizeException - the length of the encoding of the key to be wrapped is not a multiple of the block size.