[KCC] implement destroy_key_pair FFI#634
Conversation
NilanjanDaw
left a comment
There was a problem hiding this comment.
Thank you for working on this. A few early comments as you refine the implementation further.
| /// Assumes `key_handle_ptr` is a valid pointer to 16 bytes. | ||
| #[unsafe(no_mangle)] | ||
| pub unsafe extern "C" fn key_manager_destroy_key(key_handle_ptr: *const u8) -> i32 { | ||
| let handle_bytes = slice::from_raw_parts(key_handle_ptr, 16); |
There was a problem hiding this comment.
This makes me a bit nervous, probably a good idea to add some checks to see if the key_handle_ptr is valid?
| } | ||
|
|
||
| pub fn destroy_key(&self, handle: KeyHandle) -> Result<(), Error> { | ||
| if self.binding_keys.destroy_key(handle).is_ok() { |
There was a problem hiding this comment.
I don't think this delete function will work. This assumes the the Binding and KEM keys will have unique UUIDs. But that is not the case, each Binding Key, KEM Key pair will share the same UUID. We can probably pass a reference to the key-registry (binding_keys or kem_keys) to lookup as a parameter.
| /// # Safety | ||
| /// Assumes `key_handle_ptr` is a valid pointer to 16 bytes. | ||
| #[unsafe(no_mangle)] | ||
| pub unsafe extern "C" fn key_manager_destroy_key(key_handle_ptr: *const u8) -> i32 { |
There was a problem hiding this comment.
Lets have two separate FFIs, key_manager_destroy_kem_key and key_manager_destroy_binding_key to disambiguate the KeyRecord to delete the keys from.
No description provided.