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

public final Class TlsAEADCipher

extends Object
implements TlsCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.tls.crypto.TlsCipher
Imports
java.io.IOException, java.security.AccessController, .PrivilegedAction, org.bouncycastle.tls.AlertDescription, .ContentType, .ProtocolVersion, .SecurityParameters, .TlsFatalAlert, .TlsUtils, org.bouncycastle.tls.crypto.TlsCipher, .TlsCryptoParameters, .TlsCryptoUtils, .TlsDecodeResult, .TlsEncodeResult, .TlsSecret, org.bouncycastle.util.Arrays

A generic TLS 1.2 AEAD cipher.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
private final TlsCryptoParameters
private final TlsAEADCipherImpl
private final byte[]
private final byte[]
private final boolean
private final TlsAEADCipherImpl
private final byte[]
private final byte[]
protected final AEADNonceGenerator
private final boolean
private static final byte[]
private static final Class<T>
private final int
private final boolean
private final int
private final int
private static final int
private static final int
private final int
private final int
private static final long

Constructor Summary

AccessConstructor and Description
public
TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int keySize, int macSize, int aeadType)

Method Summary

Modifier and TypeMethod and Description
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.
ciphertextOffset
,
int
length of the ciphertext in the array.
ciphertextLength
)

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.
plaintextOffset
,
int
length of the plaintext in the array.
plaintextLength
)

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

Encode the passed in plaintext using the current bulk cipher.
private byte[]
getAdditionalData(long seqNo, short recordType, ProtocolVersion recordVersion, int ciphertextLength, int plaintextLength, byte[] connectionID)

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 static int
getNonceMode(boolean isTLSv13, int aeadType)

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.
pack-priv static Class<T>
lookup(final String className)

private void
rekeyCipher(SecurityParameters securityParameters, TlsAEADCipherImpl cipher, byte[] nonce, boolean serverSecret)

public void
public void
private void
setup13Cipher(TlsAEADCipherImpl cipher, byte[] nonce, TlsSecret secret, int cryptoHashAlgorithm)

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

Field Detail

AEAD_CCMback to summary
public static final int AEAD_CCM
AEAD_CHACHA20_POLY1305back to summary
public static final int AEAD_CHACHA20_POLY1305
AEAD_GCMback to summary
public static final int AEAD_GCM
cryptoParamsback to summary
private final TlsCryptoParameters cryptoParams
decryptCipherback to summary
private final TlsAEADCipherImpl decryptCipher
decryptConnectionIDback to summary
private final byte[] decryptConnectionID
decryptNonceback to summary
private final byte[] decryptNonce
decryptUseInnerPlaintextback to summary
private final boolean decryptUseInnerPlaintext
encryptCipherback to summary
private final TlsAEADCipherImpl encryptCipher
encryptConnectionIDback to summary
private final byte[] encryptConnectionID
encryptNonceback to summary
private final byte[] encryptNonce
encryptNonceGeneratorback to summary
protected final AEADNonceGenerator encryptNonceGenerator
encryptUseInnerPlaintextback to summary
private final boolean encryptUseInnerPlaintext
EPOCH_1back to summary
private static final byte[] EPOCH_1
fipsNonceGeneratorClassback to summary
private static final Class<T> fipsNonceGeneratorClass
fixed_iv_lengthback to summary
private final int fixed_iv_length
isTLSv13back to summary
private final boolean isTLSv13
keySizeback to summary
private final int keySize
macSizeback to summary
private final int macSize
NONCE_RFC5288back to summary
private static final int NONCE_RFC5288
NONCE_RFC7905back to summary
private static final int NONCE_RFC7905
nonceModeback to summary
private final int nonceMode
record_iv_lengthback to summary
private final int record_iv_length
SEQUENCE_NUMBER_PLACEHOLDERback to summary
private static final long SEQUENCE_NUMBER_PLACEHOLDER

Constructor Detail

TlsAEADCipherback to summary
public TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int keySize, int macSize, int aeadType) throws IOException

Method Detail

decodeCiphertextback to summary
public TlsDecodeResult decodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int ciphertextOffset, int ciphertextLength) 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.

ciphertextOffset:int

offset into input array the ciphertext starts at.

ciphertextLength: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 plaintextOffset, int plaintextLength) 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.

plaintextOffset:int

offset into input array the plaintext starts at.

plaintextLength:int

length of the plaintext in the array.

Returns:TlsEncodeResult

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

getAdditionalDataback to summary
private byte[] getAdditionalData(long seqNo, short recordType, ProtocolVersion recordVersion, int ciphertextLength, int plaintextLength, byte[] connectionID) throws IOException
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.

getNonceModeback to summary
private static int getNonceMode(boolean isTLSv13, int aeadType) throws IOException
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.

lookupback to summary
pack-priv static Class<T> lookup(final String className)
rekeyCipherback to summary
private void rekeyCipher(SecurityParameters securityParameters, TlsAEADCipherImpl cipher, byte[] nonce, boolean serverSecret) throws IOException
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.

setup13Cipherback to summary
private void setup13Cipher(TlsAEADCipherImpl cipher, byte[] nonce, TlsSecret secret, int cryptoHashAlgorithm) throws IOException
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.