From 41a049e708a3ab9023cbc51f1e33654a95467bfe Mon Sep 17 00:00:00 2001 From: S-P Chan Date: Thu, 22 Feb 2024 07:55:38 +0800 Subject: [PATCH] EC keys: unconditionally fetch EC_POINT - vendor optimization (e.g. Thales Luna) to have CKA_EC_POINT in CKO_PRIVATE_KEY - avoids having to store the public key - for future optimization: skip find_associated_obj if EC key already has EC_POINT - libp11 equivalent: https://github.com/OpenSC/libp11/commit/281ccb3d60e77366bd6ece4b8a18d5ef28cb4f45 Signed-off-by: S-P Chan --- src/objects.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/objects.c b/src/objects.c index 6efa5eb2..96660f30 100644 --- a/src/objects.c +++ b/src/objects.c @@ -796,6 +796,12 @@ static CK_RV fetch_ec_key(P11PROV_CTX *ctx, P11PROV_SESSION *session, FA_SET_BUF_ALLOC(attrs, num, CKA_EC_PARAMS, true); if (key->class == CKO_PUBLIC_KEY) { FA_SET_BUF_ALLOC(attrs, num, CKA_EC_POINT, true); + } else { + /* known vendor optimization to avoid storing + * EC public key on HSM; can avoid + * find_associated_obj later + */ + FA_SET_BUF_ALLOC(attrs, num, CKA_EC_POINT, false); } FA_SET_BUF_ALLOC(attrs, num, CKA_ID, false); FA_SET_BUF_ALLOC(attrs, num, CKA_LABEL, false);