YubiHsmSharp 2.7.3-alpha

This is a prerelease version of YubiHsmSharp.
dotnet add package YubiHsmSharp --version 2.7.3-alpha
                    
NuGet\Install-Package YubiHsmSharp -Version 2.7.3-alpha
                    
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="YubiHsmSharp" Version="2.7.3-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YubiHsmSharp" Version="2.7.3-alpha" />
                    
Directory.Packages.props
<PackageReference Include="YubiHsmSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YubiHsmSharp --version 2.7.3-alpha
                    
#r "nuget: YubiHsmSharp, 2.7.3-alpha"
                    
#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.
#:package YubiHsmSharp@2.7.3-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YubiHsmSharp&version=2.7.3-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=YubiHsmSharp&version=2.7.3-alpha&prerelease
                    
Install as a Cake Tool

YubiHsmSharp

This library is a C# wrapper around libyubihsm, a C library for communicating with a YubiHSM 2. The YubiHSM SDK is not included in this project and must be installed separately.

Usage

Debug output is controlled with the property YubiConnector.Verbosity, which can be set before the library is initialized.

First step of using a YubiHSM 2 is to initialize the library with new YubiModule(), initialize a connector with YubiModule.InitializeConnector(), and then connect it to the YubiHSM 2 with YubiConnector.Connect(). After this, a session must be established with YubiConnector.CreateSession().

When a session is established, commands can be exchanged over it. Raw commands can be sent with YubiSession.SendMessage(). However, nearly all commands are exposed as methods on YubiModule, YubiConnector, or YubiSession.

Example

Here is a small example of establishing a session with a YubiHSM 2 and fetching some pseudo random bytes before closing the session.

public static void Main()
{
    using YubiModule module = YubiModule.Instance;
    using YubiConnector connector = module.InitializeConnector("http://localhost:12345"u8);
    connector.Connect();
    using YubiSession session = connector.CreateSession(1, "password"u8);
    
    byte[] data = new byte[128];
    int dataLength = session.GetPseudoRandom(data);
    Debug.Assert(dataLength == data.Length);

    // session, connector, and module are automatically closed at the end of the scope.
}

Disclaimer

I do not own a YubiHSM 2 device, so this project is largely theoretical. Anyone wishing to use this library is strongly encouraged to perform their own testing against a YubiHSM 2 device.

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

    • No dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.7.3-alpha 0 6/14/2026