Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Slot ID masking #322

Closed
saividhya opened this issue May 22, 2017 · 5 comments
Closed

Issue with Slot ID masking #322

saividhya opened this issue May 22, 2017 · 5 comments

Comments

@saividhya
Copy link

In SlotManager, while inserting into slots map, the Token Serial is masked and inserted as Slot ID.
But when a lookup is done later, based on Slot ID (for eg:- in C_OpenSession), the Slot ID is not unmasked. Because of which "slotID is out of range error" is thrown

@bellgrim
Copy link
Contributor

It does not need to be unmasked when getting the slot. The masked token serial number will be used as the Slot ID.

Do you have more details on the error and how you are calling the functions?

@bellgrim
Copy link
Contributor

The masking is an internal mechanism in SoftHSM and should not be used by the calling application.

You should search for a slot in the slot list containing the token with a given label and/or serial number. Then use this slot id when calling C_OpenSession.

@saividhya
Copy link
Author

saividhya commented May 23, 2017

Consider the following scenario,

I'm initializing the slots map using C_Initialize.
Then I'm initializing a token with Slot ID 0 using C_InitToken(0,...)
Now after re-initializing(C_Initialize), if I want to get the Slot info using C_GetSlotInfo(0,...) , it throws "slotID is out of range error"

How to retrieve the Slot information for Slot ID 0?

And if we want to retrieve Slot information based on label, will the label be unique across all tokens? And how to retrieve Slot information using Label?

or if we want to retrieve it using token serial, from where can we get token serial for Slot ID 0 ?

Since I'm initializing a token at Slot ID 0, shouldn't I be able to retrieve it using Slot ID 0 ?

@rijswijk
Copy link
Contributor

rijswijk commented May 23, 2017 via email

@bellgrim
Copy link
Contributor

Here you have some code illustrating how you can find a token (slot id) based on its label or serial number. The serial number will be unique, but there can be multiple tokens with the same label (the label is given by the user when initializing the token).

https://github.com/opendnssec/SoftHSMv2/blob/develop/src/bin/common/findslot.cpp#L185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants