Importing a P-521 EC private key fails with CKR_ATTRIBUTE_VALUE_INVALID (0x13)
when the private key value contains a leading 00 byte. This is valid for P-521 keys since
the private key is 521 bits stored in 66 bytes, meaning some keys will naturally have a leading zero.
Steps to Reproduce
- Generate or obtain a P-521 private key whose value starts with a leading
00 byte
- Import using
pkcs11-tool:
pkcs11-tool --module libkryoptic_pkcs11.so \
--token-label "My token 1" \
--login --pin "test" \
--write-object private_key_ec_secp521r1.der \
--type privkey \
--id 06 --label "ECDSA-P521"
Expected Behavior
Key is imported successfully, as leading zero bytes are valid for P-521 private keys.
Actual Behavior
error: PKCS11 function C_CreateObject failed: rv = CKR_ATTRIBUTE_VALUE_INVALID (0x13)
Environment
- Kryoptic version: built from main branch
- OS: Ubuntu 24.04
- OpenSSL: 3.2.0
- pkcs11-tool: from OpenSC
Importing a P-521 EC private key fails with
CKR_ATTRIBUTE_VALUE_INVALID (0x13)when the private key value contains a leading
00byte. This is valid for P-521 keys sincethe private key is 521 bits stored in 66 bytes, meaning some keys will naturally have a leading zero.
Steps to Reproduce
00bytepkcs11-tool:Expected Behavior
Key is imported successfully, as leading zero bytes are valid for P-521 private keys.
Actual Behavior
Environment