Skip to content

Latest commit

 

History

History
123 lines (72 loc) · 3.71 KB

README.md

File metadata and controls

123 lines (72 loc) · 3.71 KB

Using YubiKey PIV with Microsoft.Net Cryptography Model

Table of Contents
  1. About
  2. Getting Started
  3. Usage
  4. License
  5. Contact
  6. Acknowledgments

About

This repository contains a Visual Studio 2019 solution with sample code in C# that uses Microsoft .NET Cryptography Model with YubiKey 5 PIV.

The C# code in YubiKeyPivSign.cs demonstrates how to sign some data with a YubiKey 5 PIV on Windows 10.

The YubiKey 5 PIV is accessed from Microsoft .NET Cryptography Model by using the underlying Microsoft Base Smart Card Crypto Provider.

(back to top)

Built With

(back to top)

Getting Started

To get started with the project follow the steps below.

Prerequisites

Use a PC with Windows 10 or higher as operating system.

Download and install Microsoft Visual Studio 2019.

A X.509 certificate needs to be enrolled to the YubiKey 5 PIV before using this sample code for signing. For test purposes, it is possible to use the Yubico .NET YubiKey SDK to generate a key-pair and generate a self-signed certificate on the YubiKey 5 PIV.

Build the solution

  1. Clone the repo

    git clone https://github.com/YubicoLabs/Microsoft.Net-Crypto-YubiKey.git
  2. Open the solutions file Microsoft.Net-Crypto-YubiKey.sln with Microsoft Visual Studio 2019.

  3. Select the menu item "Build" and select the option "Build Solution".

(back to top)

Usage

Insert a YubiKey 5 with a X.509 certificate in the USB-port at the PC.

Run the application by either pressing the button "Microsoft.Net-Crypto-YubiKey" in the top bar of Microsoft Visual Studio 2019 (see the image above), or running the executable file <file path to the solution>\Microsoft.Net-Crypto-YubiKey\bin\Debug\net5.0\Microsoft.Net-Crypto-YubiKey.exe.

This will launch a command prompt, which in turn will present the Windows Security dialog box for a Smart Card. Enter the PIN code to the YubiKey 5 PIV in this dialog box.

(back to top)

License

Distributed under the Apache License 2.0. See LICENSE for more information.

(back to top)

Contact

Please contact the Yubico solutions developer program if you have any questions.

Website: https://developers.yubico.com/

Email: [email protected]

(back to top)

Acknowledgments

More information on how to use hardware modules and smart cards with Microsoft .NET is available at Microsoft's web: How to Access Hardware Encryption Devices.

(back to top)