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
1 answer

Reading attributes from private key

I'm trying to use Pkcs11Interop to sign a message using the private key from a smart card certificate in a C# application. The smart card we are using contain multiple certificates - usually one is for signing, and one is for authentication. If I…
kc9ddi
  • 141
  • 1
  • 7
1
vote
1 answer

How to use a private key that is stored on an HSM that is secured by a user password via Pkcs11Interop OR CNG?

Summary Use CNG or Pkcs11Interop or any other alternatives to login to an HSM, search for a privatekey then pass it on to a 3rd party application for use. The key cannot be extracted from the HSM or stored in memory. a 3rd Party application needs to…
Raeef
  • 13
  • 4
1
vote
1 answer

Is there a way to get signature creation date in signature that was created by pkcs11Interop?

I verify certificate with X509Chain.Build(X509Certificate2) method. If certificate is valid i sign data using Pkcs11Interop library. Any users who are interested can download this signature to verify by themselves. But also they should be able to…
1
vote
1 answer

DotNet Core: How to cross-platform Client Certificate TLS Authentication?

I'm trying to develop a cross-platform app (windows/mac os x) that needs to sign XML files and make web requests on a server using ClientCertificate authentication... The main constraint is that I need to use a certificate on a smartcard... I'm…
NoZ
  • 11
  • 2
1
vote
2 answers

How to fix method C_GenerateKeyPair returned CKR_FUNCTION_FAILED

I am trying to use the Pkcs11Interop library to get my own certificate from HSM(Safenet inc) when i have generated public/private key i got error "Method C_GenerateKeyPair returned CKR_FUNCTION_FAILED" My code if…
Miracu
  • 11
  • 1
  • 2
1
vote
2 answers

How to Update particular Attribute after finding an object. getting error Method C_SetAttributeValue returned CKR_ATTRIBUTE_READ_ONLY

I am trying to update an attribute after finding the object. Have tried out different cases. My creation code: using (var pkcs11 = new Pkcs11(@"C:\SoftHSM2\lib\softhsm2.dll", AppType.SingleThreaded)) { var slot =…
Kamran Shahid
  • 3,954
  • 5
  • 48
  • 93
1
vote
0 answers

Type definitions and the size of various types on multi-platform distributions

I'm slightly confused by the PKCS11Interop library's use of types across different OS platforms. My understanding is that the size of a long on Windows x64 is 4 bytes but on Linux/iOS 64bit the length is 8 bytes. This is indeed reflected in the…
1
vote
0 answers

Export/Import keys using pkcs11interop

I'm trying to export/import private & public keys. According to pkcs11Admin those actions aren't supported currently. Any idea how to do it? Relevant attributes for key generation before exporting (CKA_SENSITIVE, CKA_EXTRACTABLE)? Should I wrap the…
tos
  • 11
  • 1
1
vote
1 answer

How to wrap unwrap private key?

My code for wrap and unwrap public and private key public void BasicWrapAndUnwrapKeyTest() { using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.AppType)) { // Find first slot with token present Slot…
Noppadol
  • 11
  • 3
1
vote
1 answer

Session.GetOperationState() method is throwing exception "Method C_GetOperationState returned CKR_FUNCTION_NOT_SUPPORTED in SoftHSM"

We are using SoftHSM in our application. We have generated tokens and imported keys in it. Now we have created one job which monitors if our SoftHSM is Up and running. For that, It seems that the Session.GetOperationState() method should be able to…
Kumar
  • 63
  • 1
  • 10
1
vote
0 answers

How to find public keys using the Pkcs11 library?

I'm trying to find public keys (certificates) with this code below but I can't collect those certificates. using (Pkcs11 pkcs11 = new Pkcs11(@"\\ip\c$\Program Files\SafeNet\Protect Toolkit 5\Protect Toolkit C SDK\bin\sw\cryptoki.dll",…
TEngineer
  • 95
  • 1
  • 18
1
vote
1 answer

PBKDF2 key generation using pkcs11interop, c#, windows visual studio 2010

How to make attribute template for PBKDF2 key generation in pkcs11interop. Below is my trial code : byte[] randomSalt = session.GenerateRandom(20); objectAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, CKZ.CKZ_SALT_SPECIFIED)); …
1
vote
1 answer

pkcs11interop Get error code from exception

I have two cards with different types of tokens. When calling GetTokenInfo() I get CKR_TOKEN_NOT_RECOGNIZED on some tokens. My question is, how do I retrieve this error code in a clean manner? HResult just indicates General Error. I could check for…
Jacob Holm
  • 33
  • 4
1
vote
0 answers

Sign Xml using PKCS11 interop

I want to sign XML using the pkcs11Interop library, I am using below code to sign XML but signature verification fails. when I use System.Security.Cryptography.Xml.SignedXml to sign it passes signature verification. The DigestValue generated by my…
Prashanth
  • 507
  • 5
  • 25
1
vote
1 answer

Programmatically synchronizing keys generated by HSM clients with the RFS server

I am using PKCS11Interop to perform Key Management operations inside an HSM. The HSM I am using is a network HSM, Thales N-Shield. Here are the details of my setup: 1- HSM 1- RFS Server 3- Clients My software application is distributed and is hosted…
Aashish Upadhyay
  • 840
  • 1
  • 7
  • 22