Rust wrapper: add mlkem module#9833
Conversation
|
retest this please (ERROR: wolfSSL » PRB-140-3-tests #8576 was deleted) |
| /// | ||
| /// # Parameters | ||
| /// | ||
| /// * `key_type`: Key type. One of [`MlKem::TYPE_512`], [`MlKem::TYPE_768`], |
There was a problem hiding this comment.
here, just like for the dilithium.rs, I think there should be a check for key_type.
either here or in generate_with_random_ex, making sure that is either 512, 768 or 1024.
| if ct.len() != expected_ct_size { | ||
| return Err(sys::wolfCrypt_ErrorCodes_BUFFER_E); | ||
| } | ||
| if ss.len() != Self::SHARED_SECRET_SIZE { |
There was a problem hiding this comment.
here maybe, for consistency, could they both get validated against a runtime query (like it's happening for ct.len()) or both against a rust constant.
so adding a shared_secret_size() for the ss check too or just a brief comment explaining why the constant is used directly.
| self.ws_key, | ||
| ss.as_mut_ptr(), | ||
| ct.as_ptr(), | ||
| ct.len() as u32, |
There was a problem hiding this comment.
maybe here (and other places too) I would consider a more idiomatic way of casting something like:
u32::try_from(ct.len()).map_err(|_| ...)? (I think this right way of typing this).
in practice this is just to prevent in case ct.len() is > than u32::MAAX, the cipher text for ml-kem I don't think it can be that big, but just for better practice a better casting would be better I think.
Description
Rust wrapper: add mlkem module
Testing
Unit tests
Checklist