Skip to content

Fix pkcs11 public key ID parsing with newer pkcs11-tool #551

@sarroutbi

Description

@sarroutbi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions