Pkcs11Interop | Managed .NET wrapper for unmanaged PKCS # 11 libraries | Cryptography library
kandi X-RAY | Pkcs11Interop Summary
kandi X-RAY | Pkcs11Interop Summary
PKCS#11 is cryptography standard maintained by the OASIS PKCS 11 Technical Committee (originally published by RSA Laboratories) that defines ANSI C API to access smart cards and other types of cryptographic hardware. Pkcs11Interop is managed library written in C# that brings full power of 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.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Pkcs11Interop
Pkcs11Interop Key Features
Pkcs11Interop Examples and Code Snippets
Community Discussions
Trending Discussions on Pkcs11Interop
QUESTION
I'm getting CKR_GENERAL_ERROR when configuring SunPKCS11 with softhsm.
Platform:
- Winodows 10 64bits
- OpenJDK 11.0.2
- https://github.com/disig/SoftHSM2-for-Windows/releases/download/v2.5.0/SoftHSM2-2.5.0.msi
Environment variables:
...ANSWER
Answered 2021-Apr-25 at 04:02Just setting SOFTHSM2_CONF environment variable in launcher, the provider was successfully configured and keystore could load instantly.
It seems not getting system environment variable.
QUESTION
I recently created a Console app which held the context of Pkcs11Interop library, along with HSM dll. It worked fine, however I needed to rewrite the code to Windows Service (I hosted it as gRPC service since it's .NET Core). After hosting WS, it ocurred that the slot list on factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, libraryPath, AppType.MultiThreaded).GetSlotList(SlotsType.WithOrWithoutTokenPresent).Find(slot => slot.SlotId == slotId) returns an empty list of slots, even though it returned list of 3 elements in console app.
...ANSWER
Answered 2021-Mar-28 at 16:47Pkcs11Interop returns slots received by calling C_GetSlotList
function of unmanaged PKCS#11 library. So if you get 0 slots then C_GetSlotList
returned 0 slots. You need to discuss this situation with the vendor of your PKCS#11 library who might know why their library does not see any slots.
QUESTION
I set up pkcs11Interop Library as follows
...ANSWER
Answered 2021-Feb-23 at 14:25> Is a DispatcherTimer ok for WaitForSlotEvent?
It should be OK in general. You might also consider using WaitForSlotEvent
in blocking mode called from a separate thread.
> What should I do to avoid C_WaitForSlotEvent CKR_DEVICE_ERROR?
You need to ask the vendor of your unmanaged PKCS#11 library.
AFAIK C_WaitForSlotEvent
was designed for token/card related events not for slot/reader related events. PKCS#11 specification states that when you add or remove slot/reader you might need to reload PKCS#11 library or even restart OS:
On some platforms, or earlier PKCS11 compliant libraries, it may be necessary to successfully call
C_Initialize
or to restart the entire system.
> Does pkcs11Interop handle the adding and removing of slots (ie. SmartCard Readers)?
Pkcs11Interop does nothing else but gives you access to unmanaged function C_WaitForSlotEvent
described in PKCS#11 specification.
> If pkcs11Interop does not handle adding and removing slots is polling the only way and what would be the best to poll?
See answer to first question.
QUESTION
From the meigk/pkcs11 package. Is there any way to assign a negative value in the Login function as userType? Because the HSM model that I'm working with, supports one more additional role except for the following standard roles and I want to login with that role.
Standard roles:
...ANSWER
Answered 2021-Jan-26 at 12:28If type of the parameter is uint
, you can only pass values that are assignable to the type uint
(as stated in Spec: Calls). And the valid range of uint
does not include negative numbers.
What you may do is convert your negative value to uint
. Converting a negative int
to uint
is roughly equivalent to subtracting the absolute value from the max value of int
plus 1. So if your other constants are small, this won't cause a collision.
For example:
QUESTION
I want to use the cherry SmartTerminal ST-1144 in order to finally sign pdf documents with certificates from a smartcard. I do use the .net PKCS11Interop. In the following code i need to provide the unmanaged PKCS11 library for the Cherry SmartTerminal ST-1144:
...ANSWER
Answered 2021-Jan-12 at 14:38PKCS#11 library is not driver for card reader (in your case Cherry SmartTerminal ST-1144). PKCS#11 library is driver for the card. So I highly doubt such library is installed as a part of package provided by Cherry. It should be installed as part of software you got with your smartcard.
QUESTION
I'm using Pkcs11Interop Library and trying to test encryption and decryption with RSA_PKCS_OAEP mechanism.
...ANSWER
Answered 2020-Nov-18 at 21:38I had the same problem with Luna HSM (but was given CKR_MECHANISM_PARAM_INVALID
).
That version of HSM simply did not support OAEP with SHA-256 and firmware upgrade was needed. After firmware upgrade it worked without any problems. Check if your device supports this variant.
Your code seems ok, I used (in java):
QUESTION
I am using latest AWS cloud HSM and there PKCS vendor libraries with PKCS11Interop c# library.
Trying to simulate there sample code for CKM.CKM_RSA_AES_KEY_WRAP from AWS PKCS Samples
Gives below error while wrapping AES 256 Secret key.
Net.Pkcs11Interop.Common.Pkcs11Exception: 'Method C_WrapKey returned CKR_ARGUMENTS_BAD' at Net.Pkcs11Interop.HighLevelAPI80.Session.WrapKey(IMechanism mechanism, IObjectHandle wrappingKeyHandle, IObjectHandle keyHandle)
My sample code
...ANSWER
Answered 2020-May-12 at 08:45I was doing everything right, just had forgot to send initialised rsaParams with the call.
QUESTION
I am generating a RSA key pair with AWS cloud HSM with PKCS11Interop c# library on top of AWS vendor PKCS library. Wanted to export a public key from HSM with PKCS 11 getAttributeValue methods.
The response states that attributes cannot be read, I have marked all the attributes values correctly to be able to export a key, can somebody point out what I am doing wrong ?
My sample code
...ANSWER
Answered 2020-May-02 at 08:12RSA public key objects do not have CKA_VALUE
attribute. Instead, there are two attributes called CKA_MODULUS
and CKA_PUBLIC_EXPONENT
that make up the key value.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Pkcs11Interop
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page