Package org.bouncycastle.tls.crypto.impl
Class TlsAEADCipher
- java.lang.Object
-
- org.bouncycastle.tls.crypto.impl.TlsAEADCipher
-
-
Field Summary
Fields Modifier and Type Field Description static int
AEAD_CCM
static int
AEAD_CHACHA20_POLY1305
static int
AEAD_GCM
-
Constructor Summary
Constructors Constructor Description TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int keySize, int macSize, int aeadType)
Deprecated.Use version with extra 'nonceGeneratorFactory' parameterTlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int keySize, int macSize, int aeadType, AEADNonceGeneratorFactory nonceGeneratorFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TlsDecodeResult
decodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int ciphertextOffset, int ciphertextLength)
Decode the passed in ciphertext using the current bulk cipher.TlsEncodeResult
encodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion, int headerAllocation, byte[] plaintext, int plaintextOffset, int plaintextLength)
Encode the passed in plaintext using the current bulk cipher.int
getCiphertextDecodeLimit(int plaintextLimit)
Return the maximum input size for a ciphertext given a maximum output size for the plaintext of plaintextLimit bytes.int
getCiphertextEncodeLimit(int plaintextLimit)
Return the maximum output size for a ciphertext given a maximum input size for the plaintext of plaintextLimit bytes.int
getPlaintextDecodeLimit(int ciphertextLimit)
Return the maximum output size for the plaintext given a maximum input size for the ciphertext of ciphertextLimit bytes.int
getPlaintextEncodeLimit(int ciphertextLimit)
Return the maximum input size for the plaintext given a maximum output size for the ciphertext of ciphertextLimit bytes.void
rekeyDecoder()
void
rekeyEncoder()
boolean
usesOpaqueRecordTypeDecode()
boolean
usesOpaqueRecordTypeEncode()
-
-
-
Field Detail
-
AEAD_CCM
public static final int AEAD_CCM
- See Also:
- Constant Field Values
-
AEAD_CHACHA20_POLY1305
public static final int AEAD_CHACHA20_POLY1305
- See Also:
- Constant Field Values
-
AEAD_GCM
public static final int AEAD_GCM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TlsAEADCipher
public TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int keySize, int macSize, int aeadType) throws java.io.IOException
Deprecated.Use version with extra 'nonceGeneratorFactory' parameter- Throws:
java.io.IOException
-
TlsAEADCipher
public TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int keySize, int macSize, int aeadType, AEADNonceGeneratorFactory nonceGeneratorFactory) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getCiphertextDecodeLimit
public int getCiphertextDecodeLimit(int plaintextLimit)
Description copied from interface:TlsCipher
Return the maximum input size for a ciphertext given a maximum output size for the plaintext of plaintextLimit bytes.- Specified by:
getCiphertextDecodeLimit
in interfaceTlsCipher
- Parameters:
plaintextLimit
- the maximum output size for the plaintext.- Returns:
- the maximum input size of the ciphertext for plaintextLimit bytes of output.
-
getCiphertextEncodeLimit
public int getCiphertextEncodeLimit(int plaintextLimit)
Description copied from interface:TlsCipher
Return the maximum output size for a ciphertext given a maximum input size for the plaintext of plaintextLimit bytes.- Specified by:
getCiphertextEncodeLimit
in interfaceTlsCipher
- Parameters:
plaintextLimit
- the maximum input size for the plaintext.- Returns:
- the maximum output size of the ciphertext for plaintextLimit bytes of input.
-
getPlaintextDecodeLimit
public int getPlaintextDecodeLimit(int ciphertextLimit)
Description copied from interface:TlsCipher
Return the maximum output size for the plaintext given a maximum input size for the ciphertext of ciphertextLimit bytes.- Specified by:
getPlaintextDecodeLimit
in interfaceTlsCipher
- Parameters:
ciphertextLimit
- the maximum input size for the ciphertext.- Returns:
- the maximum output size of the plaintext for ciphertextLimit bytes of input.
-
getPlaintextEncodeLimit
public int getPlaintextEncodeLimit(int ciphertextLimit)
Description copied from interface:TlsCipher
Return the maximum input size for the plaintext given a maximum output size for the ciphertext of ciphertextLimit bytes.- Specified by:
getPlaintextEncodeLimit
in interfaceTlsCipher
- Parameters:
ciphertextLimit
- the maximum output size for the ciphertext.- Returns:
- the maximum input size of the plaintext for ciphertextLimit bytes of output.
-
encodePlaintext
public TlsEncodeResult encodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion, int headerAllocation, byte[] plaintext, int plaintextOffset, int plaintextLength) throws java.io.IOException
Description copied from interface:TlsCipher
Encode the passed in plaintext using the current bulk cipher.- Specified by:
encodePlaintext
in interfaceTlsCipher
- Parameters:
seqNo
- sequence number of the message represented by plaintext.contentType
- content type of the message represented by plaintext.recordVersion
-ProtocolVersion
used for the record.headerAllocation
- extra bytes to allocate at start of returned byte array.plaintext
- array holding input plaintext to the cipher.plaintextOffset
- offset into input array the plaintext starts at.plaintextLength
- length of the plaintext in the array.- Returns:
- A
TlsEncodeResult
containing the result of encoding (after 'headerAllocation' unused bytes). - Throws:
java.io.IOException
-
decodeCiphertext
public TlsDecodeResult decodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int ciphertextOffset, int ciphertextLength) throws java.io.IOException
Description copied from interface:TlsCipher
Decode the passed in ciphertext using the current bulk cipher.- Specified by:
decodeCiphertext
in interfaceTlsCipher
- Parameters:
seqNo
- sequence number of the message represented by ciphertext.recordType
- content type used in the record for this message.recordVersion
-ProtocolVersion
used for the record.ciphertext
- array holding input ciphertext to the cipher.ciphertextOffset
- offset into input array the ciphertext starts at.ciphertextLength
- length of the ciphertext in the array.- Returns:
- A
TlsDecodeResult
containing the result of decoding. - Throws:
java.io.IOException
-
rekeyDecoder
public void rekeyDecoder() throws java.io.IOException
- Specified by:
rekeyDecoder
in interfaceTlsCipher
- Throws:
java.io.IOException
-
rekeyEncoder
public void rekeyEncoder() throws java.io.IOException
- Specified by:
rekeyEncoder
in interfaceTlsCipher
- Throws:
java.io.IOException
-
usesOpaqueRecordTypeDecode
public boolean usesOpaqueRecordTypeDecode()
- Specified by:
usesOpaqueRecordTypeDecode
in interfaceTlsCipher
-
usesOpaqueRecordTypeEncode
public boolean usesOpaqueRecordTypeEncode()
- Specified by:
usesOpaqueRecordTypeEncode
in interfaceTlsCipher
-
-