Merged
Conversation
When using a HSM that supports allocating on slot zero, we fail to allow its use because we expect a non-zero slot value. This violates PKCS#11, which says: > A priori, any value of CK_SLOT_ID can be a valid slot identifier—in > particular, a system may have a slot identified by the value 0. It > need not have such a slot, however. Because of the type def: > ``` > typedef CK_ULONG CK_SLOT_ID; > ``` we cannot use -1 as a valid number, so we have to convert slot to be a pointer type to know whether or not it has been set. See also: http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/csprd01/pkcs11-base-v2.40-csprd01.html#_Toc72656028 Thanks to gris-gris for reporting this on Matrix. Signed-off-by: Alexander Scheel <ascheel@gitlab.com>
tomek-securosys
added a commit
to securosys-com/go-kms-wrapping
that referenced
this pull request
Oct 28, 2025
When using a HSM that supports allocating on slot zero, we fail to allow its use because we expect a non-zero slot value. This violates PKCS#11, which says: > A priori, any value of CK_SLOT_ID can be a valid slot identifier—in > particular, a system may have a slot identified by the value 0. It > need not have such a slot, however. Because of the type def: > ``` > typedef CK_ULONG CK_SLOT_ID; > ``` we cannot use -1 as a valid number, so we have to convert slot to be a pointer type to know whether or not it has been set. See also: http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/csprd01/pkcs11-base-v2.40-csprd01.html#_Toc72656028 Thanks to gris-gris for reporting this on Matrix. Signed-off-by: Tomasz Madej <tomasz.madej@securosys.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using a HSM that supports allocating on slot zero, we fail to allow its use because we expect a non-zero slot value. This violates PKCS#11, which says:
Because of the type def:
we cannot use -1 as a valid number, so we have to convert slot to be a pointer type to know whether or not it has been set.
See also: http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/csprd01/pkcs11-base-v2.40-csprd01.html#_Toc72656028
Thanks to gris-gris for reporting this on Matrix.
cc: @glatigny