]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Add initial cipher suite interfaces
authorMatthew Endsley <mendsley@gmail.com>
Sat, 19 Dec 2020 02:21:34 +0000 (18:21 -0800)
committerMatthew Endsley <mendsley@gmail.com>
Tue, 2 Feb 2021 16:53:31 +0000 (08:53 -0800)
Hazel/Dtls/IHandshakeCipherSuite.cs [new file with mode: 0644]
Hazel/Hazel.csproj

diff --git a/Hazel/Dtls/IHandshakeCipherSuite.cs b/Hazel/Dtls/IHandshakeCipherSuite.cs
new file mode 100644 (file)
index 0000000..4428e85
--- /dev/null
@@ -0,0 +1,60 @@
+using System;
+
+namespace Hazel.Dtls
+{
+    /// <summary>
+    /// DTLS cipher suite interface for the handshake portion of
+    /// the connection.
+    /// </summary>
+    public interface IHandshakeCipherSuite : IDisposable
+    {
+        /// <summary>
+        /// Gets the size of the shared key
+        /// </summary>
+        /// <returns>Size of the shared key in bytes </returns>
+        int SharedKeySize();
+
+        /// <summary>
+        /// Calculate the size of the ServerKeyExchnage message
+        /// </summary>
+        /// <returns>Size of the message in bytes</returns>
+        int CalculateServerMessageSize();
+
+        /// <summary>
+        /// Encodes the ServerKeyExchange message
+        /// </summary>
+        /// <param name="privateKey">Private key to use for signing</param>
+        void EncodeServerKeyExchangeMessage(ByteSpan output, object privateKey);
+
+        /// <summary>
+        /// Verifies the authenticity of a server key exchange
+        /// message and calculates the shared secret.
+        /// </summary>
+        /// <returns>
+        /// True if the authenticity has been validated and a shared key
+        /// was generated. Otherwise, false.
+        /// </returns>
+        bool VerifyServerMessageAndGenerateSharedKey(ByteSpan output, ByteSpan serverKeyExchangeMessage, object publicKey);
+
+        /// <summary>
+        /// Calculate the size of the ClientKeyExchange message
+        /// </summary>
+        /// <returns>Size of the message in bytes</returns>
+        int CalculateClientMessageSize();
+
+        /// <summary>
+        /// Encodes the ClientKeyExchangeMessage
+        /// </summary>
+        void EncodeClientKeyExchangeMessage(ByteSpan output);
+
+        /// <summary>
+        /// Verifies the validity of a client key exchange message
+        /// and calculats the hsared secret.
+        /// </summary>
+        /// <returns>
+        /// True if the client exchange message is valid and a
+        /// shared key was generated. Otherwise, false.
+        /// </returns>
+        bool VerifyClientMessageAndGenerateSharedKey(ByteSpan output, ByteSpan clientKeyExchangeMessage);
+    }
+}
index f938a8d98f2c0e2ced0f5fd4806bca392d33d419..ac4ed51c08288c01f356cdd4cdb2ca1cd94e66c3 100644 (file)
@@ -78,6 +78,7 @@
     <Compile Include="Crypto\X25519.cs" />
     <Compile Include="DataReceivedEventArgs.cs" />
     <Compile Include="DisconnectedEventArgs.cs" />
+    <Compile Include="Dtls\IHandshakeCipherSuite.cs" />
     <Compile Include="FewerThreads\HazelThreadPool.cs" />
     <Compile Include="FewerThreads\ThreadLimitedUdpConnectionListener.cs" />
     <Compile Include="FewerThreads\ThreadLimitedUdpServerConnection.cs" />