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

public final Class TlsBlockCipher

extends Object
implements TlsCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.tls.crypto.TlsCipher
Imports
java.io.IOException, org.bouncycastle.tls.AlertDescription, .ContentType, .ProtocolVersion, .SecurityParameters, .TlsFatalAlert, .TlsUtils, org.bouncycastle.tls.crypto.TlsCipher, .TlsCryptoParameters, .TlsDecodeResult, .TlsEncodeResult, .TlsHMAC, org.bouncycastle.util.Pack

A generic TLS 1.0-1.2 block cipher. This can be used for AES or 3DES for example.

Field Summary

Modifier and TypeField and Description
private final boolean
private final TlsCryptoParameters
private final TlsBlockCipherImpl
private final byte[]
private final boolean
private final TlsBlockCipherImpl
private final byte[]
private final boolean
private final boolean
private final byte[]
private final TlsSuiteMac
private final boolean
private final boolean
private final TlsSuiteMac

Constructor Summary

AccessConstructor and Description
public
TlsBlockCipher(TlsCryptoParameters cryptoParams, TlsBlockCipherImpl encryptCipher, TlsBlockCipherImpl decryptCipher, TlsHMAC clientMac, TlsHMAC serverMac, int cipherKeySize)

Method Summary

Modifier and TypeMethod and Description
private int
checkPaddingConstantTime(byte[] buf, int off, int len, int blockSize, int macSize)

private int
public TlsDecodeResult
decodeCiphertext(long
sequence number of the message represented by ciphertext.
seqNo
,
short
content type used in the record for this message.
recordType
,
ProtocolVersion
ProtocolVersion used for the record.
recordVersion
,
byte[]
array holding input ciphertext to the cipher.
ciphertext
,
int
offset into input array the ciphertext starts at.
offset
,
int
length of the ciphertext in the array.
len
)

Implements org.bouncycastle.tls.crypto.TlsCipher.decodeCiphertext.

Decode the passed in ciphertext using the current bulk cipher.
public TlsEncodeResult
encodePlaintext(long
sequence number of the message represented by plaintext.
seqNo
,
short
content type of the message represented by plaintext.
contentType
,
ProtocolVersion
ProtocolVersion used for the record.
recordVersion
,
int
extra bytes to allocate at start of returned byte array.
headerAllocation
,
byte[]
array holding input plaintext to the cipher.
plaintext
,
int
offset into input array the plaintext starts at.
offset
,
int
length of the plaintext in the array.
len
)

Implements org.bouncycastle.tls.crypto.TlsCipher.encodePlaintext.

Encode the passed in plaintext using the current bulk cipher.
public int
getCiphertextDecodeLimit(int
the maximum output size for the plaintext.
plaintextLimit
)

Implements org.bouncycastle.tls.crypto.TlsCipher.getCiphertextDecodeLimit.

Return the maximum input size for a ciphertext given a maximum output size for the plaintext of plaintextLimit bytes.
public int
getCiphertextEncodeLimit(int
the maximum input size for the plaintext.
plaintextLimit
)

Implements org.bouncycastle.tls.crypto.TlsCipher.getCiphertextEncodeLimit.

Return the maximum output size for a ciphertext given a maximum input size for the plaintext of plaintextLimit bytes.
private int
getCiphertextLength(int blockSize, int macSize, int maxPadding, int plaintextLength)

public int
getPlaintextDecodeLimit(int
the maximum input size for the ciphertext.
ciphertextLimit
)

Implements org.bouncycastle.tls.crypto.TlsCipher.getPlaintextDecodeLimit.

Return the maximum output size for the plaintext given a maximum input size for the ciphertext of ciphertextLimit bytes.
public int
getPlaintextEncodeLimit(int
the maximum output size for the ciphertext.
ciphertextLimit
)

Implements org.bouncycastle.tls.crypto.TlsCipher.getPlaintextEncodeLimit.

Return the maximum input size for the plaintext given a maximum output size for the ciphertext of ciphertextLimit bytes.
private int
getPlaintextLength(int blockSize, int macSize, int ciphertextLength)

public void
public void
public boolean
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

acceptExtraPaddingback to summary
private final boolean acceptExtraPadding
cryptoParamsback to summary
private final TlsCryptoParameters cryptoParams
decryptCipherback to summary
private final TlsBlockCipherImpl decryptCipher
decryptConnectionIDback to summary
private final byte[] decryptConnectionID
decryptUseInnerPlaintextback to summary
private final boolean decryptUseInnerPlaintext
encryptCipherback to summary
private final TlsBlockCipherImpl encryptCipher
encryptConnectionIDback to summary
private final byte[] encryptConnectionID
encryptThenMACback to summary
private final boolean encryptThenMAC
encryptUseInnerPlaintextback to summary
private final boolean encryptUseInnerPlaintext
randomDataback to summary
private final byte[] randomData
readMacback to summary
private final TlsSuiteMac readMac
useExplicitIVback to summary
private final boolean useExplicitIV
useExtraPaddingback to summary
private final boolean useExtraPadding
writeMacback to summary
private final TlsSuiteMac writeMac

Constructor Detail

TlsBlockCipherback to summary
public TlsBlockCipher(TlsCryptoParameters cryptoParams, TlsBlockCipherImpl encryptCipher, TlsBlockCipherImpl decryptCipher, TlsHMAC clientMac, TlsHMAC serverMac, int cipherKeySize) throws IOException

Method Detail

checkPaddingConstantTimeback to summary
private int checkPaddingConstantTime(byte[] buf, int off, int len, int blockSize, int macSize)
chooseExtraPadBlocksback to summary
private int chooseExtraPadBlocks(int max)
decodeCiphertextback to summary
public TlsDecodeResult decodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int offset, int len) throws IOException

Implements org.bouncycastle.tls.crypto.TlsCipher.decodeCiphertext.

Doc from org.bouncycastle.tls.crypto.TlsCipher.decodeCiphertext.

Decode the passed in ciphertext using the current bulk cipher.

Parameters
seqNo:long

sequence number of the message represented by ciphertext.

recordType:short

content type used in the record for this message.

recordVersion:ProtocolVersion

ProtocolVersion used for the record.

ciphertext:byte[]

array holding input ciphertext to the cipher.

offset:int

offset into input array the ciphertext starts at.

len:int

length of the ciphertext in the array.

Returns:TlsDecodeResult

A TlsDecodeResult containing the result of decoding.

encodePlaintextback to summary
public TlsEncodeResult encodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion, int headerAllocation, byte[] plaintext, int offset, int len) throws IOException

Implements org.bouncycastle.tls.crypto.TlsCipher.encodePlaintext.

Doc from org.bouncycastle.tls.crypto.TlsCipher.encodePlaintext.

Encode the passed in plaintext using the current bulk cipher.

Parameters
seqNo:long

sequence number of the message represented by plaintext.

contentType:short

content type of the message represented by plaintext.

recordVersion:ProtocolVersion

ProtocolVersion used for the record.

headerAllocation:int

extra bytes to allocate at start of returned byte array.

plaintext:byte[]

array holding input plaintext to the cipher.

offset:int

offset into input array the plaintext starts at.

len:int

length of the plaintext in the array.

Returns:TlsEncodeResult

A TlsEncodeResult containing the result of encoding (after 'headerAllocation' unused bytes).

getCiphertextDecodeLimitback to summary
public int getCiphertextDecodeLimit(int plaintextLimit)

Implements org.bouncycastle.tls.crypto.TlsCipher.getCiphertextDecodeLimit.

Doc from org.bouncycastle.tls.crypto.TlsCipher.getCiphertextDecodeLimit.

Return the maximum input size for a ciphertext given a maximum output size for the plaintext of plaintextLimit bytes.

Parameters
plaintextLimit:int

the maximum output size for the plaintext.

Returns:int

the maximum input size of the ciphertext for plaintextLimit bytes of output.

getCiphertextEncodeLimitback to summary
public int getCiphertextEncodeLimit(int plaintextLimit)

Implements org.bouncycastle.tls.crypto.TlsCipher.getCiphertextEncodeLimit.

Doc from org.bouncycastle.tls.crypto.TlsCipher.getCiphertextEncodeLimit.

Return the maximum output size for a ciphertext given a maximum input size for the plaintext of plaintextLimit bytes.

Parameters
plaintextLimit:int

the maximum input size for the plaintext.

Returns:int

the maximum output size of the ciphertext for plaintextLimit bytes of input.

getCiphertextLengthback to summary
private int getCiphertextLength(int blockSize, int macSize, int maxPadding, int plaintextLength)
getPlaintextDecodeLimitback to summary
public int getPlaintextDecodeLimit(int ciphertextLimit)

Implements org.bouncycastle.tls.crypto.TlsCipher.getPlaintextDecodeLimit.

Doc from org.bouncycastle.tls.crypto.TlsCipher.getPlaintextDecodeLimit.

Return the maximum output size for the plaintext given a maximum input size for the ciphertext of ciphertextLimit bytes.

Parameters
ciphertextLimit:int

the maximum input size for the ciphertext.

Returns:int

the maximum output size of the plaintext for ciphertextLimit bytes of input.

getPlaintextEncodeLimitback to summary
public int getPlaintextEncodeLimit(int ciphertextLimit)

Implements org.bouncycastle.tls.crypto.TlsCipher.getPlaintextEncodeLimit.

Doc from org.bouncycastle.tls.crypto.TlsCipher.getPlaintextEncodeLimit.

Return the maximum input size for the plaintext given a maximum output size for the ciphertext of ciphertextLimit bytes.

Parameters
ciphertextLimit:int

the maximum output size for the ciphertext.

Returns:int

the maximum input size of the plaintext for ciphertextLimit bytes of output.

getPlaintextLengthback to summary
private int getPlaintextLength(int blockSize, int macSize, int ciphertextLength)
rekeyDecoderback to summary
public void rekeyDecoder() throws IOException

Implements org.bouncycastle.tls.crypto.TlsCipher.rekeyDecoder.

rekeyEncoderback to summary
public void rekeyEncoder() throws IOException

Implements org.bouncycastle.tls.crypto.TlsCipher.rekeyEncoder.

usesOpaqueRecordTypeDecodeback to summary
public boolean usesOpaqueRecordTypeDecode()

Implements org.bouncycastle.tls.crypto.TlsCipher.usesOpaqueRecordTypeDecode.

usesOpaqueRecordTypeEncodeback to summary
public boolean usesOpaqueRecordTypeEncode()

Implements org.bouncycastle.tls.crypto.TlsCipher.usesOpaqueRecordTypeEncode.