Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wrapper/rust/wolfssl-wolfcrypt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fn generate_bindings() -> Result<()> {
.header("headers.h")
.clang_arg(format!("-I{}", wolfssl_base_dir()?))
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.use_core()
.generate()
.map_err(|_| io::Error::other("Failed to generate bindings"))?;

Expand Down
26 changes: 13 additions & 13 deletions wrapper/rust/wolfssl-wolfcrypt/src/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Encryption Standard (AES) functionality.
#![cfg(aes)]

use crate::sys;
use std::mem::{size_of_val, MaybeUninit};
use core::mem::{size_of_val, MaybeUninit};

#[cfg(aes_wc_block_size)]
pub const AES_BLOCK_SIZE: usize = sys::WC_AES_BLOCK_SIZE as usize;
Expand Down Expand Up @@ -88,7 +88,7 @@ impl CBC {
///
/// A Result which is Ok(CBC) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let cbc = CBC {ws_aes};
Ok(cbc)
Expand Down Expand Up @@ -292,7 +292,7 @@ impl CCM {
///
/// A Result which is Ok(CCM) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let ccm = CCM {ws_aes};
Ok(ccm)
Expand Down Expand Up @@ -487,7 +487,7 @@ impl CFB {
///
/// A Result which is Ok(CFB) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let cfb = CFB {ws_aes};
Ok(cfb)
Expand Down Expand Up @@ -794,7 +794,7 @@ impl CTR {
///
/// A Result which is Ok(CTR) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let ctr = CTR {ws_aes};
Ok(ctr)
Expand Down Expand Up @@ -1075,7 +1075,7 @@ impl ECB {
///
/// A Result which is Ok(ECB) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let ecb = ECB {ws_aes};
Ok(ecb)
Expand Down Expand Up @@ -1276,7 +1276,7 @@ impl GCM {
///
/// A Result which is Ok(GCM) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let gcm = GCM {ws_aes};
Ok(gcm)
Expand Down Expand Up @@ -1499,7 +1499,7 @@ impl GCMStream {
///
/// A Result which is Ok(GCMStream) on success or an Err containing the
/// wolfSSL library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let gcmstream = GCMStream {ws_aes};
Ok(gcmstream)
Expand Down Expand Up @@ -1751,7 +1751,7 @@ impl OFB {
///
/// A Result which is Ok(OFB) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_aes = new_ws_aes(heap, dev_id)?;
let ofb = OFB {ws_aes};
Ok(ofb)
Expand Down Expand Up @@ -1945,7 +1945,7 @@ impl XTS {
///
/// A Result which is Ok(XTS) on success or an Err containing the wolfSSL
/// library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_xtsaes = new_ws_xtsaes(heap, dev_id)?;
let xts = XTS {ws_xtsaes};
Ok(xts)
Expand Down Expand Up @@ -2307,7 +2307,7 @@ impl XTSStream {
///
/// A Result which is Ok(XTSStream) on success or an Err containing the
/// wolfSSL library return code on failure.
pub fn new_ex(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let ws_xtsaes = new_ws_xtsaes(heap, dev_id)?;
let ws_xtsaesstreamdata: MaybeUninit<sys::XtsAesStreamData> = MaybeUninit::uninit();
let ws_xtsaesstreamdata = unsafe { ws_xtsaesstreamdata.assume_init() };
Expand Down Expand Up @@ -2533,7 +2533,7 @@ impl Drop for XTSStream {
}
}

fn new_ws_aes(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<sys::Aes, i32> {
fn new_ws_aes(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<sys::Aes, i32> {
let heap = match heap {
Some(heap) => heap,
None => core::ptr::null_mut(),
Expand All @@ -2554,7 +2554,7 @@ fn new_ws_aes(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> R
}

#[cfg(any(aes_xts, aes_xts_stream))]
fn new_ws_xtsaes(heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<sys::XtsAes, i32> {
fn new_ws_xtsaes(heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<sys::XtsAes, i32> {
let heap = match heap {
Some(heap) => heap,
None => core::ptr::null_mut(),
Expand Down
2 changes: 1 addition & 1 deletion wrapper/rust/wolfssl-wolfcrypt/src/blake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ functionality.
#![cfg(any(blake2b, blake2s))]

use crate::sys;
use std::mem::MaybeUninit;
use core::mem::MaybeUninit;

/// Context for BLAKE2b computation.
#[cfg(blake2b)]
Expand Down
2 changes: 1 addition & 1 deletion wrapper/rust/wolfssl-wolfcrypt/src/chacha20_poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ChaCha20-Poly1305 functionality.
#![cfg(chacha20_poly1305)]

use crate::sys;
use std::mem::MaybeUninit;
use core::mem::MaybeUninit;

pub struct ChaCha20Poly1305 {
wc_ccp: sys::ChaChaPoly_Aead,
Expand Down
8 changes: 4 additions & 4 deletions wrapper/rust/wolfssl-wolfcrypt/src/cmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Message Authentication Code (CMAC) functionality.
#![cfg(cmac)]

use crate::sys;
use std::mem::MaybeUninit;
use core::mem::MaybeUninit;

/// The `CMAC` struct manages the lifecycle of a wolfSSL `Cmac` object.
///
Expand Down Expand Up @@ -133,7 +133,7 @@ impl CMAC {
/// ];
/// let mut cmac = CMAC::new_ex(&key, None, None).expect("Error with new_ex()");
/// ```
pub fn new_ex(key: &[u8], heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_ex(key: &[u8], heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let key_size = key.len() as u32;
let mut ws_cmac: MaybeUninit<sys::Cmac> = MaybeUninit::uninit();
let typ = sys::CmacType_WC_CMAC_AES as i32;
Expand Down Expand Up @@ -242,7 +242,7 @@ impl CMAC {
/// }
/// ```
#[cfg(aes)]
pub fn generate_ex(&mut self, key: &[u8], data: &[u8], dout: &mut [u8], heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<(), i32> {
pub fn generate_ex(&mut self, key: &[u8], data: &[u8], dout: &mut [u8], heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<(), i32> {
let key_size = key.len() as u32;
let data_size = data.len() as u32;
let mut dout_size = dout.len() as u32;
Expand Down Expand Up @@ -384,7 +384,7 @@ impl CMAC {
/// }
/// ```
#[cfg(aes)]
pub fn verify_ex(&mut self, key: &[u8], data: &[u8], check: &[u8], heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<bool, i32> {
pub fn verify_ex(&mut self, key: &[u8], data: &[u8], check: &[u8], heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<bool, i32> {
let key_size = key.len() as u32;
let data_size = data.len() as u32;
let check_size = check.len() as u32;
Expand Down
2 changes: 1 addition & 1 deletion wrapper/rust/wolfssl-wolfcrypt/src/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ functionality.
#[cfg(random)]
use crate::random::RNG;
use crate::sys;
use std::mem::MaybeUninit;
use core::mem::MaybeUninit;

pub struct Curve25519Key {
wc_key: sys::curve25519_key,
Expand Down
12 changes: 6 additions & 6 deletions wrapper/rust/wolfssl-wolfcrypt/src/dh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ wolfSSL `DhKey` object. It ensures proper initialization and deallocation.
use crate::sys;
#[cfg(random)]
use crate::random::RNG;
use std::mem::{MaybeUninit};
use core::mem::{MaybeUninit};

pub struct DH {
wc_dhkey: sys::DhKey,
Expand Down Expand Up @@ -218,7 +218,7 @@ impl DH {
/// }
/// ```
#[cfg(all(dh_keygen, random))]
pub fn generate_ex(rng: &mut RNG, modulus_size: i32, heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn generate_ex(rng: &mut RNG, modulus_size: i32, heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let mut wc_dhkey: MaybeUninit<sys::DhKey> = MaybeUninit::uninit();
let heap = match heap {
Some(heap) => heap,
Expand Down Expand Up @@ -345,7 +345,7 @@ impl DH {
/// let mut dh = DH::new_named_ex(DH::FFDHE_2048, None, None).expect("Error with new_named_ex()");
/// }
/// ```
pub fn new_named_ex(name: i32, heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_named_ex(name: i32, heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let mut wc_dhkey: MaybeUninit<sys::DhKey> = MaybeUninit::uninit();
let heap = match heap {
Some(heap) => heap,
Expand Down Expand Up @@ -555,7 +555,7 @@ impl DH {
/// let dh = DH::new_from_pg_ex(&p, &g, None, None).expect("Error with new_from_pg_ex()");
/// }
/// ```
pub fn new_from_pg_ex(p: &[u8], g: &[u8], heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_from_pg_ex(p: &[u8], g: &[u8], heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let p_size = p.len() as u32;
let g_size = g.len() as u32;
let mut wc_dhkey: MaybeUninit<sys::DhKey> = MaybeUninit::uninit();
Expand Down Expand Up @@ -783,7 +783,7 @@ impl DH {
/// let dh = DH::new_from_pgq_ex(&p, &g, &q, None, None).expect("Error with new_from_pgq_ex()");
/// }
/// ```
pub fn new_from_pgq_ex(p: &[u8], g: &[u8], q: &[u8], heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_from_pgq_ex(p: &[u8], g: &[u8], q: &[u8], heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let p_size = p.len() as u32;
let g_size = g.len() as u32;
let q_size = q.len() as u32;
Expand Down Expand Up @@ -1023,7 +1023,7 @@ impl DH {
/// }
/// ```
#[cfg(random)]
pub fn new_from_pgq_with_check_ex(p: &[u8], g: &[u8], q: &[u8], trusted: i32, rng: &mut RNG, heap: Option<*mut std::os::raw::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
pub fn new_from_pgq_with_check_ex(p: &[u8], g: &[u8], q: &[u8], trusted: i32, rng: &mut RNG, heap: Option<*mut core::ffi::c_void>, dev_id: Option<i32>) -> Result<Self, i32> {
let p_size = p.len() as u32;
let g_size = g.len() as u32;
let q_size = q.len() as u32;
Expand Down
Loading