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 protected TlsCryptoParameters
cryptoParams
protected TlsAEADCipherImpl
decryptCipher
protected byte[]
decryptImplicitNonce
protected TlsAEADCipherImpl
encryptCipher
protected byte[]
encryptImplicitNonce
protected int
macSize
static int
NONCE_RFC5288
static int
NONCE_RFC7905
protected int
nonceMode
protected int
record_iv_length
-
Constructor Summary
Constructors Constructor Description TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int cipherKeySize, int macSize)
TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int cipherKeySize, int macSize, int nonceMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.protected byte[]
getAdditionalData(long seqNo, short type, int len)
int
getCiphertextLimit(int plaintextLimit)
Return the maximum size for the ciphertext given plaintextlimit bytes of plaintext.int
getPlaintextLimit(int ciphertextLimit)
Return the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.
-
-
-
Field Detail
-
NONCE_RFC5288
public static final int NONCE_RFC5288
- See Also:
- Constant Field Values
-
NONCE_RFC7905
public static final int NONCE_RFC7905
- See Also:
- Constant Field Values
-
cryptoParams
protected final TlsCryptoParameters cryptoParams
-
macSize
protected final int macSize
-
record_iv_length
protected final int record_iv_length
-
decryptCipher
protected final TlsAEADCipherImpl decryptCipher
-
encryptCipher
protected final TlsAEADCipherImpl encryptCipher
-
encryptImplicitNonce
protected final byte[] encryptImplicitNonce
-
decryptImplicitNonce
protected final byte[] decryptImplicitNonce
-
nonceMode
protected final int nonceMode
-
-
Constructor Detail
-
TlsAEADCipher
public TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int cipherKeySize, int macSize) throws java.io.IOException
- Throws:
java.io.IOException
-
TlsAEADCipher
public TlsAEADCipher(TlsCryptoParameters cryptoParams, TlsAEADCipherImpl encryptCipher, TlsAEADCipherImpl decryptCipher, int cipherKeySize, int macSize, int nonceMode) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getCiphertextLimit
public int getCiphertextLimit(int plaintextLimit)
Description copied from interface:TlsCipher
Return the maximum size for the ciphertext given plaintextlimit bytes of plaintext.- Specified by:
getCiphertextLimit
in 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:TlsCipher
Return the maximum size for the plaintext given ciphertextlimit bytes of ciphertext.- Specified by:
getPlaintextLimit
in 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.IOException
Description copied from interface:TlsCipher
Encrypt and MAC the passed in plain text using the current cipher suite.- Specified by:
encodePlaintext
in 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.IOException
Description copied from interface:TlsCipher
Validate and decrypt the passed in cipher text using the current cipher suite.- Specified by:
decodeCiphertext
in 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
-
getAdditionalData
protected byte[] getAdditionalData(long seqNo, short type, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
-