public abstract class BlockCipherProxyCipher extends ProxyCipher
ProxyCipher and
appends the initialization vector (IV) for the block encryption to the cipher
text and reads the IV from the cipher text in decrypt mode.| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
iv_
The initialization vector of the block encryption.
|
protected int |
ivLength_
The length of the initialization vector (IV).
|
protected int |
ivPos_
The position of the last read/wrote byte of the IV.
|
protected Key |
key_
The key for encryption/decryption.
|
protected int |
opmode_
The mode of operation of this Cipher.
|
protected SecureRandom |
random_
The source of randomness.
|
cipher_| Constructor and Description |
|---|
BlockCipherProxyCipher()
Creates a new instance of this
AESProxyCipher. |
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
concatenate(byte[] a,
byte[] b)
Concatenates the two given byte arrays
a and b. |
protected byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen) |
protected int |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset) |
protected void |
engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random) |
protected void |
engineInit(int opmode,
Key key,
AlgorithmParameters params,
SecureRandom random) |
protected void |
engineInit(int opmode,
Key key,
SecureRandom random) |
protected Key |
engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType) |
protected byte[] |
engineUpdate(byte[] input,
int inputOffset,
int inputLen) |
protected int |
engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset) |
protected byte[] |
engineWrap(Key key) |
protected int |
readIV(byte[] input,
int inputOffset,
int inputLen)
Reads the IV from the given
input and re-initializes the
underlying Cipher engine with this IV when the complete IV has been
read. |
protected byte[] |
writeIV()
Returns the bytes from the IV that have not been written yet.
|
protected int |
writeIV(byte[] output,
int outputOffset)
Writes the bytes from the IV to
output that have not been
written yet. |
engineGetBlockSize, engineGetIV, engineGetOutputSize, engineGetParameters, engineSetMode, engineSetPadding, getAlgorithmInstance, getAlgorithmInstanceUncaught, getCipherName, getInstanceengineDoFinal, engineGetKeySize, engineUpdate, engineUpdateAAD, engineUpdateAADprotected int ivLength_
protected byte[] iv_
protected int ivPos_
protected int opmode_
protected Key key_
protected SecureRandom random_
public BlockCipherProxyCipher()
throws NoSuchAlgorithmException,
NoSuchProviderException,
NoSuchPaddingException
AESProxyCipher.protected void engineInit(int opmode,
Key key,
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
protected void engineInit(int opmode,
Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException,
InvalidAlgorithmParameterException
protected void engineInit(int opmode,
Key key,
SecureRandom random)
throws InvalidKeyException
engineInit in class ProxyCipherInvalidKeyExceptionCipherSpi.engineInit(int, java.security.Key,
java.security.SecureRandom)protected int engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws ShortBufferException
engineUpdate in class ProxyCipherShortBufferExceptionCipherSpi.engineUpdate(byte[], int, int, byte[], int)protected byte[] engineUpdate(byte[] input,
int inputOffset,
int inputLen)
engineUpdate in class ProxyCipherCipherSpi.engineUpdate(byte[], int, int)protected int engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
throws ShortBufferException,
IllegalBlockSizeException,
BadPaddingException
engineDoFinal in class ProxyCipherShortBufferExceptionIllegalBlockSizeExceptionBadPaddingExceptionCipherSpi.engineDoFinal(byte[], int, int, byte[], int)protected byte[] engineDoFinal(byte[] input,
int inputOffset,
int inputLen)
throws IllegalBlockSizeException,
BadPaddingException
engineDoFinal in class ProxyCipherIllegalBlockSizeExceptionBadPaddingExceptionCipherSpi.engineDoFinal(byte[], int, int)protected byte[] engineWrap(Key key) throws IllegalBlockSizeException, InvalidKeyException
engineWrap in class ProxyCipherIllegalBlockSizeExceptionInvalidKeyExceptionCipherSpi.engineWrap(java.security.Key)protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType) throws InvalidKeyException, NoSuchAlgorithmException
engineUnwrap in class ProxyCipherInvalidKeyExceptionNoSuchAlgorithmExceptionCipherSpi.engineUnwrap(byte[], java.lang.String, int)protected byte[] concatenate(byte[] a,
byte[] b)
a and b.a - the byte[] ab - the byte[] bbyte[] of length
(a.length + b.length) containing a copy of the bytes
of a followed by a copy of the bytes of b
.protected int readIV(byte[] input,
int inputOffset,
int inputLen)
input and re-initializes the
underlying Cipher engine with this IV when the complete IV has been
read.input - the input bufferinputOffset - the offset in input where the input startsinputLen - the input lengthinputprotected byte[] writeIV()
protected int writeIV(byte[] output,
int outputOffset)
throws ShortBufferException
output that have not been
written yet.output - the output bufferoutputOffset - the offset in outputoutputShortBufferException - if the given output is to small to hold the result© 2002-2005 IAIK, © 2004, 2006 - 2019 Stiftung SIC