OpenSC
OpenSC copied to clipboard
Minor Enhancement: Show slot numbers as hexadecimal and decimal, currently only hexadecimal is shown
Problem Description
OpenSC prints slot numbers as hexadecimal. Many applications only accept slot numbers as a decimal number, not hexadecimal. Manual conversion is required. If there is only one slot that is fine, but some applications require many slots. Manual conversion of slot numbers from hexadecimal to decimal is tedious when there are many slots.
Proposed Resolution
I searched the repo and found this line of code. I think this printf could be changed to print the slot number twice, in hexadecimal and decimal formats. The change seems trivial and would solve the problem.
- https://github.com/OpenSC/OpenSC/blob/8a6026abf528ce038321e8287c7c77bbfc883236/src/tools/pkcs11-tool.c#L1427
What I don't know is if there other places in the code where the same change is required or desirable too.
Steps to reproduce
Create slot(s) in SoftHSM2 v2.50 for Windows
"C:\SoftHSM2\bin\softhsm2-util.exe" --init-token --slot 0 --label Token-0 --pin 12345 --so-pin 9876543210
"C:\SoftHSM2\bin\softhsm2-util.exe" --init-token --slot 0 --label Token-1 --pin 23456 --so-pin 9876543210
"C:\SoftHSM2\bin\softhsm2-util.exe" --init-token --slot 0 --label Token-2 --pin 34567 --so-pin 9876543210
"C:\SoftHSM2\bin\softhsm2-util.exe" --init-token --slot 0 --label Token-3 --pin 45678 --so-pin 9876543210
"C:\SoftHSM2\bin\softhsm2-util.exe" --init-token --slot 0 --label Token-4 --pin 56789 --so-pin 9876543210
"C:\SoftHSM2\bin\softhsm2-util.exe" --init-token --slot 0 --label Token-5 --pin 67890 --so-pin 9876543210
List slots with OpenSC pkcs11-tool. Slot numbers are printed as hexadecimal. Decimal representation of slot number would be nice too.
"C:\Program Files\OpenSC Project\OpenSC\tools\pkcs11-tool" --module "C:\SoftHSM2\lib\softhsm2-x64.dll" --list-slots
Available slots:
Slot 0 (0x5a7d6e08): SoftHSM slot ID 0x5a7d6e08
token label : Token-0
token manufacturer : SoftHSM project
token model : SoftHSM v2
token flags : login required, rng, token initialized, PIN initialized, other flags=0x20
hardware version : 2.5
firmware version : 2.5
serial num : 947ea9855a7d6e08
pin min/max : 4/255
go ahead and make a pull request!
Closing this issue due to inactivity. Please re-open the ticket if more input is available.