Proposed API change: accept key material by reference#57
Proposed API change: accept key material by reference#57marlonbaeten wants to merge 1 commit intorozbb:mainfrom
Conversation
|
I would also be curious to know if this was a deliberate design decision, especially since in the |
|
Hi, thank you for this! I agree there is unnecessary cloning happening. IIRC the reason I made the API this way was purely convenience. I'm not super concerned with copying secret keys, since all of those types are zeroize-on-drop anyway. Right now the only reason I could see to modify the API is to avoid an unnecessary clone of a public key. Given that public keys in post-quantum KEMs can be up to 1.5kB, this is slightly nontrivial. Not clear though if this really matters. That said, the reasons against it are:
Do you have a strong opinion here? Does the current API impede a use case of yours? |
Thank you for this useful library!
I noticed while using the library that the interface forces the caller to transfer memory ownership of the key material to an instance of the operation mode enum (
OpModeS).Since the PSK is also part of this data structure, one cannot reuse the
OpModeS::AuthPskvalue for multiple sessions and is thus forced to clone the private / public key for each PSK /OpModeS::AuthPskinstance.The API can be changed to take a reference to the key material; see this PR as an example.
Would you consider such a change to the API? I could assist in updating examples and documentation.