YubiHsmSharp 2.7.3-alpha
dotnet add package YubiHsmSharp --version 2.7.3-alpha
NuGet\Install-Package YubiHsmSharp -Version 2.7.3-alpha
<PackageReference Include="YubiHsmSharp" Version="2.7.3-alpha" />
<PackageVersion Include="YubiHsmSharp" Version="2.7.3-alpha" />
<PackageReference Include="YubiHsmSharp" />
paket add YubiHsmSharp --version 2.7.3-alpha
#r "nuget: YubiHsmSharp, 2.7.3-alpha"
#:package YubiHsmSharp@2.7.3-alpha
#addin nuget:?package=YubiHsmSharp&version=2.7.3-alpha&prerelease
#tool nuget:?package=YubiHsmSharp&version=2.7.3-alpha&prerelease
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 | Versions 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. |
-
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 |