From: Matthew Endsley Date: Wed, 13 Jan 2021 18:37:06 +0000 (-0800) Subject: Add interface for record protection X-Git-Tag: 1.0.0~20^2~24^2~1 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=08cdd22301d363df28f5c5cf0f4ded3cad0069d2;p=rhonda%2Fimpostor.hazel.git Add interface for record protection --- diff --git a/Hazel/Dtls/IRecordProtection.cs b/Hazel/Dtls/IRecordProtection.cs new file mode 100644 index 0000000..1d70c6a --- /dev/null +++ b/Hazel/Dtls/IRecordProtection.cs @@ -0,0 +1,66 @@ +using System; + +namespace Hazel.Dtls +{ + /// + /// DTLS cipher suite interface for protection of record payload. + /// + public interface IRecordProtection : IDisposable + { + /// + /// Calculate the size of an encrypted plaintext + /// + /// Size of plaintext in bytes + /// Size of encrypted ciphertext in bytes + int GetEncryptedSize(int dataSize); + + /// + /// Calculate the size of decrypted ciphertext + /// + /// Size of ciphertext in bytes + /// Size of decrypted plaintext in bytes + int GetDecryptedSize(int dataSize); + + /// + /// Encrypt a plaintext intput with server keys + /// + /// Output may overlap with input. + /// + /// Output ciphertext + /// Input plaintext + /// Parent DTLS record + void EncryptServerPlaintext(ByteSpan output, ByteSpan input, ref Record record); + + /// + /// Encrypt a plaintext intput with client keys + /// + /// Output may overlap with input. + /// + /// Output ciphertext + /// Input plaintext + /// Parent DTLS record + void EncryptClientPlaintext(ByteSpan output, ByteSpan input, ref Record record); + + /// + /// Decrypt a ciphertext intput with server keys + /// + /// Output may overlap with input. + /// + /// Output plaintext + /// Input ciphertext + /// Parent DTLS record + /// True if the input was authenticated and decrypted. Otherwise false + bool DecryptCiphertextFromServer(ByteSpan output, ByteSpan input, ref Record record); + + /// + /// Decrypt a ciphertext intput with client keys + /// + /// Output may overlap with input. + /// + /// Output plaintext + /// Input ciphertext + /// Parent DTLS record + /// True if the input was authenticated and decrypted. Otherwise false + bool DecryptCiphertextFromClient(ByteSpan output, ByteSpan input, ref Record record); + } +} diff --git a/Hazel/Hazel.csproj b/Hazel/Hazel.csproj index e102524..0d176f3 100644 --- a/Hazel/Hazel.csproj +++ b/Hazel/Hazel.csproj @@ -80,6 +80,7 @@ +