Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable key location for TLS 1.3 ephemeral key #9741

Open
KloolK opened this issue Oct 30, 2024 · 0 comments
Open

Configurable key location for TLS 1.3 ephemeral key #9741

KloolK opened this issue Oct 30, 2024 · 0 comments

Comments

@KloolK
Copy link
Contributor

KloolK commented Oct 30, 2024

Suggested enhancement

The location of the key used for ECDHE during the TLS 1.3 Handshake (handshake->xxdh_psa_privkey) is currently hardcoded to PSA_KEY_LOCATION_LOCAL_STORAGE because it uses the default lifetime PSA_KEY_LIFETIME_VOLATILE:

key_attributes = psa_key_attributes_init();
psa_set_key_usage_flags(&key_attributes, PSA_KEY_USAGE_DERIVE);
psa_set_key_algorithm(&key_attributes, alg);
psa_set_key_type(&key_attributes, handshake->xxdh_psa_type);
psa_set_key_bits(&key_attributes, handshake->xxdh_psa_bits);
/* Generate ECDH/FFDH private key. */
status = psa_generate_key(&key_attributes,
&handshake->xxdh_psa_privkey);

#define PSA_KEY_ATTRIBUTES_INIT { PSA_KEY_ATTRIBUTES_MAYBE_SLOT_NUMBER \
PSA_KEY_TYPE_NONE, 0, \
PSA_KEY_LIFETIME_VOLATILE, \
PSA_KEY_POLICY_INIT, \
MBEDTLS_SVC_KEY_ID_INIT }
static inline struct psa_key_attributes_s psa_key_attributes_init(void)
{
const struct psa_key_attributes_s v = PSA_KEY_ATTRIBUTES_INIT;
return v;
}

This prevents using an opaque crypto driver for the generation step and subsequent computation of the public key. Using a transparent driver here is typically not an option with an actual HSM since they usually don't support exporting a generated private key.

One might consider performing only the public key computation part with the opaque driver, but this is not a general solution because some HSMs require both the private and public part in order to import an ECC key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants