<PackageReference Include="BouncyCastle.Cryptography" Version="2.3.1" />

Org.BouncyCastle.Tls.Crypto.Impl.TlsAeadCipher

A generic TLS 1.2 AEAD cipher.
namespace Org.BouncyCastle.Tls.Crypto.Impl { public class TlsAeadCipher : TlsCipher, TlsCipherExt { public const int AEAD_CCM = 1; public const int AEAD_CHACHA20_POLY1305 = 2; public const int AEAD_GCM = 3; protected readonly TlsCryptoParameters m_cryptoParams; protected readonly int m_keySize; protected readonly int m_macSize; protected readonly int m_fixed_iv_length; protected readonly int m_record_iv_length; protected readonly TlsAeadCipherImpl m_decryptCipher; protected readonly TlsAeadCipherImpl m_encryptCipher; protected readonly byte[] m_decryptNonce; protected readonly byte[] m_encryptNonce; protected readonly byte[] m_decryptConnectionID; protected readonly byte[] m_encryptConnectionID; protected readonly bool m_decryptUseInnerPlaintext; protected readonly bool m_encryptUseInnerPlaintext; protected readonly bool m_isTlsV13; protected readonly int m_nonceMode; public virtual bool UsesOpaqueRecordType { get; } public TlsAeadCipher(TlsCryptoParameters cryptoParams, TlsAeadCipherImpl encryptCipher, TlsAeadCipherImpl decryptCipher, int keySize, int macSize, int aeadType); public virtual int GetCiphertextDecodeLimit(int plaintextLimit); public virtual int GetCiphertextEncodeLimit(int plaintextLength, int plaintextLimit); public virtual int GetPlaintextLimit(int ciphertextLimit); public virtual int GetPlaintextDecodeLimit(int ciphertextLimit); public virtual int GetPlaintextEncodeLimit(int ciphertextLimit); public virtual TlsEncodeResult EncodePlaintext(long seqNo, short contentType, ProtocolVersion recordVersion, int headerAllocation, byte[] plaintext, int plaintextOffset, int plaintextLength); public virtual TlsDecodeResult DecodeCiphertext(long seqNo, short recordType, ProtocolVersion recordVersion, byte[] ciphertext, int ciphertextOffset, int ciphertextLength); public virtual void RekeyDecoder(); public virtual void RekeyEncoder(); protected virtual byte[] GetAdditionalData(long seqNo, short recordType, ProtocolVersion recordVersion, int ciphertextLength, int plaintextLength); protected virtual byte[] GetAdditionalData(long seqNo, short recordType, ProtocolVersion recordVersion, int ciphertextLength, int plaintextLength, byte[] connectionID); protected virtual void RekeyCipher(SecurityParameters securityParameters, TlsAeadCipherImpl cipher, byte[] nonce, bool serverSecret); protected virtual void Setup13Cipher(TlsAeadCipherImpl cipher, byte[] nonce, TlsSecret secret, int cryptoHashAlgorithm); } }