Modifier and Type | Field and Description |
---|---|
protected boolean |
acceptExtraPadding |
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(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(int max) |
TlsDecodeResult |
decodeCiphertext(long seqNo,
short recordType,
ProtocolVersion recordVersion,
byte[] ciphertext,
int offset,
int len)
Decode the passed in ciphertext using the current bulk cipher.
|
TlsEncodeResult |
encodePlaintext(long seqNo,
short contentType,
ProtocolVersion recordVersion,
int headerAllocation,
byte[] plaintext,
int offset,
int len)
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 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 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(TlsCryptoParameters cryptoParams, TlsBlockCipherImpl encryptCipher, TlsBlockCipherImpl decryptCipher, TlsHMAC clientMac, TlsHMAC serverMac, int cipherKeySize) throws java.io.IOException
java.io.IOException
public int getCiphertextDecodeLimit(int plaintextLimit)
TlsCipher
getCiphertextDecodeLimit
in interface TlsCipher
plaintextLimit
- the maximum output size for the plaintext.public int getCiphertextEncodeLimit(int plaintextLength, int plaintextLimit)
TlsCipher
getCiphertextEncodeLimit
in interface TlsCipher
plaintextLength
- the actual input size for the plaintext.plaintextLimit
- the maximum input size for the plaintext.public int getPlaintextLimit(int ciphertextLimit)
TlsCipher
getPlaintextLimit
in interface TlsCipher
ciphertextLimit
- 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
TlsCipher
encodePlaintext
in interface TlsCipher
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.offset
- offset into input array the plaintext starts at.len
- length of the plaintext in the array.TlsEncodeResult
containing the result of encoding (after 'headerAllocation' unused bytes).java.io.IOException
public TlsDecodeResult decodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int offset, int len) throws java.io.IOException
TlsCipher
decodeCiphertext
in interface TlsCipher
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.offset
- offset into input array the ciphertext starts at.len
- length of the ciphertext in the array.TlsDecodeResult
containing the result of decoding.java.io.IOException
public void rekeyDecoder() throws java.io.IOException
rekeyDecoder
in interface TlsCipher
java.io.IOException
public void rekeyEncoder() throws java.io.IOException
rekeyEncoder
in interface TlsCipher
java.io.IOException
public boolean usesOpaqueRecordType()
usesOpaqueRecordType
in interface TlsCipher
protected int checkPaddingConstantTime(byte[] buf, int off, int len, int blockSize, int macSize)
protected int chooseExtraPadBlocks(int max)
protected int getCiphertextLength(int blockSize, int macSize, int maxPadding, int plaintextLength)
protected int lowestBitSet(int x)