Package org.bouncycastle.tls.crypto.impl
Class TlsBlockCipher
- java.lang.Object
-
- org.bouncycastle.tls.crypto.impl.TlsBlockCipher
-
-
Field Summary
Fields Modifier and Type Field Description protected TlsCryptocryptoprotected TlsCryptoParameterscryptoParamsprotected TlsBlockCipherImpldecryptCipherprotected TlsBlockCipherImplencryptCipherprotected booleanencryptThenMACprotected byte[]randomDataprotected TlsSuiteMacreadMacprotected booleanuseExplicitIVprotected booleanuseExtraPaddingprotected TlsSuiteMacwriteMac
-
Constructor Summary
Constructors Constructor Description TlsBlockCipher(TlsCrypto crypto, TlsCryptoParameters cryptoParams, TlsBlockCipherImpl encryptCipher, TlsBlockCipherImpl decryptCipher, TlsHMAC clientMac, TlsHMAC serverMac, int cipherKeySize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcheckPaddingConstantTime(byte[] buf, int off, int len, int blockSize, int macSize)protected intchooseExtraPadBlocks(java.security.SecureRandom r, int max)byte[]decodeCiphertext(long seqNo, short type, byte[] ciphertext, int offset, int len)Validate and decrypt the passed in cipher text using the current cipher suite.byte[]encodePlaintext(long seqNo, short type, byte[] plaintext, int offset, int len)Encrypt and MAC the passed in plain text using the current cipher suite.intgetCiphertextLimit(int plaintextLimit)Return the maximum size for the ciphertext given plaintextlimit bytes of plaintext.intgetPlaintextLimit(int ciphertextLimit)Return the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.protected intlowestBitSet(int x)
-
-
-
Field Detail
-
crypto
protected final TlsCrypto crypto
-
cryptoParams
protected final TlsCryptoParameters cryptoParams
-
randomData
protected final byte[] randomData
-
encryptThenMAC
protected final boolean encryptThenMAC
-
useExplicitIV
protected final boolean useExplicitIV
-
useExtraPadding
protected final boolean useExtraPadding
-
decryptCipher
protected final TlsBlockCipherImpl decryptCipher
-
encryptCipher
protected final TlsBlockCipherImpl encryptCipher
-
readMac
protected final TlsSuiteMac readMac
-
writeMac
protected final TlsSuiteMac writeMac
-
-
Constructor Detail
-
TlsBlockCipher
public TlsBlockCipher(TlsCrypto crypto, TlsCryptoParameters cryptoParams, TlsBlockCipherImpl encryptCipher, TlsBlockCipherImpl decryptCipher, TlsHMAC clientMac, TlsHMAC serverMac, int cipherKeySize) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getCiphertextLimit
public int getCiphertextLimit(int plaintextLimit)
Description copied from interface:TlsCipherReturn the maximum size for the ciphertext given plaintextlimit bytes of plaintext.- Specified by:
getCiphertextLimitin interfaceTlsCipher- Parameters:
plaintextLimit- the maximum number of bytes of plaintext.- Returns:
- the maximum size of the ciphertext for plaintextlimit bytes of input.
-
getPlaintextLimit
public int getPlaintextLimit(int ciphertextLimit)
Description copied from interface:TlsCipherReturn the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.- Specified by:
getPlaintextLimitin interfaceTlsCipher- Parameters:
ciphertextLimit- the maximum number of bytes of ciphertext.- Returns:
- the maximum size of the plaintext for ciphertextlimit bytes of input.
-
encodePlaintext
public byte[] encodePlaintext(long seqNo, short type, byte[] plaintext, int offset, int len) throws java.io.IOExceptionDescription copied from interface:TlsCipherEncrypt and MAC the passed in plain text using the current cipher suite.- Specified by:
encodePlaintextin interfaceTlsCipher- Parameters:
seqNo- sequence number of the message represented by plaintext.type- content type of the message represented by plaintext.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:
- the resulting cipher text.
- Throws:
java.io.IOException
-
decodeCiphertext
public byte[] decodeCiphertext(long seqNo, short type, byte[] ciphertext, int offset, int len) throws java.io.IOExceptionDescription copied from interface:TlsCipherValidate and decrypt the passed in cipher text using the current cipher suite.- Specified by:
decodeCiphertextin interfaceTlsCipher- Parameters:
seqNo- sequence number of the message represented by ciphertext.type- content type of the message represented by ciphertext.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:
- the resulting plaintext.
- Throws:
java.io.IOException
-
checkPaddingConstantTime
protected int checkPaddingConstantTime(byte[] buf, int off, int len, int blockSize, int macSize)
-
chooseExtraPadBlocks
protected int chooseExtraPadBlocks(java.security.SecureRandom r, int max)
-
lowestBitSet
protected int lowestBitSet(int x)
-
-