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

Make key objects of carying type-specific methods #112

Closed
Jakuje opened this issue Nov 8, 2024 · 0 comments · Fixed by #116
Closed

Make key objects of carying type-specific methods #112

Jakuje opened this issue Nov 8, 2024 · 0 comments · Fixed by #116

Comments

@Jakuje
Copy link
Contributor

Jakuje commented Nov 8, 2024

Until #111, every key type had 1-n mapping to one or more mechanisms, which could encapsulate all operations on the given key type.

The #111 introduced EC_MONTGOMERY keys, that share the ECDH mechanism with the standard EC(DSA) key objects. The ECDH Operation would be more readable, if we could convert the key object to pkey and ask the object itself for the output length, instead of calling the key specific functions from different modules.

          Instead of hardcoding this here I think we should dynamically check at run time (by looking at the mechanisms available perhaps during registration) whether montgomery curves are available.

These functions should probably be exported by the relative mechanism and the mechanism should be sourced via the key type.

We may need to add a new trait to key objects that can be used to extract this info in a more abstract way.
Ie key.get_key_len() or key.get_field_len() or key.get_modulo_len() or some such.

The trait can return Err(CKR_KEY_TYPE_INCONSISTENT)? in the default implementation and only keys that can return a reasonable value will implement this.

If you think it is too much for this PR pleae file an issue and we can make a follow-up later.

Originally posted by @simo5 in #111 (comment)

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 a pull request may close this issue.

1 participant