OpenPGP smartcard support for .NET

Version 1.9.1. of DidiSoft OpenPGP Library for .NET provides out of the box support for smart cards implementing the OpenPGP smartcard specification, like Yubikey, Nitrokey, OpenPGP card, etc.

In order to use private keys residing on the smartcard a new class SmartcardKeyStore (located in a new assembly DidiSoft.Pgp.Smartcard.dll) must be instantiated and provided to the PGPLib class for the desired operation. Here is a simple example that illustrates the PGP sign operation:

C# example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using DidiSoft.Pgp;
using DidiSoft.Pgp.Smartcard;
 
class SignSmartcardExample
{
 public static void Main()
 {
  // initialize the smartcard
  SmartcardKeyStore smartcard = new SmartcardKeyStore("Yubikey", "123456");
 
  // create an instance of the library
  PGPLib pgp = new PGPLib();
 
  bool asciiOutput = true;
  // sign a file
  pgp.SignFile("INPUT.txt", smartcard, "INPUT.pgp", asciiOutput);
 }
}

The actual sign operation is performed and computed transparently inside the smartcard.

If you decide to implement OpenPGP smartcard support in your application, you can take a closer look at the detailed tutorial page for OpenPGP smartcards.