NTDLS.SecureKeyExchange 3.0.1

dotnet add package NTDLS.SecureKeyExchange --version 3.0.1                
NuGet\Install-Package NTDLS.SecureKeyExchange -Version 3.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NTDLS.SecureKeyExchange" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NTDLS.SecureKeyExchange --version 3.0.1                
#r "nuget: NTDLS.SecureKeyExchange, 3.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NTDLS.SecureKeyExchange as a Cake Addin
#addin nuget:?package=NTDLS.SecureKeyExchange&version=3.0.1

// Install NTDLS.SecureKeyExchange as a Cake Tool
#tool nuget:?package=NTDLS.SecureKeyExchange&version=3.0.1                

NTDLS.SecureKeyExchange

📦 Be sure to check out the NuGet package: https://www.nuget.org/packages/NTDLS.SecureKeyExchange

Easily generate a single or multi-round Diffie-Hellman key C#.

Scenario (use your imagination):

  • localHost is a local service.
  • remotePeer is a remote peer.
//localHost starts the process with a call to GenerateNegotiationToken(),
//  specifying the size of the key (which is actually n*16).
var localHost = new CompoundNegotiator();
byte[] negotiationToken = localHost.GenerateNegotiationToken(8);

//localHost passes the resulting bytes from GenerateNegotiationToken()
//  to a remote peer which passes the bytes to ApplyNegotiationToken().
var remotePeer = new CompoundNegotiator();
byte[] negotiationReply = remotePeer.ApplyNegotiationToken(negotiationToken);

//The remotePeer passes the bytes from ApplyNegotiationToken() back to the 
//  localHost, where the localHost passes them to ApplyNegotiationResponseToken()
localHost.ApplyNegotiationResponseToken(negotiationReply);

//At this point, both the localHost and the remotePeer have the same bytes in
//  "SharedSecret" as we can see from comparing the "SharedSecretHash".
if (remotePeer.SharedSecretHash != localHost.SharedSecretHash)
{
    throw new Exception("This should never happen.");
}

Console.WriteLine($"Key length: {localHost.KeyLength} bytes.");
Console.WriteLine($" Local Shared Secret: {localHost.SharedSecretHash}");
Console.WriteLine($"Remote Shared Secret: {remotePeer.SharedSecretHash}");

License

[Apache-2.0](https://choosealicense.com/licenses/mit/)

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 136 6/22/2024
3.0.0 108 6/22/2024
2.2.2 95 6/12/2024
2.2.1 273 11/15/2023
2.2.0 153 11/2/2023
2.1.0 156 10/12/2023
2.0.2 145 10/10/2023
2.0.1 362 11/19/2022
2.0.0 354 11/19/2022
1.0.0 354 11/18/2022

Added key expansion and changed resulting share secret to 16 bytes per unit.
     This breaks compatibility with previous versions, but is a highly recommended update.