Top Description Fields Constructors Methods
org.bouncycastle.tls.crypto.impl.jcajce

public Class JceBlockCipherWithCBCImplicitIVImpl

extends Object
implements TlsBlockCipherImpl
Class Inheritance
All Implemented Interfaces
org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl
Imports
java.security.GeneralSecurityException, .SecureRandom, javax.crypto.Cipher, .SecretKey, javax.crypto.spec.IvParameterSpec, .SecretKeySpec, org.bouncycastle.tls.TlsUtils, org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl

A basic wrapper for a JCE Cipher class to provide the needed block cipher functionality for TLS where the cipher requires the IV to be continued between calls.

Field Summary

Modifier and TypeField and Description
private final String
private static final int
private final Cipher
private final int
private final JcaTlsCrypto
private SecretKey
private byte[]

Constructor Summary

AccessConstructor and Description
public
JceBlockCipherWithCBCImplicitIVImpl(JcaTlsCrypto crypto, Cipher cipher, String algorithm, boolean isEncrypting)

Method Summary

Modifier and TypeMethod and Description
public int
doFinal(byte[]
array holding input data to the cipher.
input
,
int
offset into input array data starts at.
inputOffset
,
int
length of the input data in the array.
inputLength
,
byte[]
array to hold the cipher output.
output
,
int
offset into output array to start saving output.
outputOffset
)

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.doFinal.

Perform the cipher encryption/decryption returning the output in output.

public int
getBlockSize()

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.getBlockSize.

Return the blocksize (in bytes) of the underlying block cipher.

public void
init(byte[]
array holding the initialization vector (IV).
iv
,
int
offset into the array the IV starts at.
ivOff
,
int
length of the IV in the array.
ivLen
)

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.init.

Initialise the parameters for operator.

public void
setKey(byte[]
array holding the block cipher key.
key
,
int
offset into the array the key starts at.
keyOff
,
int
length of the key in the array.
keyLen
)

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.setKey.

Set the key to be used by the block cipher implementation supporting this service.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private final String algorithm
BUF_SIZEback to summary
private static final int BUF_SIZE
cipherback to summary
private final Cipher cipher
cipherModeback to summary
private final int cipherMode
cryptoback to summary
private final JcaTlsCrypto crypto
keyback to summary
private SecretKey key
nextIVback to summary
private byte[] nextIV

Constructor Detail

JceBlockCipherWithCBCImplicitIVImplback to summary
public JceBlockCipherWithCBCImplicitIVImpl(JcaTlsCrypto crypto, Cipher cipher, String algorithm, boolean isEncrypting) throws GeneralSecurityException

Method Detail

doFinalback to summary
public int doFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.doFinal.

Doc from org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.doFinal.

Perform the cipher encryption/decryption returning the output in output.

Note

we have to use doFinal() here as it is the only way to guarantee output from the underlying cipher.

Parameters
input:byte[]

array holding input data to the cipher.

inputOffset:int

offset into input array data starts at.

inputLength:int

length of the input data in the array.

output:byte[]

array to hold the cipher output.

outputOffset:int

offset into output array to start saving output.

Returns:int

the amount of data written to output.

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.getBlockSize.

Doc from org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.getBlockSize.

Return the blocksize (in bytes) of the underlying block cipher.

Returns:int

the cipher's blocksize.

initback to summary
public void init(byte[] iv, int ivOff, int ivLen)

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.init.

Doc from org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.init.

Initialise the parameters for operator.

Parameters
iv:byte[]

array holding the initialization vector (IV).

ivOff:int

offset into the array the IV starts at.

ivLen:int

length of the IV in the array.

setKeyback to summary
public void setKey(byte[] key, int keyOff, int keyLen)

Implements org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.setKey.

Doc from org.bouncycastle.tls.crypto.impl.TlsBlockCipherImpl.setKey.

Set the key to be used by the block cipher implementation supporting this service.

Parameters
key:byte[]

array holding the block cipher key.

keyOff:int

offset into the array the key starts at.

keyLen:int

length of the key in the array.