Questions tagged [pkcs11interop]

Pkcs11Interop is managed .NET wrapper for unmanaged PKCS#11 libraries that provide access to the cryptographic hardware

Pkcs11Interop is managed library written in C# that brings PKCS#11 API to the .NET environment.

It loads unmanaged PKCS#11 library provided by the cryptographic device vendor and makes its functions accessible to .NET application.

The library is open source and hosted on GitHub.

104 questions
1
vote
2 answers

Erroring out creating an ECDSA Key pair with pkcs11interop

I am connecting to Gemalto HSM which supports secp256r1. I have the following code to create an ECDSA key pair using Pkcs11interop. I am getting the paramsBytes using BouncyCastle NistNamedCurves and X962Parameters. The HSM keeps comming back with…
minime
  • 79
  • 8
1
vote
1 answer

Is it possible to connect with a HSM without PIN using PKCS11INTEROP library?

We are using PKCS11INTEROP library to connect with the NShield HSM. To perform any operation(generate/encrypt/decrypt) inside the HSM you need to first get the slot and then login to the slot using the PIN. This is all working as expected. NShield…
Aashish Upadhyay
  • 840
  • 1
  • 7
  • 22
1
vote
1 answer

Which one should I use: session vs _session in Pkcs11interop

I am facing the same issue as the owner of this thread: Threadsafe usage of PKCS11Interop library in C# Here you have provided a solution and given a link of…
Kumar
  • 63
  • 1
  • 10
1
vote
2 answers

Exception "CKR_FUNCTION_NOT_SUPPORTED", PKCS11Interop with OpenSC

I am trying to use PKCS11Interop Library with latest version (0.16) of OpenSC (opensc-pkcs11.dll). I have tried USB tokens from three vendors which are Yubico 4, NitroKey Pro/Start, Fetian ePass2003 but unable to use most of the functions from…
Kamran Khan
  • 23
  • 1
  • 4
1
vote
1 answer

Attempted to read or write protected memory. PKCS11Interop

I am getting Access violation exception in the highlighed line. Attempted to read or write protected memory. This is often an indication that other memory is corrupt. I have the certificate on the hsm and the label . I am building my application…
1
vote
1 answer

Convert PKCS'11 Object handle to X509Certificate Object in C#

How can i convert the Object_Handle which is a ulong returned by C_FindObject to a X509Certificate object in C#. Here is the code . ulong[] foundObjectIds = new ulong[10]; foundObjectIds[0] = CK_INVALID_HANDLE; success =…
0
votes
0 answers

Pcks11Interop Method C_Login returned CKR_SESSION_HANDLE_INVALID

I am experiencing an issue as follows: Method C_Login returned CKR_SESSION_HANDLE_INVALID at Net.Pkcs11Interop.HighLevelAPI80.Session.Login(CKU userType, String pin) at PKCS11Service.Initialize() in PKCS11Service.cs:line 81 at…
0
votes
1 answer

Connect to remote HSM with PKCS11interop

I'm just practising about Safenet soft HSM and PKCS11interop library. I am curios about how the librar decides to connect which HSM? I think the cryptoki library created in my local is configured to use local soft HSM. But I couldn't find any…
0
votes
1 answer

BouncyCastle gets error 'public key presented not for certificate signature' for retrieved ECPublicKey

I am trying to use BouncyCastle library for generating X509Certificate in a .Net application, meanwhile i want to use keys stored in HSM. My solution is generating EC key-pair in HSM, returning ECPoint and key lable to .Net application, and…
0
votes
0 answers

C# cms.ComputeSignature(signer) without prompting a PIN code (smart card)

I am trying to get a certificate signature using CMS/Pkcs, it keeps prompting me a PIN code. How to disable this pin code pop-up or include it within the code (Note it is a fixed pin and it does not change) Encoding utf8 = Encoding.UTF8; …
0
votes
1 answer

How to create a EC Key Pair?

I am trying to create an EC key pair using the Pkcs#11 interop library (5.1.2) but every time I try to generate one it returns CKR_TEMPLATE_INCOMPLETE or CKR_DOMAIN_PARAMS_INVALID. I am using SC650 smart card to be able to generate the keys. As well…
0
votes
1 answer

PKCS11 encrypt hash with RSA private key

We are building a Digitial Signing platform. Per user we generate a RSA 2048 key pair in an HSM, and issue a X509 digital certificate. During PAdEs or CAdES digital signing (Enveloping) we get the SHa256 hash 32 bytes that needs to be encrypted with…
user1912383
  • 359
  • 2
  • 6
  • 16
0
votes
0 answers

How i extract a certificate and a private key from a token with PKCS11 Interop LowLevele API

I have an application to sign a PDF file and I need to extract from token certificate and private key to do this. I need a code in C# with Pkcs11Interop LowLevel API. I've tried with this code: bool success = true; CK_ATTRIBUTE[] template = new…
0
votes
0 answers

How to add more signed attributes to an iText signature (PDF/CMS)

Problem: I want to sign PDF documents with iText and a PKCS11 provider (In C#, Java works too). This works, but the signed PDF lacks several signed attributes: Issuer Serial Number Signing Time So after a comment of @mkl I implemented a custom…
swaechter
  • 1,357
  • 3
  • 22
  • 46
0
votes
1 answer

PKCS#11Interop.X509Store unable to find Private Key

Pkcs11X509Certificate is unable to find the private key in some tokens. Pkcs11X509Certificate.GetRSAPrivateKey() yields null. Then, when I run SignedXml.ComputeSignature(), I get the following…
Dalmo
  • 1
  • 2