From 56c0cf45c00b72e46248205a2f869bc5c060534d Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Fri, 18 Dec 2020 18:21:34 -0800 Subject: [PATCH] Add initial cipher suite interfaces --- Hazel/Dtls/IHandshakeCipherSuite.cs | 60 +++++++++++++++++++++++++++++ Hazel/Hazel.csproj | 1 + 2 files changed, 61 insertions(+) create mode 100644 Hazel/Dtls/IHandshakeCipherSuite.cs diff --git a/Hazel/Dtls/IHandshakeCipherSuite.cs b/Hazel/Dtls/IHandshakeCipherSuite.cs new file mode 100644 index 0000000..4428e85 --- /dev/null +++ b/Hazel/Dtls/IHandshakeCipherSuite.cs @@ -0,0 +1,60 @@ +using System; + +namespace Hazel.Dtls +{ + /// + /// DTLS cipher suite interface for the handshake portion of + /// the connection. + /// + public interface IHandshakeCipherSuite : IDisposable + { + /// + /// Gets the size of the shared key + /// + /// Size of the shared key in bytes + int SharedKeySize(); + + /// + /// Calculate the size of the ServerKeyExchnage message + /// + /// Size of the message in bytes + int CalculateServerMessageSize(); + + /// + /// Encodes the ServerKeyExchange message + /// + /// Private key to use for signing + void EncodeServerKeyExchangeMessage(ByteSpan output, object privateKey); + + /// + /// Verifies the authenticity of a server key exchange + /// message and calculates the shared secret. + /// + /// + /// True if the authenticity has been validated and a shared key + /// was generated. Otherwise, false. + /// + bool VerifyServerMessageAndGenerateSharedKey(ByteSpan output, ByteSpan serverKeyExchangeMessage, object publicKey); + + /// + /// Calculate the size of the ClientKeyExchange message + /// + /// Size of the message in bytes + int CalculateClientMessageSize(); + + /// + /// Encodes the ClientKeyExchangeMessage + /// + void EncodeClientKeyExchangeMessage(ByteSpan output); + + /// + /// Verifies the validity of a client key exchange message + /// and calculats the hsared secret. + /// + /// + /// True if the client exchange message is valid and a + /// shared key was generated. Otherwise, false. + /// + bool VerifyClientMessageAndGenerateSharedKey(ByteSpan output, ByteSpan clientKeyExchangeMessage); + } +} diff --git a/Hazel/Hazel.csproj b/Hazel/Hazel.csproj index f938a8d..ac4ed51 100644 --- a/Hazel/Hazel.csproj +++ b/Hazel/Hazel.csproj @@ -78,6 +78,7 @@ + -- 2.39.5