Package org.bouncycastle.tls.crypto
Interface TlsCipher
- All Known Implementing Classes:
TlsAEADCipher,TlsBlockCipher,TlsNullCipher,TlsNullNullCipher
public interface TlsCipher
Base interface for a TLS cipher suite.
-
Method Summary
Modifier and TypeMethodDescriptiondecodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int offset, int len) Validate and decrypt the passed in cipher text using the current cipher suite.encodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion, int headerAllocation, byte[] plaintext, int offset, int len) Encrypt and MAC the passed in plain text using the current cipher suite.intgetCiphertextDecodeLimit(int plaintextLimit) Return the maximum input size for a ciphertext given a maximum output size for the plaintext of plaintextLimit bytes.intgetCiphertextEncodeLimit(int plaintextLength, int plaintextLimit) Return the maximum output size for a ciphertext given an actual input plaintext size of plaintextLength bytes and a maximum input plaintext size of plaintextLimit bytes.intgetPlaintextLimit(int ciphertextLimit) Return the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.voidvoidboolean
-
Method Details
-
getCiphertextDecodeLimit
int getCiphertextDecodeLimit(int plaintextLimit) Return the maximum input size for a ciphertext given a maximum output size for the plaintext of plaintextLimit bytes.- Parameters:
plaintextLimit- the maximum output size for the plaintext.- Returns:
- the maximum input size of the ciphertext for plaintextlimit bytes of output.
-
getCiphertextEncodeLimit
int getCiphertextEncodeLimit(int plaintextLength, int plaintextLimit) Return the maximum output size for a ciphertext given an actual input plaintext size of plaintextLength bytes and a maximum input plaintext size of plaintextLimit bytes.- Parameters:
plaintextLength- the actual input size for the plaintext.plaintextLimit- the maximum input size for the plaintext.- Returns:
- the maximum output size of the ciphertext for plaintextlimit bytes of input.
-
getPlaintextLimit
int getPlaintextLimit(int ciphertextLimit) Return the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.- Parameters:
ciphertextLimit- the maximum number of bytes of ciphertext.- Returns:
- the maximum size of the plaintext for ciphertextlimit bytes of input.
-
encodePlaintext
TlsEncodeResult encodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion, int headerAllocation, byte[] plaintext, int offset, int len) throws IOException Encrypt and MAC the passed in plain text using the current cipher suite.- Parameters:
seqNo- sequence number of the message represented by plaintext.contentType- content type of the message represented by plaintext.recordVersion-ProtocolVersionused for the record.headerAllocation- extra bytes to allocate at start of returned byte array.plaintext- array holding input plain text to the cipher.offset- offset into input array the plain text starts at.len- length of the plaintext in the array.- Returns:
- A
TlsEncodeResultcontaining the result of encoding (after 'headerAllocation' unused bytes). - Throws:
IOException
-
decodeCiphertext
TlsDecodeResult decodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int offset, int len) throws IOException Validate and decrypt the passed in cipher text using the current cipher suite.- Parameters:
seqNo- sequence number of the message represented by ciphertext.recordType- content type used in the record for this message.recordVersion-ProtocolVersionused for the record.ciphertext- array holding input cipher text to the cipher.offset- offset into input array the cipher text starts at.len- length of the cipher text in the array.- Returns:
- A
TlsDecodeResultcontaining the result of decoding. - Throws:
IOException
-
rekeyDecoder
- Throws:
IOException
-
rekeyEncoder
- Throws:
IOException
-
usesOpaqueRecordType
boolean usesOpaqueRecordType()
-