Fix pkcs11 public key ID parsing with newer pkcs11-tool
Newer versions of pkcs11-tool changed their -O output to show IDs as
3 (0x03) instead of just 03. The existing parsing in clevis-encrypt-pkcs11
used tr -d ' ' which stripped spaces but left the parenthetical annotation,
producing an invalid ID like 3(0x03). This caused the error:
Invalid ID "3(0x03)"
Unable to obtain a public key from PKCS#11 device
Fix
Replace tr -d ' ' with awk '{print $1}' to extract only the actual ID
value, handling both the old format (ID: 03) and the new format
(ID: 3 (0x03)).
Files to change
src/pins/pkcs11/clevis-encrypt-pkcs11 — fix ID parsing pipeline
src/pins/pkcs11/tests/pkcs11-id-parsing — new unit test
src/pins/pkcs11/tests/meson.build — register the new test
Fix pkcs11 public key ID parsing with newer pkcs11-tool
Newer versions of
pkcs11-toolchanged their-Ooutput to show IDs as3 (0x03)instead of just03. The existing parsing inclevis-encrypt-pkcs11used
tr -d ' 'which stripped spaces but left the parenthetical annotation,producing an invalid ID like
3(0x03). This caused the error:Invalid ID "3(0x03)"
Unable to obtain a public key from PKCS#11 device
Fix
Replace
tr -d ' 'withawk '{print $1}'to extract only the actual IDvalue, handling both the old format (
ID: 03) and the new format(
ID: 3 (0x03)).Files to change
src/pins/pkcs11/clevis-encrypt-pkcs11— fix ID parsing pipelinesrc/pins/pkcs11/tests/pkcs11-id-parsing— new unit testsrc/pins/pkcs11/tests/meson.build— register the new test