Allow call with null pointer for handle key and template - #367
placintaalexandru wants to merge 1 commit into
Conversation
|
Hello! Would be nice if The intended use of the To make this cleaner, maybe we should add a new What do you think? |
| mechanism: &Mechanism, | ||
| base_key: ObjectHandle, | ||
| template: &[Attribute], | ||
| template: Option<&[Attribute]>, |
There was a problem hiding this comment.
I wonder if this could be:
| template: Option<&[Attribute]>, | |
| template: impl Into<Option<&[Attribute]>>, |
and then somewhere below:
let template = template.into();This would allow existing clients to use normal syntax and also allow passing None.
Example in the Rust Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=5e16ba050b6c7d7736801d3b552e3dbd
(it seems it requires explicit lifetime there)
|
Thank you for wiligness to support this, since it's something vendor dependent ^^' I was sharing the same idea @hug-dev , but since IDK if there would be any situation when the user would need both I was thinking maybe the following: // current one remains unchanged
pub fn derive_key(...) { ... }
#[cfg(feature = "SOME_MEANINGFUL_NAME")]
pub fn derive_key_vendor(...) { ... } |
Yes I think that is a reasonable approach! Or at least a good way to start until more of those appear and we see a better way to do it. |
Some calls to Thales Luna HSMs allows the following call of
C_DeriveKey:One example is when trying to do bip32 derivation using
CKM_BIP32_CHILD_DERIVECK_BIP32_CHILD_DERIVE_PARAMS. The call works as follows:pTemplateandphKeyare null pointersCK_BIP32_CHILD_DERIVE_PARAMS.hPublicKeyandCK_BIP32_CHILD_DERIVE_PARAMS.hPrivateKeyAt the moment this is not expressable by the
cryptokicrate so I was thinking it would be nice to allow it.I tested this against a Thales Luna Network HSM
If there is interest in this, I can work on making the tests pass as well, which is trivial
Downsides
derive_key0as value so the return type should be changed as well to better reflect user's intention