Skip to content

'Function::GenerateKeyPair': FunctionFailed with Nitrokey NetHSM v2.0.0 PKCS#11 lib #14

@and0x000

Description

@and0x000

I'm tinkering with the nitrokey/nethsm docker container and their .so PKCS#11 lib (v2.0.0) in combination with cascade using the cascade Debian packages from the NLNetLabs mirror.
Package versions are

  • kmip2pkcs11 -> 0.1.0~alpha-1bookworm
  • cascade -> 0.1.0~alpha4-1bookworm

I added the hsm to the cascad policy (cascade hsm add) and verified connectivity of the .so with pkcs11-tool.

However, when trying to add a zone (cascade zone add), I get these error messages:

2025-11-20T14:28:04.848016Z ERROR cascade: Error: Failed to add zone: Zone registration failed: Keyset command '/usr/libexec/cascade/cascade-dnst keyset -c /var/lib/cascade/keys/test.zone.cfg init' returned non-zero exit code: exit status: 1 [
  stdout=,
  stderr=
    [/usr/libexec/cascade/cascade-dnst] ERROR: KMIP request failed: Internal error: Missing response payload: Server error: Operation CreateKeyPair failed: Failed to create key pair: Relay failed to invoke PKCS#11 function 'Function::GenerateKeyPair': FunctionFailed
    [/usr/libexec/cascade/cascade-dnst] ERROR: KMIP key generation failed: a problem occurred while communicating with the KMIP server: Internal error: Missing response payload: Server error: Operation CreateKeyPair failed: Failed to create key pair: Relay failed to invoke PKCS#11 function 'Function::GenerateKeyPair': FunctionFailed
]

Logs from the relevant section (log level trace):

[...]
Nov 20 14:28:04 cascade-test /usr/bin/kmip2pkcs11[2806231]: C_FindObjectsInit() template: Some(CkRawAttrTemplate { ptr: 0x7f48500060c0, count: 1 })
Nov 20 14:28:04 cascade-test /usr/bin/kmip2pkcs11[2806231]: attr 258: Some([165, 181, 252, 142, 21, 207, 56, 246, 45, 144, 11, 229, 94, 108, 87, 179, 56, 90, 128, 188])
Nov 20 14:28:04 cascade-test /usr/bin/kmip2pkcs11[2806231]: ID [165, 181, 252, 142, 21, 207, 56, 246, 45, 144, 11, 229, 94, 108, 87, 179, 56, 90, 128, 188] is invalid: not a UTF-8 string
Nov 20 14:28:04 cascade-test /usr/bin/kmip2pkcs11[2806231]: Invalid ID in key requirements
[...]
Nov 20 14:28:04 cascade-test /usr/bin/kmip2pkcs11[2806231]: ID [165, 181, 252, 142, 21, 207, 56, 246, 45, 144, 11, 229, 94, 108, 87, 179, 56, 90, 128, 188] is invalid: not a UTF-8 string
Nov 20 14:28:04 cascade-test /usr/bin/kmip2pkcs11[2806231]: C_GenerateKeyPair() failed to generate key: InvalidAttribute(258)
Nov 20 14:28:04 cascade-test /usr/bin/kmip2pkcs11[2806231]: C_GenerateKeyPair failed with error FunctionFailed
[...]

The passed array translates to various non-printable characters in most all the encodings I tried.

Best correlation in documentation for the error message that I found was NetHSM limitting the key IDs to A-Z, a-z and 0-9. But I have no clue if this is the root cause, a too strict limitation of NetHSM, a incorrect use of PKCS#11 by cascade/kmip2pkcs11 or if that's the right correlation at all.

Please let me know if this is the wrong spot for this error report ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions