Skip to content

Support X25519 and X448 public key inspection - #102

Open
dangfan wants to merge 1 commit into
Mastercard:masterfrom
dangfan:fix-montgomery-public-keys
Open

Support X25519 and X448 public key inspection#102
dangfan wants to merge 1 commit into
Mastercard:masterfrom
dangfan:fix-montgomery-public-keys

Conversation

@dangfan

@dangfan dangfan commented Sep 5, 2026

Copy link
Copy Markdown

Summary

  • recognize CKK_EC_MONTGOMERY objects in p11ls and p11od
  • export and render X25519/X448 public keys through p11cat and p11more
  • accept RFC 8410 OIDs, PKCS#11 curve-name parameters, raw public values, and legacy DER OCTET STRING wrappers
  • add unit tests, mock integration coverage, and user documentation

Testing

  • make check TESTS="unit/test_ec integration/mock_montgomery.sh"
  • full test suite: 16 passed, 40 skipped because optional SoftHSM/NSS dependencies were unavailable, 0 failed
  • real-token smoke tests for p11ls, p11od, p11cat, and p11more; the exported SPKI parsed successfully with OpenSSL and preserved the raw CKA_EC_POINT bytes

Fixes #101

Recognize PKCS#11 v3 CKK_EC_MONTGOMERY objects in the listing and attribute-dump tools.

Export and render X25519 and X448 public keys from standard raw points or legacy DER-wrapped values, with unit and mock integration coverage.

Signed-off-by: Fan DANG <i@dang.fan>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Error propagation and mock mechanism-advertising inconsistencies must be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds X25519/X448 Montgomery public-key inspection, rendering, and RFC 8410 export support.

Changes:

  • Recognizes Montgomery key types and curve parameters.
  • Builds OpenSSL keys from raw or DER-wrapped public values.
  • Adds documentation, unit tests, and mock integration coverage.
File summaries
File Description
tests/unit/test_ec.c Tests parameter parsing and key construction.
tests/mock/mock_pkcs11.c Seeds mock Montgomery objects, but incorrectly advertises unsupported key-pair generation.
tests/Makefile.am Registers integration coverage.
tests/integration/mock_montgomery.sh Exercises inspection and export.
man/p11more.1.md Documents rendering support.
man/p11cat.1.md Documents export support.
lib/pkcs11_pkey.c Constructs X25519/X448 public keys.
lib/pkcs11_od.c Names the Montgomery key type.
lib/pkcs11_more.c Renders Montgomery keys, but missing attributes can still yield successful empty output.
lib/pkcs11_ls.c Identifies Montgomery keys.
lib/pkcs11_ec.c Decodes Montgomery curve parameters.
lib/pkcs11_cat.c Exports Montgomery keys, but missing attributes can still yield successful empty output.
include/pkcs11lib.h Declares Montgomery helper APIs.
docs/MANUAL.md Documents inspection and export.
CHANGELOG.md Records Montgomery support.
Review details
  • Files reviewed: 15/15 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/pkcs11_cat.c
Comment on lines +493 to +495
if(oecparams == NULL || oecpoint == NULL) {
fprintf(stderr, "Error: object missing attribute(s) CKA_EC_PARAMS and/or CKA_EC_POINT\n");
break;
Comment thread lib/pkcs11_more.c
Comment on lines +434 to +438
oecparams = pkcs11_get_attr_in_attrlist(attrs, CKA_EC_PARAMS);
oecpoint = pkcs11_get_attr_in_attrlist(attrs, CKA_EC_POINT);
if(oecparams == NULL || oecpoint == NULL) {
fprintf(stderr, "Error: object missing attribute(s) CKA_EC_PARAMS and/or CKA_EC_POINT\n");
break;
Comment thread tests/mock/mock_pkcs11.c
Comment on lines 883 to +884
CKM_EC_EDWARDS_KEY_PAIR_GEN, CKM_EDDSA,
CKM_EC_MONTGOMERY_KEY_PAIR_GEN,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CKK_EC_MONTGOMERY/X25519 support to object inspection and public-key export tools

2 participants