]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Add interface for record protection
authorMatthew Endsley <mendsley@gmail.com>
Wed, 13 Jan 2021 18:37:06 +0000 (10:37 -0800)
committerMatthew Endsley <mendsley@gmail.com>
Tue, 2 Feb 2021 16:53:32 +0000 (08:53 -0800)
Hazel/Dtls/IRecordProtection.cs [new file with mode: 0644]
Hazel/Hazel.csproj

diff --git a/Hazel/Dtls/IRecordProtection.cs b/Hazel/Dtls/IRecordProtection.cs
new file mode 100644 (file)
index 0000000..1d70c6a
--- /dev/null
@@ -0,0 +1,66 @@
+using System;
+
+namespace Hazel.Dtls
+{
+    /// <summary>
+    /// DTLS cipher suite interface for protection of record payload.
+    /// </summary>
+    public interface IRecordProtection : IDisposable
+    {
+        /// <summary>
+        /// Calculate the size of an encrypted plaintext
+        /// </summary>
+        /// <param name="dataSize">Size of plaintext in bytes</param>
+        /// <returns>Size of encrypted ciphertext in bytes</returns>
+        int GetEncryptedSize(int dataSize);
+
+        /// <summary>
+        /// Calculate the size of decrypted ciphertext
+        /// </summary>
+        /// <param name="dataSize">Size of ciphertext in bytes</param>
+        /// <returns>Size of decrypted plaintext in bytes</returns>
+        int GetDecryptedSize(int dataSize);
+
+        /// <summary>
+        /// Encrypt a plaintext intput with server keys
+        ///
+        /// Output may overlap with input.
+        /// </summary>
+        /// <param name="output">Output ciphertext</param>
+        /// <param name="input">Input plaintext</param>
+        /// <param name="record">Parent DTLS record</param>
+        void EncryptServerPlaintext(ByteSpan output, ByteSpan input, ref Record record);
+
+        /// <summary>
+        /// Encrypt a plaintext intput with client keys
+        ///
+        /// Output may overlap with input.
+        /// </summary>
+        /// <param name="output">Output ciphertext</param>
+        /// <param name="input">Input plaintext</param>
+        /// <param name="record">Parent DTLS record</param>
+        void EncryptClientPlaintext(ByteSpan output, ByteSpan input, ref Record record);
+
+        /// <summary>
+        /// Decrypt a ciphertext intput with server keys
+        ///
+        /// Output may overlap with input.
+        /// </summary>
+        /// <param name="output">Output plaintext</param>
+        /// <param name="input">Input ciphertext</param>
+        /// <param name="record">Parent DTLS record</param>
+        /// <returns>True if the input was authenticated and decrypted. Otherwise false</returns>
+        bool DecryptCiphertextFromServer(ByteSpan output, ByteSpan input, ref Record record);
+
+        /// <summary>
+        /// Decrypt a ciphertext intput with client keys
+        ///
+        /// Output may overlap with input.
+        /// </summary>
+        /// <param name="output">Output plaintext</param>
+        /// <param name="input">Input ciphertext</param>
+        /// <param name="record">Parent DTLS record</param>
+        /// <returns>True if the input was authenticated and decrypted. Otherwise false</returns>
+        bool DecryptCiphertextFromClient(ByteSpan output, ByteSpan input, ref Record record);
+    }
+}
index e102524b40de3ed944963154e0115d529ded321b..0d176f3c0833a4bf57fa9368d21c5fd86e3d4fa2 100644 (file)
@@ -80,6 +80,7 @@
     <Compile Include="DisconnectedEventArgs.cs" />
     <Compile Include="Dtls\Handshake.cs" />
     <Compile Include="Dtls\IHandshakeCipherSuite.cs" />
+    <Compile Include="Dtls\IRecordProtection.cs" />
     <Compile Include="Dtls\PrfSha256.cs" />
     <Compile Include="Dtls\Record.cs" />
     <Compile Include="Dtls\X25519EcdheRsaSha256.cs" />