I use pkcs11 dll in my wpf project, but i want to know what driver/software version my eID reader has so if it is an old version, we can make a popup with "update your driver for the eID reader"
part of code:
_pkcs11 = new Pkcs11("beidpkcs11.dll", false);
LibraryInfo Lib = _pkcs11.GetInfo();
DllVersion = Lib.CryptokiVersion;
You seem to be using PKCS#11 API via managed Pkcs11Interop wrapper to access your eID card but IMO this API does not provide information about the version of your smartcard reader driver. Your best shot is to try to examine HardwareVersion
and/or FirmwareVersion
properties of SlotInfo
class which contains information about your smarcard reader (known as slot in PKCS#11) but these fields have slightly different meaning:
using (Pkcs11 pkcs11 = new Pkcs11("beidpkcs11.dll", true))
{
List<Slot> slots = pkcs11.GetSlotList(false);
foreach (Slot slot in slots)
{
SlotInfo slotInfo = slot.GetSlotInfo();
// Examine slotInfo.HardwareVersion
// Examine slotInfo.FirmwareVersion
}
}
You can also try to read SCARD_ATTR_VENDOR_IFD_VERSION
reader attribute with SCardGetAttrib()
function which is part of PC/SC interface but I am not sure whether the returned value is driver version or device hardware version. Following example reads this attribute with managed pcsc-sharp wrapper:
using System;
using PCSC;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var context = new SCardContext();
context.Establish(SCardScope.System);
var readerNames = context.GetReaders();
if (readerNames == null || readerNames.Length < 1)
{
Console.WriteLine("You need at least one reader in order to run this example.");
Console.ReadKey();
return;
}
foreach (var readerName in readerNames)
{
var reader = new SCardReader(context);
Console.Write("Trying to connect to reader.. " + readerName);
var rc = reader.Connect(readerName, SCardShareMode.Shared, SCardProtocol.Any);
if (rc != SCardError.Success)
{
Console.WriteLine(" failed. No smart card present? " + SCardHelper.StringifyError(rc) + "\n");
}
else
{
Console.WriteLine(" done.");
byte[] attribute = null;
rc = reader.GetAttrib(SCardAttribute.VendorInterfaceDeviceTypeVersion, out attribute);
if (rc != SCardError.Success)
Console.WriteLine("Error by trying to receive attribute. {0}\n", SCardHelper.StringifyError(rc));
else
Console.WriteLine("Attribute value: {0}\n", BitConverter.ToString(attribute ?? new byte[] { }));
reader.Disconnect(SCardReaderDisposition.Leave);
}
}
context.Release();
Console.ReadKey();
}
}
}
Other than that you would need to use some OS specific low level driver APIs but I am not familiar with any of those.