| Modifier and Type | Field and Description |
|---|---|
protected boolean |
acceptExtraPadding |
protected TlsCrypto |
crypto |
protected TlsCryptoParameters |
cryptoParams |
protected TlsBlockCipherImpl |
decryptCipher |
protected TlsBlockCipherImpl |
encryptCipher |
protected boolean |
encryptThenMAC |
protected byte[] |
randomData |
protected TlsSuiteMac |
readMac |
protected boolean |
useExplicitIV |
protected boolean |
useExtraPadding |
protected TlsSuiteMac |
writeMac |
| Constructor and Description |
|---|
TlsBlockCipher(TlsCrypto crypto,
TlsCryptoParameters cryptoParams,
TlsBlockCipherImpl encryptCipher,
TlsBlockCipherImpl decryptCipher,
TlsHMAC clientMac,
TlsHMAC serverMac,
int cipherKeySize) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
checkPaddingConstantTime(byte[] buf,
int off,
int len,
int blockSize,
int macSize) |
protected int |
chooseExtraPadBlocks(java.security.SecureRandom r,
int max) |
TlsDecodeResult |
decodeCiphertext(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.
|
TlsEncodeResult |
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.
|
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 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.
|
protected int |
getCiphertextLength(int blockSize,
int macSize,
int maxPadding,
int plaintextLength) |
int |
getPlaintextLimit(int ciphertextLimit)
Return the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.
|
protected int |
lowestBitSet(int x) |
void |
rekeyDecoder() |
void |
rekeyEncoder() |
boolean |
usesOpaqueRecordType() |
protected final TlsCrypto crypto
protected final TlsCryptoParameters cryptoParams
protected final byte[] randomData
protected final boolean encryptThenMAC
protected final boolean useExplicitIV
protected final boolean acceptExtraPadding
protected final boolean useExtraPadding
protected final TlsBlockCipherImpl decryptCipher
protected final TlsBlockCipherImpl encryptCipher
protected final TlsSuiteMac readMac
protected final TlsSuiteMac writeMac
public TlsBlockCipher(TlsCrypto crypto, TlsCryptoParameters cryptoParams, TlsBlockCipherImpl encryptCipher, TlsBlockCipherImpl decryptCipher, TlsHMAC clientMac, TlsHMAC serverMac, int cipherKeySize) throws java.io.IOException
java.io.IOExceptionpublic int getCiphertextDecodeLimit(int plaintextLimit)
TlsCiphergetCiphertextDecodeLimit in interface TlsCipherplaintextLimit - the maximum output size for the plaintext.public int getCiphertextEncodeLimit(int plaintextLength,
int plaintextLimit)
TlsCiphergetCiphertextEncodeLimit in interface TlsCipherplaintextLength - the actual input size for the plaintext.plaintextLimit - the maximum input size for the plaintext.public int getPlaintextLimit(int ciphertextLimit)
TlsCiphergetPlaintextLimit in interface TlsCipherciphertextLimit - the maximum number of bytes of ciphertext.public TlsEncodeResult encodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion, int headerAllocation, byte[] plaintext, int offset, int len) throws java.io.IOException
TlsCipherencodePlaintext in interface TlsCipherseqNo - 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 plain text to the cipher.offset - offset into input array the plain text starts at.len - length of the plaintext in the array.TlsEncodeResult containing the result of encoding (after 'headerAllocation' unused bytes).java.io.IOExceptionpublic TlsDecodeResult decodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int offset, int len) throws java.io.IOException
TlsCipherdecodeCiphertext in interface TlsCipherseqNo - 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 cipher text to the cipher.offset - offset into input array the cipher text starts at.len - length of the cipher text in the array.TlsDecodeResult containing the result of decoding.java.io.IOExceptionpublic void rekeyDecoder()
throws java.io.IOException
rekeyDecoder in interface TlsCipherjava.io.IOExceptionpublic void rekeyEncoder()
throws java.io.IOException
rekeyEncoder in interface TlsCipherjava.io.IOExceptionpublic boolean usesOpaqueRecordType()
usesOpaqueRecordType in interface TlsCipherprotected int checkPaddingConstantTime(byte[] buf,
int off,
int len,
int blockSize,
int macSize)
protected int chooseExtraPadBlocks(java.security.SecureRandom r,
int max)
protected int getCiphertextLength(int blockSize,
int macSize,
int maxPadding,
int plaintextLength)
protected int lowestBitSet(int x)