Fix crash when closing sessions with vendor-specific user types#231
Conversation
|
Those failing tests seem to be related to an upstream change (#233). I pushed a change to master to disable the offending test when running against |
|
Thanks. I merged the change from |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #231 +/- ##
==========================================
+ Coverage 90.17% 91.40% +1.23%
==========================================
Files 15 15
Lines 2625 2677 +52
Branches 29 27 -2
==========================================
+ Hits 2367 2447 +80
+ Misses 255 228 -27
+ Partials 3 2 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Nice work. Thanks! |
|
Thank you for reviewing and merging this, @MatthiasValvekens! Do you happen to have a timeline for the next release? I would love to make use of the custom user support in my current project. |
|
No timeline as such, but I'd like to merge the ML-KEM changes before cutting the next release. This depends on an open PR in SoftHSMv2 getting reviewed/merged for CI purposes. If that doesn't happen soon I'll either disable the relevant tests on SoftHSMv2 temporarily (opencryptoki will then be our only ML-KEM CI target), or do a release without those changes. |
Fix #230
In the current version of this package, when using a custom user such as the Crypto User -- represented by value
0x80000001-- on Thales Luna HSM 7, we run into problems when closing a session because:Session.close()method callsSession.user_type(). (Both methods are defined inpkcs11/_pkcs11.pyx.)Session.user_type()then callsUserType().UserType(), defined inpkcs11/constants.py, crashes because the custom user value0x80000001does not matchNOBODY(999),SO(0), orUSER(1).This PR fixes the problem by avoiding the indirect call to
UserType()inSession.close(). It also updatesSession.user_type()to not crash if the user type is a custom user.