You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bindings for the hkdf methods defined here are currently missing in the Rust SDK.
I've written the following bindings. Does this seem good and should I submit this as a pull request (for example in a separate file named 'hkdf.rs')?
use nanos_sdk::bindings::*;extern"C"{pubfncx_hkdf_extract(hash_id:cx_md_t,ikm:&[u8],ikm_len:u32,salt:&[u8],salt_len:u32,prk:&[u8]);pubfncx_hkdf_expand(hash_id:cx_md_t,prk:&[u8],prk_len:u32,info:&[u8],info_len:u32,okm:&[u8],okm_len:u32);}/// Wrapper for cx_hkdf_extract/// /// Extract entropy /// /// In: /// ikm: input key material (acting as data)/// salt: salt acting as a key/// prk: pseudorandom keypubfnhkdf_extract(ikm:&[u8],salt:&mut[u8],prk:&mut[u8]){unsafe{cx_hkdf_extract(CX_SHA256,
ikm.as_ptr(),
ikm.len()asu32,
salt.as_mut_ptr(),
salt.len()asu32,
prk.as_mut_ptr());}}/// Wrapper for cx_hkdf_expand/// /// Expand generated output of an already reasonably random input /// /// In: /// prk: pseudorandom key/// info: /// okm: output key materialpubfnhkdf_expand(prk:&[u8],info:&[u8],okm:&mut[u8]){unsafe{cx_hkdf_expand(CX_SHA256,
prk.as_ptr(),
prk.len()asu32,
info.as_mut_ptr(),
info.len()asu32,
okm.as_mut_ptr(),
okm.len()asu32);}}
The text was updated successfully, but these errors were encountered:
ndcroos
changed the title
Add support for hkdf functions.
Add support for cx_hkdf functions.
Sep 14, 2022
ndcroos
changed the title
Add support for cx_hkdf functions.
Add support for cx_hkdf functions
Sep 14, 2022
These bindings would be invalid however, as the extern C part should use only raw pointers, and use mut when necessary: salt: &[u8] should be alt: *mut u8 for example.
(read-only should be *const u8)
This "extern "C"" prototype could be generated automatically by adding libcxng/src/cx_hkdf.c to the list of compiled sources in the build.rs script, and libcxng/src/cx_hkdf.h to the bindgen headers
Bindings for the hkdf methods defined here are currently missing in the Rust SDK.
I've written the following bindings. Does this seem good and should I submit this as a pull request (for example in a separate file named 'hkdf.rs')?
The text was updated successfully, but these errors were encountered: