From 4fcb6ed6c4915bcae494245155e0b86f92b8b501 Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Fri, 4 Feb 2022 14:52:41 +0000 Subject: [PATCH 1/7] Bump bindgen for version 0.2.x of crate Signed-off-by: Ionut Mihalcea --- cryptoki-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptoki-sys/Cargo.toml b/cryptoki-sys/Cargo.toml index 5cb46347..12469ed1 100644 --- a/cryptoki-sys/Cargo.toml +++ b/cryptoki-sys/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/parallaxsecond/rust-cryptoki" documentation = "https://docs.rs/crate/cryptoki" [build-dependencies] -bindgen = { version = "0.57.0", optional = true } +bindgen = { version = "0.59.1", optional = true } target-lexicon = "0.12.0" [dependencies] From ac944450fd8a6a01a3934857d8376c2fa785e501 Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Tue, 8 Feb 2022 12:54:17 +0000 Subject: [PATCH 2/7] Add new bindings and regeneration script A new script is added to aid the regeneration of bindings whenever the bindgen version is changed, along with the bindings produced with bindgen v0.59.2. Signed-off-by: Ionut Mihalcea --- cryptoki-sys/regenerate_bindings.sh | 28 ++++ .../src/bindings/aarch64-unknown-linux-gnu.rs | 145 ++++++++++-------- .../src/bindings/arm-unknown-linux-gnueabi.rs | 143 +++++++++-------- .../src/bindings/i686-unknown-linux-gnu.rs | 96 +++++++++--- .../bindings/powerpc64-unknown-linux-gnu.rs | 96 +++++++++--- .../src/bindings/x86_64-unknown-linux-gnu.rs | 145 ++++++++++-------- 6 files changed, 416 insertions(+), 237 deletions(-) create mode 100755 cryptoki-sys/regenerate_bindings.sh diff --git a/cryptoki-sys/regenerate_bindings.sh b/cryptoki-sys/regenerate_bindings.sh new file mode 100755 index 00000000..872c88ca --- /dev/null +++ b/cryptoki-sys/regenerate_bindings.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright 2022 Contributors to the Parsec project. +# SPDX-License-Identifier: Apache-2.0 + +set -xeuf -o pipefail + +# x86_64-unknown-darwin is not included as the stable toolchain does not +# include `rust-std` as a components (see https://doc.rust-lang.org/nightly/rustc/platform-support.html) +targets=( aarch64-unknown-linux-gnu arm-unknown-linux-gnueabi i686-unknown-linux-gnu powerpc64-unknown-linux-gnu x86_64-unknown-linux-gnu ) + +grepcwe() { grep -c "$@" || test $? = 1; } + +for target in "${targets[@]}" +do + PREVIOUSLY_INSTALLED=`rustup target list | grepcwe "$target (installed)"` + + if [ "$PREVIOUSLY_INSTALLED" == "0" ]; then + rustup target install $target + fi + + cargo build --target $target --features generate-bindings + find ../target/$target/ -name pkcs11_bindings.rs | xargs -I '{}' cp '{}' src/bindings/$target.rs + + if [ "$PREVIOUSLY_INSTALLED" == "0" ]; then + rustup target remove $target + fi +done \ No newline at end of file diff --git a/cryptoki-sys/src/bindings/aarch64-unknown-linux-gnu.rs b/cryptoki-sys/src/bindings/aarch64-unknown-linux-gnu.rs index 8c47f3db..4264453a 100644 --- a/cryptoki-sys/src/bindings/aarch64-unknown-linux-gnu.rs +++ b/cryptoki-sys/src/bindings/aarch64-unknown-linux-gnu.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.56.0 */ +/* automatically generated by rust-bindgen 0.59.2 */ pub type CK_FLAGS = ::std::os::raw::c_ulong; #[repr(C)] @@ -115,7 +115,7 @@ fn bindgen_test_layout__CK_INFO() { pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; pub type CK_SLOT_ID = ::std::os::raw::c_ulong; #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct _CK_SLOT_INFO { pub slotDescription: [::std::os::raw::c_uchar; 64usize], pub manufacturerID: [::std::os::raw::c_uchar; 32usize], @@ -188,7 +188,11 @@ fn bindgen_test_layout__CK_SLOT_INFO() { } impl Default for _CK_SLOT_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -540,7 +544,11 @@ fn bindgen_test_layout__CK_ATTRIBUTE() { } impl Default for _CK_ATTRIBUTE { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -646,7 +654,11 @@ fn bindgen_test_layout__CK_MECHANISM() { } impl Default for _CK_MECHANISM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -752,7 +764,11 @@ fn bindgen_test_layout_CK_OTP_PARAM() { } impl Default for CK_OTP_PARAM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -796,7 +812,11 @@ fn bindgen_test_layout_CK_OTP_PARAMS() { } impl Default for CK_OTP_PARAMS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -840,7 +860,11 @@ fn bindgen_test_layout_CK_OTP_SIGNATURE_INFO() { } impl Default for CK_OTP_SIGNATURE_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RSA_PKCS_MGF_TYPE = ::std::os::raw::c_ulong; @@ -973,7 +997,11 @@ fn bindgen_test_layout_ck_rsa_pkcs_oaep_params() { } impl Default for ck_rsa_pkcs_oaep_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1100,7 +1128,11 @@ fn bindgen_test_layout_ck_gcm_params() { } impl Default for ck_gcm_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type ck_ec_kdf_t = ::std::os::raw::c_ulong; @@ -1186,7 +1218,11 @@ fn bindgen_test_layout_ck_ecdh1_derive_params() { } impl Default for ck_ecdh1_derive_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1234,7 +1270,11 @@ fn bindgen_test_layout_ck_key_derivation_string_data() { } impl Default for ck_key_derivation_string_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1295,7 +1335,11 @@ fn bindgen_test_layout_ck_des_cbc_encrypt_data_params() { } impl Default for ck_des_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1356,7 +1400,11 @@ fn bindgen_test_layout_ck_aes_cbc_encrypt_data_params() { } impl Default for ck_aes_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RV = ::std::os::raw::c_ulong; @@ -2770,56 +2818,15 @@ fn bindgen_test_layout__CK_C_INITIALIZE_ARGS() { } impl Default for _CK_C_INITIALIZE_ARGS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type size_t = ::std::os::raw::c_ulong; pub type wchar_t = ::std::os::raw::c_uint; -#[repr(C)] -#[repr(align(16))] -#[derive(Debug, Default, Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, - pub __bindgen_padding_0: u64, - pub __clang_max_align_nonce2: u128, -} -#[test] -fn bindgen_test_layout_max_align_t() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(max_align_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 16usize, - concat!("Alignment of ", stringify!(max_align_t)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce1 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce2 as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce2) - ) - ); -} pub type CK_BYTE = ::std::os::raw::c_uchar; pub type CK_CHAR = ::std::os::raw::c_uchar; pub type CK_UTF8CHAR = ::std::os::raw::c_uchar; @@ -2896,20 +2903,24 @@ impl Pkcs11 { where P: AsRef<::std::ffi::OsStr>, { - let __library = ::libloading::Library::new(path)?; - let C_GetFunctionList = __library - .get("C_GetFunctionList".as_bytes()) - .map(|sym| *sym); + let library = ::libloading::Library::new(path)?; + Self::from_library(library) + } + pub unsafe fn from_library(library: L) -> Result + where + L: Into<::libloading::Library>, + { + let __library = library.into(); + let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); Ok(Pkcs11 { __library, C_GetFunctionList, }) } pub unsafe fn C_GetFunctionList(&self, function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV { - let sym = self + (self .C_GetFunctionList .as_ref() - .expect("Expected function, got error."); - (sym)(function_list) + .expect("Expected function, got error."))(function_list) } } diff --git a/cryptoki-sys/src/bindings/arm-unknown-linux-gnueabi.rs b/cryptoki-sys/src/bindings/arm-unknown-linux-gnueabi.rs index e486d902..74afe82d 100644 --- a/cryptoki-sys/src/bindings/arm-unknown-linux-gnueabi.rs +++ b/cryptoki-sys/src/bindings/arm-unknown-linux-gnueabi.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.56.0 */ +/* automatically generated by rust-bindgen 0.59.2 */ pub type CK_FLAGS = ::std::os::raw::c_ulong; #[repr(C)] @@ -115,7 +115,7 @@ fn bindgen_test_layout__CK_INFO() { pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; pub type CK_SLOT_ID = ::std::os::raw::c_ulong; #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct _CK_SLOT_INFO { pub slotDescription: [::std::os::raw::c_uchar; 64usize], pub manufacturerID: [::std::os::raw::c_uchar; 32usize], @@ -188,7 +188,11 @@ fn bindgen_test_layout__CK_SLOT_INFO() { } impl Default for _CK_SLOT_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -540,7 +544,11 @@ fn bindgen_test_layout__CK_ATTRIBUTE() { } impl Default for _CK_ATTRIBUTE { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -646,7 +654,11 @@ fn bindgen_test_layout__CK_MECHANISM() { } impl Default for _CK_MECHANISM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -752,7 +764,11 @@ fn bindgen_test_layout_CK_OTP_PARAM() { } impl Default for CK_OTP_PARAM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -796,7 +812,11 @@ fn bindgen_test_layout_CK_OTP_PARAMS() { } impl Default for CK_OTP_PARAMS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -840,7 +860,11 @@ fn bindgen_test_layout_CK_OTP_SIGNATURE_INFO() { } impl Default for CK_OTP_SIGNATURE_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RSA_PKCS_MGF_TYPE = ::std::os::raw::c_ulong; @@ -973,7 +997,11 @@ fn bindgen_test_layout_ck_rsa_pkcs_oaep_params() { } impl Default for ck_rsa_pkcs_oaep_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1100,7 +1128,11 @@ fn bindgen_test_layout_ck_gcm_params() { } impl Default for ck_gcm_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type ck_ec_kdf_t = ::std::os::raw::c_ulong; @@ -1186,7 +1218,11 @@ fn bindgen_test_layout_ck_ecdh1_derive_params() { } impl Default for ck_ecdh1_derive_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1234,7 +1270,11 @@ fn bindgen_test_layout_ck_key_derivation_string_data() { } impl Default for ck_key_derivation_string_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1295,7 +1335,11 @@ fn bindgen_test_layout_ck_des_cbc_encrypt_data_params() { } impl Default for ck_des_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1356,7 +1400,11 @@ fn bindgen_test_layout_ck_aes_cbc_encrypt_data_params() { } impl Default for ck_aes_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RV = ::std::os::raw::c_ulong; @@ -2770,54 +2818,15 @@ fn bindgen_test_layout__CK_C_INITIALIZE_ARGS() { } impl Default for _CK_C_INITIALIZE_ARGS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type size_t = ::std::os::raw::c_uint; pub type wchar_t = ::std::os::raw::c_uint; -#[repr(C)] -#[derive(Debug, Default, Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, - pub __clang_max_align_nonce2: f64, -} -#[test] -fn bindgen_test_layout_max_align_t() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(max_align_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(max_align_t)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce1 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce2 as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce2) - ) - ); -} pub type CK_BYTE = ::std::os::raw::c_uchar; pub type CK_CHAR = ::std::os::raw::c_uchar; pub type CK_UTF8CHAR = ::std::os::raw::c_uchar; @@ -2894,20 +2903,24 @@ impl Pkcs11 { where P: AsRef<::std::ffi::OsStr>, { - let __library = ::libloading::Library::new(path)?; - let C_GetFunctionList = __library - .get("C_GetFunctionList".as_bytes()) - .map(|sym| *sym); + let library = ::libloading::Library::new(path)?; + Self::from_library(library) + } + pub unsafe fn from_library(library: L) -> Result + where + L: Into<::libloading::Library>, + { + let __library = library.into(); + let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); Ok(Pkcs11 { __library, C_GetFunctionList, }) } pub unsafe fn C_GetFunctionList(&self, function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV { - let sym = self + (self .C_GetFunctionList .as_ref() - .expect("Expected function, got error."); - (sym)(function_list) + .expect("Expected function, got error."))(function_list) } } diff --git a/cryptoki-sys/src/bindings/i686-unknown-linux-gnu.rs b/cryptoki-sys/src/bindings/i686-unknown-linux-gnu.rs index dda2e096..29b5186b 100644 --- a/cryptoki-sys/src/bindings/i686-unknown-linux-gnu.rs +++ b/cryptoki-sys/src/bindings/i686-unknown-linux-gnu.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.57.0 */ +/* automatically generated by rust-bindgen 0.59.2 */ pub type CK_FLAGS = ::std::os::raw::c_ulong; #[repr(C)] @@ -115,7 +115,7 @@ fn bindgen_test_layout__CK_INFO() { pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; pub type CK_SLOT_ID = ::std::os::raw::c_ulong; #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct _CK_SLOT_INFO { pub slotDescription: [::std::os::raw::c_uchar; 64usize], pub manufacturerID: [::std::os::raw::c_uchar; 32usize], @@ -188,7 +188,11 @@ fn bindgen_test_layout__CK_SLOT_INFO() { } impl Default for _CK_SLOT_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -540,7 +544,11 @@ fn bindgen_test_layout__CK_ATTRIBUTE() { } impl Default for _CK_ATTRIBUTE { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -646,7 +654,11 @@ fn bindgen_test_layout__CK_MECHANISM() { } impl Default for _CK_MECHANISM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -752,7 +764,11 @@ fn bindgen_test_layout_CK_OTP_PARAM() { } impl Default for CK_OTP_PARAM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -796,7 +812,11 @@ fn bindgen_test_layout_CK_OTP_PARAMS() { } impl Default for CK_OTP_PARAMS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -840,7 +860,11 @@ fn bindgen_test_layout_CK_OTP_SIGNATURE_INFO() { } impl Default for CK_OTP_SIGNATURE_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RSA_PKCS_MGF_TYPE = ::std::os::raw::c_ulong; @@ -973,7 +997,11 @@ fn bindgen_test_layout_ck_rsa_pkcs_oaep_params() { } impl Default for ck_rsa_pkcs_oaep_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1100,7 +1128,11 @@ fn bindgen_test_layout_ck_gcm_params() { } impl Default for ck_gcm_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type ck_ec_kdf_t = ::std::os::raw::c_ulong; @@ -1186,7 +1218,11 @@ fn bindgen_test_layout_ck_ecdh1_derive_params() { } impl Default for ck_ecdh1_derive_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1234,7 +1270,11 @@ fn bindgen_test_layout_ck_key_derivation_string_data() { } impl Default for ck_key_derivation_string_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1295,7 +1335,11 @@ fn bindgen_test_layout_ck_des_cbc_encrypt_data_params() { } impl Default for ck_des_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1356,7 +1400,11 @@ fn bindgen_test_layout_ck_aes_cbc_encrypt_data_params() { } impl Default for ck_aes_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RV = ::std::os::raw::c_ulong; @@ -2770,7 +2818,11 @@ fn bindgen_test_layout__CK_C_INITIALIZE_ARGS() { } impl Default for _CK_C_INITIALIZE_ARGS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type size_t = ::std::os::raw::c_uint; @@ -2851,7 +2903,14 @@ impl Pkcs11 { where P: AsRef<::std::ffi::OsStr>, { - let __library = ::libloading::Library::new(path)?; + let library = ::libloading::Library::new(path)?; + Self::from_library(library) + } + pub unsafe fn from_library(library: L) -> Result + where + L: Into<::libloading::Library>, + { + let __library = library.into(); let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); Ok(Pkcs11 { __library, @@ -2859,10 +2918,9 @@ impl Pkcs11 { }) } pub unsafe fn C_GetFunctionList(&self, function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV { - let sym = self + (self .C_GetFunctionList .as_ref() - .expect("Expected function, got error."); - (sym)(function_list) + .expect("Expected function, got error."))(function_list) } } diff --git a/cryptoki-sys/src/bindings/powerpc64-unknown-linux-gnu.rs b/cryptoki-sys/src/bindings/powerpc64-unknown-linux-gnu.rs index 61aec305..e8699a8b 100644 --- a/cryptoki-sys/src/bindings/powerpc64-unknown-linux-gnu.rs +++ b/cryptoki-sys/src/bindings/powerpc64-unknown-linux-gnu.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.57.0 */ +/* automatically generated by rust-bindgen 0.59.2 */ pub type CK_FLAGS = ::std::os::raw::c_ulong; #[repr(C)] @@ -115,7 +115,7 @@ fn bindgen_test_layout__CK_INFO() { pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; pub type CK_SLOT_ID = ::std::os::raw::c_ulong; #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct _CK_SLOT_INFO { pub slotDescription: [::std::os::raw::c_uchar; 64usize], pub manufacturerID: [::std::os::raw::c_uchar; 32usize], @@ -188,7 +188,11 @@ fn bindgen_test_layout__CK_SLOT_INFO() { } impl Default for _CK_SLOT_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -540,7 +544,11 @@ fn bindgen_test_layout__CK_ATTRIBUTE() { } impl Default for _CK_ATTRIBUTE { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -646,7 +654,11 @@ fn bindgen_test_layout__CK_MECHANISM() { } impl Default for _CK_MECHANISM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -752,7 +764,11 @@ fn bindgen_test_layout_CK_OTP_PARAM() { } impl Default for CK_OTP_PARAM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -796,7 +812,11 @@ fn bindgen_test_layout_CK_OTP_PARAMS() { } impl Default for CK_OTP_PARAMS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -840,7 +860,11 @@ fn bindgen_test_layout_CK_OTP_SIGNATURE_INFO() { } impl Default for CK_OTP_SIGNATURE_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RSA_PKCS_MGF_TYPE = ::std::os::raw::c_ulong; @@ -973,7 +997,11 @@ fn bindgen_test_layout_ck_rsa_pkcs_oaep_params() { } impl Default for ck_rsa_pkcs_oaep_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1100,7 +1128,11 @@ fn bindgen_test_layout_ck_gcm_params() { } impl Default for ck_gcm_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type ck_ec_kdf_t = ::std::os::raw::c_ulong; @@ -1186,7 +1218,11 @@ fn bindgen_test_layout_ck_ecdh1_derive_params() { } impl Default for ck_ecdh1_derive_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1234,7 +1270,11 @@ fn bindgen_test_layout_ck_key_derivation_string_data() { } impl Default for ck_key_derivation_string_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1295,7 +1335,11 @@ fn bindgen_test_layout_ck_des_cbc_encrypt_data_params() { } impl Default for ck_des_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1356,7 +1400,11 @@ fn bindgen_test_layout_ck_aes_cbc_encrypt_data_params() { } impl Default for ck_aes_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RV = ::std::os::raw::c_ulong; @@ -2770,7 +2818,11 @@ fn bindgen_test_layout__CK_C_INITIALIZE_ARGS() { } impl Default for _CK_C_INITIALIZE_ARGS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type size_t = ::std::os::raw::c_ulong; @@ -2851,7 +2903,14 @@ impl Pkcs11 { where P: AsRef<::std::ffi::OsStr>, { - let __library = ::libloading::Library::new(path)?; + let library = ::libloading::Library::new(path)?; + Self::from_library(library) + } + pub unsafe fn from_library(library: L) -> Result + where + L: Into<::libloading::Library>, + { + let __library = library.into(); let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); Ok(Pkcs11 { __library, @@ -2859,10 +2918,9 @@ impl Pkcs11 { }) } pub unsafe fn C_GetFunctionList(&self, function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV { - let sym = self + (self .C_GetFunctionList .as_ref() - .expect("Expected function, got error."); - (sym)(function_list) + .expect("Expected function, got error."))(function_list) } } diff --git a/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs b/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs index 16599f42..e8699a8b 100644 --- a/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs +++ b/cryptoki-sys/src/bindings/x86_64-unknown-linux-gnu.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.56.0 */ +/* automatically generated by rust-bindgen 0.59.2 */ pub type CK_FLAGS = ::std::os::raw::c_ulong; #[repr(C)] @@ -115,7 +115,7 @@ fn bindgen_test_layout__CK_INFO() { pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; pub type CK_SLOT_ID = ::std::os::raw::c_ulong; #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct _CK_SLOT_INFO { pub slotDescription: [::std::os::raw::c_uchar; 64usize], pub manufacturerID: [::std::os::raw::c_uchar; 32usize], @@ -188,7 +188,11 @@ fn bindgen_test_layout__CK_SLOT_INFO() { } impl Default for _CK_SLOT_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -540,7 +544,11 @@ fn bindgen_test_layout__CK_ATTRIBUTE() { } impl Default for _CK_ATTRIBUTE { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -646,7 +654,11 @@ fn bindgen_test_layout__CK_MECHANISM() { } impl Default for _CK_MECHANISM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -752,7 +764,11 @@ fn bindgen_test_layout_CK_OTP_PARAM() { } impl Default for CK_OTP_PARAM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -796,7 +812,11 @@ fn bindgen_test_layout_CK_OTP_PARAMS() { } impl Default for CK_OTP_PARAMS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -840,7 +860,11 @@ fn bindgen_test_layout_CK_OTP_SIGNATURE_INFO() { } impl Default for CK_OTP_SIGNATURE_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RSA_PKCS_MGF_TYPE = ::std::os::raw::c_ulong; @@ -973,7 +997,11 @@ fn bindgen_test_layout_ck_rsa_pkcs_oaep_params() { } impl Default for ck_rsa_pkcs_oaep_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1100,7 +1128,11 @@ fn bindgen_test_layout_ck_gcm_params() { } impl Default for ck_gcm_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type ck_ec_kdf_t = ::std::os::raw::c_ulong; @@ -1186,7 +1218,11 @@ fn bindgen_test_layout_ck_ecdh1_derive_params() { } impl Default for ck_ecdh1_derive_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1234,7 +1270,11 @@ fn bindgen_test_layout_ck_key_derivation_string_data() { } impl Default for ck_key_derivation_string_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1295,7 +1335,11 @@ fn bindgen_test_layout_ck_des_cbc_encrypt_data_params() { } impl Default for ck_des_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1356,7 +1400,11 @@ fn bindgen_test_layout_ck_aes_cbc_encrypt_data_params() { } impl Default for ck_aes_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RV = ::std::os::raw::c_ulong; @@ -2770,56 +2818,15 @@ fn bindgen_test_layout__CK_C_INITIALIZE_ARGS() { } impl Default for _CK_C_INITIALIZE_ARGS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type size_t = ::std::os::raw::c_ulong; pub type wchar_t = ::std::os::raw::c_int; -#[repr(C)] -#[repr(align(16))] -#[derive(Debug, Default, Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, - pub __bindgen_padding_0: u64, - pub __clang_max_align_nonce2: u128, -} -#[test] -fn bindgen_test_layout_max_align_t() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(max_align_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 16usize, - concat!("Alignment of ", stringify!(max_align_t)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce1 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce2 as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce2) - ) - ); -} pub type CK_BYTE = ::std::os::raw::c_uchar; pub type CK_CHAR = ::std::os::raw::c_uchar; pub type CK_UTF8CHAR = ::std::os::raw::c_uchar; @@ -2896,20 +2903,24 @@ impl Pkcs11 { where P: AsRef<::std::ffi::OsStr>, { - let __library = ::libloading::Library::new(path)?; - let C_GetFunctionList = __library - .get("C_GetFunctionList".as_bytes()) - .map(|sym| *sym); + let library = ::libloading::Library::new(path)?; + Self::from_library(library) + } + pub unsafe fn from_library(library: L) -> Result + where + L: Into<::libloading::Library>, + { + let __library = library.into(); + let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); Ok(Pkcs11 { __library, C_GetFunctionList, }) } pub unsafe fn C_GetFunctionList(&self, function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV { - let sym = self + (self .C_GetFunctionList .as_ref() - .expect("Expected function, got error."); - (sym)(function_list) + .expect("Expected function, got error."))(function_list) } } From a4eb1d69b3ae57ceca49f87a9540588c84167e2c Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Wed, 9 Feb 2022 10:32:56 +0000 Subject: [PATCH 3/7] Fix script comment Signed-off-by: Ionut Mihalcea --- cryptoki-sys/regenerate_bindings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cryptoki-sys/regenerate_bindings.sh b/cryptoki-sys/regenerate_bindings.sh index 872c88ca..a2e2520b 100755 --- a/cryptoki-sys/regenerate_bindings.sh +++ b/cryptoki-sys/regenerate_bindings.sh @@ -5,8 +5,8 @@ set -xeuf -o pipefail -# x86_64-unknown-darwin is not included as the stable toolchain does not -# include `rust-std` as a components (see https://doc.rust-lang.org/nightly/rustc/platform-support.html) +# x86_64-unknown-darwin is included as a stable toolchain but does not +# include `rust-std` as a component (see https://doc.rust-lang.org/nightly/rustc/platform-support.html) targets=( aarch64-unknown-linux-gnu arm-unknown-linux-gnueabi i686-unknown-linux-gnu powerpc64-unknown-linux-gnu x86_64-unknown-linux-gnu ) grepcwe() { grep -c "$@" || test $? = 1; } From 3368715ff295f831b21d3d0aa28a701c7c1cd1e4 Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Wed, 9 Feb 2022 10:53:53 +0000 Subject: [PATCH 4/7] Update script and MacOS bindings Update the script to make it shell-compliant. Update the MacOS Darwin bindings, and change bindings OS name from `unknown` to `apple`. Add this target to the list supported by the script. Update the `build.rs` file to use correct `bindgen` methods. Co-authored-by: Ionut Mihalcea Co-authored-by: Anton Antonov Signed-off-by: Ionut Mihalcea --- cryptoki-sys/build.rs | 6 +- cryptoki-sys/regenerate_bindings.sh | 17 ++-- ...known-darwin.rs => x86_64-apple-darwin.rs} | 96 +++++++++++++++---- cryptoki-sys/src/lib.rs | 2 +- 4 files changed, 88 insertions(+), 33 deletions(-) rename cryptoki-sys/src/bindings/{x86_64-unknown-darwin.rs => x86_64-apple-darwin.rs} (96%) diff --git a/cryptoki-sys/build.rs b/cryptoki-sys/build.rs index 6de9a520..da76dbae 100644 --- a/cryptoki-sys/build.rs +++ b/cryptoki-sys/build.rs @@ -37,12 +37,12 @@ fn generate_bindings() { // The PKCS11 library works in a slightly different way to most shared libraries. We have // to call `C_GetFunctionList`, which returns a list of pointers to the _actual_ library // functions. This is the only function we need to create a binding for. - .whitelist_function("C_GetFunctionList") + .allowlist_function("C_GetFunctionList") // This is needed because no types will be generated if `whitelist_function` is used. // Unsure if this is a bug. - .whitelist_type("*") + .allowlist_type("*") // See this issue: https://github.com/parallaxsecond/rust-cryptoki/issues/12 - .blacklist_type("max_align_t") + .blocklist_type("max_align_t") // Derive the `Debug` trait for the generated structs where possible. .derive_debug(true) // Derive the `Default` trait for the generated structs where possible. diff --git a/cryptoki-sys/regenerate_bindings.sh b/cryptoki-sys/regenerate_bindings.sh index a2e2520b..218b12dc 100755 --- a/cryptoki-sys/regenerate_bindings.sh +++ b/cryptoki-sys/regenerate_bindings.sh @@ -5,24 +5,21 @@ set -xeuf -o pipefail -# x86_64-unknown-darwin is included as a stable toolchain but does not -# include `rust-std` as a component (see https://doc.rust-lang.org/nightly/rustc/platform-support.html) -targets=( aarch64-unknown-linux-gnu arm-unknown-linux-gnueabi i686-unknown-linux-gnu powerpc64-unknown-linux-gnu x86_64-unknown-linux-gnu ) +targets="aarch64-unknown-linux-gnu arm-unknown-linux-gnueabi i686-unknown-linux-gnu powerpc64-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-apple-darwin" +TARGET_INSTALLED= -grepcwe() { grep -c "$@" || test $? = 1; } +for target in $targets; do -for target in "${targets[@]}" -do - PREVIOUSLY_INSTALLED=`rustup target list | grepcwe "$target (installed)"` - - if [ "$PREVIOUSLY_INSTALLED" == "0" ]; then + # Check if the target is already installed + if ! rustup target list | grep -q "$target (installed)"; then rustup target install $target + TARGET_INSTALLED="$target" fi cargo build --target $target --features generate-bindings find ../target/$target/ -name pkcs11_bindings.rs | xargs -I '{}' cp '{}' src/bindings/$target.rs - if [ "$PREVIOUSLY_INSTALLED" == "0" ]; then + if [ "$TARGET_INSTALLED" == "$target" ]; then rustup target remove $target fi done \ No newline at end of file diff --git a/cryptoki-sys/src/bindings/x86_64-unknown-darwin.rs b/cryptoki-sys/src/bindings/x86_64-apple-darwin.rs similarity index 96% rename from cryptoki-sys/src/bindings/x86_64-unknown-darwin.rs rename to cryptoki-sys/src/bindings/x86_64-apple-darwin.rs index 61aec305..e8699a8b 100644 --- a/cryptoki-sys/src/bindings/x86_64-unknown-darwin.rs +++ b/cryptoki-sys/src/bindings/x86_64-apple-darwin.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.57.0 */ +/* automatically generated by rust-bindgen 0.59.2 */ pub type CK_FLAGS = ::std::os::raw::c_ulong; #[repr(C)] @@ -115,7 +115,7 @@ fn bindgen_test_layout__CK_INFO() { pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; pub type CK_SLOT_ID = ::std::os::raw::c_ulong; #[repr(C)] -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub struct _CK_SLOT_INFO { pub slotDescription: [::std::os::raw::c_uchar; 64usize], pub manufacturerID: [::std::os::raw::c_uchar; 32usize], @@ -188,7 +188,11 @@ fn bindgen_test_layout__CK_SLOT_INFO() { } impl Default for _CK_SLOT_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -540,7 +544,11 @@ fn bindgen_test_layout__CK_ATTRIBUTE() { } impl Default for _CK_ATTRIBUTE { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -646,7 +654,11 @@ fn bindgen_test_layout__CK_MECHANISM() { } impl Default for _CK_MECHANISM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -752,7 +764,11 @@ fn bindgen_test_layout_CK_OTP_PARAM() { } impl Default for CK_OTP_PARAM { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -796,7 +812,11 @@ fn bindgen_test_layout_CK_OTP_PARAMS() { } impl Default for CK_OTP_PARAMS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -840,7 +860,11 @@ fn bindgen_test_layout_CK_OTP_SIGNATURE_INFO() { } impl Default for CK_OTP_SIGNATURE_INFO { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RSA_PKCS_MGF_TYPE = ::std::os::raw::c_ulong; @@ -973,7 +997,11 @@ fn bindgen_test_layout_ck_rsa_pkcs_oaep_params() { } impl Default for ck_rsa_pkcs_oaep_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1100,7 +1128,11 @@ fn bindgen_test_layout_ck_gcm_params() { } impl Default for ck_gcm_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type ck_ec_kdf_t = ::std::os::raw::c_ulong; @@ -1186,7 +1218,11 @@ fn bindgen_test_layout_ck_ecdh1_derive_params() { } impl Default for ck_ecdh1_derive_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1234,7 +1270,11 @@ fn bindgen_test_layout_ck_key_derivation_string_data() { } impl Default for ck_key_derivation_string_data { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1295,7 +1335,11 @@ fn bindgen_test_layout_ck_des_cbc_encrypt_data_params() { } impl Default for ck_des_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } #[repr(C)] @@ -1356,7 +1400,11 @@ fn bindgen_test_layout_ck_aes_cbc_encrypt_data_params() { } impl Default for ck_aes_cbc_encrypt_data_params { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type CK_RV = ::std::os::raw::c_ulong; @@ -2770,7 +2818,11 @@ fn bindgen_test_layout__CK_C_INITIALIZE_ARGS() { } impl Default for _CK_C_INITIALIZE_ARGS { fn default() -> Self { - unsafe { ::std::mem::zeroed() } + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } } } pub type size_t = ::std::os::raw::c_ulong; @@ -2851,7 +2903,14 @@ impl Pkcs11 { where P: AsRef<::std::ffi::OsStr>, { - let __library = ::libloading::Library::new(path)?; + let library = ::libloading::Library::new(path)?; + Self::from_library(library) + } + pub unsafe fn from_library(library: L) -> Result + where + L: Into<::libloading::Library>, + { + let __library = library.into(); let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); Ok(Pkcs11 { __library, @@ -2859,10 +2918,9 @@ impl Pkcs11 { }) } pub unsafe fn C_GetFunctionList(&self, function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV { - let sym = self + (self .C_GetFunctionList .as_ref() - .expect("Expected function, got error."); - (sym)(function_list) + .expect("Expected function, got error."))(function_list) } } diff --git a/cryptoki-sys/src/lib.rs b/cryptoki-sys/src/lib.rs index 8d506ce2..380996ef 100644 --- a/cryptoki-sys/src/lib.rs +++ b/cryptoki-sys/src/lib.rs @@ -67,7 +67,7 @@ include!(concat!( ))] include!(concat!( env!("CARGO_MANIFEST_DIR"), - "/src/bindings/x86_64-unknown-darwin.rs" + "/src/bindings/x86_64-apple-darwin.rs" )); // If the "generate-bindings" feature is on, use the generated bindings. From 40b609bd5f7aab5ac2bf2af5b7d6e8ec351a8a7c Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Wed, 9 Feb 2022 11:14:37 +0000 Subject: [PATCH 5/7] Add aarch64-apple-darwin target bindings Signed-off-by: Ionut Mihalcea --- cryptoki-sys/build.rs | 1 + cryptoki-sys/regenerate_bindings.sh | 2 +- .../src/bindings/aarch64-apple-darwin.rs | 2926 +++++++++++++++++ cryptoki-sys/src/lib.rs | 10 + 4 files changed, 2938 insertions(+), 1 deletion(-) create mode 100644 cryptoki-sys/src/bindings/aarch64-apple-darwin.rs diff --git a/cryptoki-sys/build.rs b/cryptoki-sys/build.rs index da76dbae..decee24b 100644 --- a/cryptoki-sys/build.rs +++ b/cryptoki-sys/build.rs @@ -21,6 +21,7 @@ fn main() { (Architecture::Powerpc64, OperatingSystem::Linux) => {} (Architecture::Powerpc64le, OperatingSystem::Linux) => {} (Architecture::X86_64, OperatingSystem::Darwin) => {} + (Architecture::Aarch64(_), OperatingSystem::Darwin) => {} (arch, os) => { panic!("Compilation target (architecture, OS) tuple ({}, {}) is not part of the supported tuples. Please compile with the \"generate-bindings\" feature or add support for your platform :)", arch, os); } diff --git a/cryptoki-sys/regenerate_bindings.sh b/cryptoki-sys/regenerate_bindings.sh index 218b12dc..9e9e6138 100755 --- a/cryptoki-sys/regenerate_bindings.sh +++ b/cryptoki-sys/regenerate_bindings.sh @@ -5,7 +5,7 @@ set -xeuf -o pipefail -targets="aarch64-unknown-linux-gnu arm-unknown-linux-gnueabi i686-unknown-linux-gnu powerpc64-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-apple-darwin" +targets="aarch64-unknown-linux-gnu arm-unknown-linux-gnueabi i686-unknown-linux-gnu powerpc64-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin" TARGET_INSTALLED= for target in $targets; do diff --git a/cryptoki-sys/src/bindings/aarch64-apple-darwin.rs b/cryptoki-sys/src/bindings/aarch64-apple-darwin.rs new file mode 100644 index 00000000..e8699a8b --- /dev/null +++ b/cryptoki-sys/src/bindings/aarch64-apple-darwin.rs @@ -0,0 +1,2926 @@ +/* automatically generated by rust-bindgen 0.59.2 */ + +pub type CK_FLAGS = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _CK_VERSION { + pub major: ::std::os::raw::c_uchar, + pub minor: ::std::os::raw::c_uchar, +} +#[test] +fn bindgen_test_layout__CK_VERSION() { + assert_eq!( + ::std::mem::size_of::<_CK_VERSION>(), + 2usize, + concat!("Size of: ", stringify!(_CK_VERSION)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_VERSION>(), + 1usize, + concat!("Alignment of ", stringify!(_CK_VERSION)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_VERSION>())).major as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_VERSION), + "::", + stringify!(major) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_VERSION>())).minor as *const _ as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(_CK_VERSION), + "::", + stringify!(minor) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _CK_INFO { + pub cryptokiVersion: _CK_VERSION, + pub manufacturerID: [::std::os::raw::c_uchar; 32usize], + pub flags: CK_FLAGS, + pub libraryDescription: [::std::os::raw::c_uchar; 32usize], + pub libraryVersion: _CK_VERSION, +} +#[test] +fn bindgen_test_layout__CK_INFO() { + assert_eq!( + ::std::mem::size_of::<_CK_INFO>(), + 88usize, + concat!("Size of: ", stringify!(_CK_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_INFO>())).cryptokiVersion as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_INFO), + "::", + stringify!(cryptokiVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_INFO>())).manufacturerID as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(_CK_INFO), + "::", + stringify!(manufacturerID) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_INFO>())).flags as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_CK_INFO), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_INFO>())).libraryDescription as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_CK_INFO), + "::", + stringify!(libraryDescription) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_INFO>())).libraryVersion as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_CK_INFO), + "::", + stringify!(libraryVersion) + ) + ); +} +pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; +pub type CK_SLOT_ID = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _CK_SLOT_INFO { + pub slotDescription: [::std::os::raw::c_uchar; 64usize], + pub manufacturerID: [::std::os::raw::c_uchar; 32usize], + pub flags: CK_FLAGS, + pub hardwareVersion: _CK_VERSION, + pub firmwareVersion: _CK_VERSION, +} +#[test] +fn bindgen_test_layout__CK_SLOT_INFO() { + assert_eq!( + ::std::mem::size_of::<_CK_SLOT_INFO>(), + 112usize, + concat!("Size of: ", stringify!(_CK_SLOT_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_SLOT_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_SLOT_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SLOT_INFO>())).slotDescription as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_SLOT_INFO), + "::", + stringify!(slotDescription) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SLOT_INFO>())).manufacturerID as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_CK_SLOT_INFO), + "::", + stringify!(manufacturerID) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SLOT_INFO>())).flags as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_CK_SLOT_INFO), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SLOT_INFO>())).hardwareVersion as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_CK_SLOT_INFO), + "::", + stringify!(hardwareVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SLOT_INFO>())).firmwareVersion as *const _ as usize }, + 106usize, + concat!( + "Offset of field: ", + stringify!(_CK_SLOT_INFO), + "::", + stringify!(firmwareVersion) + ) + ); +} +impl Default for _CK_SLOT_INFO { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _CK_TOKEN_INFO { + pub label: [::std::os::raw::c_uchar; 32usize], + pub manufacturerID: [::std::os::raw::c_uchar; 32usize], + pub model: [::std::os::raw::c_uchar; 16usize], + pub serialNumber: [::std::os::raw::c_uchar; 16usize], + pub flags: CK_FLAGS, + pub ulMaxSessionCount: ::std::os::raw::c_ulong, + pub ulSessionCount: ::std::os::raw::c_ulong, + pub ulMaxRwSessionCount: ::std::os::raw::c_ulong, + pub ulRwSessionCount: ::std::os::raw::c_ulong, + pub ulMaxPinLen: ::std::os::raw::c_ulong, + pub ulMinPinLen: ::std::os::raw::c_ulong, + pub ulTotalPublicMemory: ::std::os::raw::c_ulong, + pub ulFreePublicMemory: ::std::os::raw::c_ulong, + pub ulTotalPrivateMemory: ::std::os::raw::c_ulong, + pub ulFreePrivateMemory: ::std::os::raw::c_ulong, + pub hardwareVersion: _CK_VERSION, + pub firmwareVersion: _CK_VERSION, + pub utcTime: [::std::os::raw::c_uchar; 16usize], +} +#[test] +fn bindgen_test_layout__CK_TOKEN_INFO() { + assert_eq!( + ::std::mem::size_of::<_CK_TOKEN_INFO>(), + 208usize, + concat!("Size of: ", stringify!(_CK_TOKEN_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_TOKEN_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_TOKEN_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).label as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(label) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).manufacturerID as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(manufacturerID) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).model as *const _ as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(model) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).serialNumber as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(serialNumber) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).flags as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulMaxSessionCount as *const _ as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulMaxSessionCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulSessionCount as *const _ as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulSessionCount) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulMaxRwSessionCount as *const _ as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulMaxRwSessionCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulRwSessionCount as *const _ as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulRwSessionCount) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulMaxPinLen as *const _ as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulMaxPinLen) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulMinPinLen as *const _ as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulMinPinLen) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulTotalPublicMemory as *const _ as usize + }, + 152usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulTotalPublicMemory) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulFreePublicMemory as *const _ as usize + }, + 160usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulFreePublicMemory) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulTotalPrivateMemory as *const _ as usize + }, + 168usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulTotalPrivateMemory) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).ulFreePrivateMemory as *const _ as usize + }, + 176usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(ulFreePrivateMemory) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).hardwareVersion as *const _ as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(hardwareVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).firmwareVersion as *const _ as usize }, + 186usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(firmwareVersion) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_TOKEN_INFO>())).utcTime as *const _ as usize }, + 188usize, + concat!( + "Offset of field: ", + stringify!(_CK_TOKEN_INFO), + "::", + stringify!(utcTime) + ) + ); +} +pub type CK_SESSION_HANDLE = ::std::os::raw::c_ulong; +pub type CK_USER_TYPE = ::std::os::raw::c_ulong; +pub type CK_STATE = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _CK_SESSION_INFO { + pub slotID: CK_SLOT_ID, + pub state: CK_STATE, + pub flags: CK_FLAGS, + pub ulDeviceError: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout__CK_SESSION_INFO() { + assert_eq!( + ::std::mem::size_of::<_CK_SESSION_INFO>(), + 32usize, + concat!("Size of: ", stringify!(_CK_SESSION_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_SESSION_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_SESSION_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SESSION_INFO>())).slotID as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_SESSION_INFO), + "::", + stringify!(slotID) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SESSION_INFO>())).state as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CK_SESSION_INFO), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SESSION_INFO>())).flags as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_CK_SESSION_INFO), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_SESSION_INFO>())).ulDeviceError as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_CK_SESSION_INFO), + "::", + stringify!(ulDeviceError) + ) + ); +} +pub type CK_OBJECT_HANDLE = ::std::os::raw::c_ulong; +pub type CK_OBJECT_CLASS = ::std::os::raw::c_ulong; +pub type CK_HW_FEATURE_TYPE = ::std::os::raw::c_ulong; +pub type CK_KEY_TYPE = ::std::os::raw::c_ulong; +pub type CK_CERTIFICATE_TYPE = ::std::os::raw::c_ulong; +pub type CK_ATTRIBUTE_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _CK_ATTRIBUTE { + pub type_: CK_ATTRIBUTE_TYPE, + pub pValue: *mut ::std::os::raw::c_void, + pub ulValueLen: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout__CK_ATTRIBUTE() { + assert_eq!( + ::std::mem::size_of::<_CK_ATTRIBUTE>(), + 24usize, + concat!("Size of: ", stringify!(_CK_ATTRIBUTE)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_ATTRIBUTE>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_ATTRIBUTE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_ATTRIBUTE>())).type_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_ATTRIBUTE), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_ATTRIBUTE>())).pValue as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CK_ATTRIBUTE), + "::", + stringify!(pValue) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_ATTRIBUTE>())).ulValueLen as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_CK_ATTRIBUTE), + "::", + stringify!(ulValueLen) + ) + ); +} +impl Default for _CK_ATTRIBUTE { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _CK_DATE { + pub year: [::std::os::raw::c_uchar; 4usize], + pub month: [::std::os::raw::c_uchar; 2usize], + pub day: [::std::os::raw::c_uchar; 2usize], +} +#[test] +fn bindgen_test_layout__CK_DATE() { + assert_eq!( + ::std::mem::size_of::<_CK_DATE>(), + 8usize, + concat!("Size of: ", stringify!(_CK_DATE)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_DATE>(), + 1usize, + concat!("Alignment of ", stringify!(_CK_DATE)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_DATE>())).year as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_DATE), + "::", + stringify!(year) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_DATE>())).month as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(_CK_DATE), + "::", + stringify!(month) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_DATE>())).day as *const _ as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(_CK_DATE), + "::", + stringify!(day) + ) + ); +} +pub type CK_MECHANISM_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _CK_MECHANISM { + pub mechanism: CK_MECHANISM_TYPE, + pub pParameter: *mut ::std::os::raw::c_void, + pub ulParameterLen: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout__CK_MECHANISM() { + assert_eq!( + ::std::mem::size_of::<_CK_MECHANISM>(), + 24usize, + concat!("Size of: ", stringify!(_CK_MECHANISM)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_MECHANISM>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_MECHANISM)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_MECHANISM>())).mechanism as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_MECHANISM), + "::", + stringify!(mechanism) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_MECHANISM>())).pParameter as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CK_MECHANISM), + "::", + stringify!(pParameter) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_MECHANISM>())).ulParameterLen as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_CK_MECHANISM), + "::", + stringify!(ulParameterLen) + ) + ); +} +impl Default for _CK_MECHANISM { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _CK_MECHANISM_INFO { + pub ulMinKeySize: ::std::os::raw::c_ulong, + pub ulMaxKeySize: ::std::os::raw::c_ulong, + pub flags: CK_FLAGS, +} +#[test] +fn bindgen_test_layout__CK_MECHANISM_INFO() { + assert_eq!( + ::std::mem::size_of::<_CK_MECHANISM_INFO>(), + 24usize, + concat!("Size of: ", stringify!(_CK_MECHANISM_INFO)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_MECHANISM_INFO>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_MECHANISM_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_MECHANISM_INFO>())).ulMinKeySize as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_MECHANISM_INFO), + "::", + stringify!(ulMinKeySize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_MECHANISM_INFO>())).ulMaxKeySize as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CK_MECHANISM_INFO), + "::", + stringify!(ulMaxKeySize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_MECHANISM_INFO>())).flags as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_CK_MECHANISM_INFO), + "::", + stringify!(flags) + ) + ); +} +pub type CK_PARAM_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct CK_OTP_PARAM { + pub type_: CK_PARAM_TYPE, + pub pValue: *mut ::std::os::raw::c_void, + pub ulValueLen: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_CK_OTP_PARAM() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(CK_OTP_PARAM)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(CK_OTP_PARAM)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(CK_OTP_PARAM), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pValue as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(CK_OTP_PARAM), + "::", + stringify!(pValue) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulValueLen as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(CK_OTP_PARAM), + "::", + stringify!(ulValueLen) + ) + ); +} +impl Default for CK_OTP_PARAM { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct CK_OTP_PARAMS { + pub pParams: *mut CK_OTP_PARAM, + pub ulCount: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_CK_OTP_PARAMS() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(CK_OTP_PARAMS)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(CK_OTP_PARAMS)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pParams as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(CK_OTP_PARAMS), + "::", + stringify!(pParams) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulCount as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(CK_OTP_PARAMS), + "::", + stringify!(ulCount) + ) + ); +} +impl Default for CK_OTP_PARAMS { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct CK_OTP_SIGNATURE_INFO { + pub pParams: *mut CK_OTP_PARAM, + pub ulCount: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_CK_OTP_SIGNATURE_INFO() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(CK_OTP_SIGNATURE_INFO)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(CK_OTP_SIGNATURE_INFO)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pParams as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(CK_OTP_SIGNATURE_INFO), + "::", + stringify!(pParams) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulCount as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(CK_OTP_SIGNATURE_INFO), + "::", + stringify!(ulCount) + ) + ); +} +impl Default for CK_OTP_SIGNATURE_INFO { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +pub type CK_RSA_PKCS_MGF_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct ck_rsa_pkcs_pss_params { + pub hashAlg: CK_MECHANISM_TYPE, + pub mgf: CK_RSA_PKCS_MGF_TYPE, + pub sLen: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_ck_rsa_pkcs_pss_params() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(ck_rsa_pkcs_pss_params)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_rsa_pkcs_pss_params)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hashAlg as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_pss_params), + "::", + stringify!(hashAlg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).mgf as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_pss_params), + "::", + stringify!(mgf) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).sLen as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_pss_params), + "::", + stringify!(sLen) + ) + ); +} +pub type CK_RSA_PKCS_OAEP_SOURCE_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ck_rsa_pkcs_oaep_params { + pub hashAlg: CK_MECHANISM_TYPE, + pub mgf: CK_RSA_PKCS_MGF_TYPE, + pub source: CK_RSA_PKCS_OAEP_SOURCE_TYPE, + pub pSourceData: *mut ::std::os::raw::c_void, + pub ulSourceDataLen: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_ck_rsa_pkcs_oaep_params() { + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(ck_rsa_pkcs_oaep_params)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_rsa_pkcs_oaep_params)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).hashAlg as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_oaep_params), + "::", + stringify!(hashAlg) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).mgf as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_oaep_params), + "::", + stringify!(mgf) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).source as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_oaep_params), + "::", + stringify!(source) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pSourceData as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_oaep_params), + "::", + stringify!(pSourceData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ulSourceDataLen as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(ck_rsa_pkcs_oaep_params), + "::", + stringify!(ulSourceDataLen) + ) + ); +} +impl Default for ck_rsa_pkcs_oaep_params { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct ck_aes_ctr_params { + pub ulCounterBits: ::std::os::raw::c_ulong, + pub cb: [::std::os::raw::c_uchar; 16usize], +} +#[test] +fn bindgen_test_layout_ck_aes_ctr_params() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(ck_aes_ctr_params)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_aes_ctr_params)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulCounterBits as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_aes_ctr_params), + "::", + stringify!(ulCounterBits) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).cb as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ck_aes_ctr_params), + "::", + stringify!(cb) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ck_gcm_params { + pub pIv: *mut ::std::os::raw::c_uchar, + pub ulIvLen: ::std::os::raw::c_ulong, + pub ulIvBits: ::std::os::raw::c_ulong, + pub pAAD: *mut ::std::os::raw::c_uchar, + pub ulAADLen: ::std::os::raw::c_ulong, + pub ulTagBits: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_ck_gcm_params() { + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(ck_gcm_params)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_gcm_params)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pIv as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_gcm_params), + "::", + stringify!(pIv) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulIvLen as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ck_gcm_params), + "::", + stringify!(ulIvLen) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulIvBits as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ck_gcm_params), + "::", + stringify!(ulIvBits) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).pAAD as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(ck_gcm_params), + "::", + stringify!(pAAD) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulAADLen as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(ck_gcm_params), + "::", + stringify!(ulAADLen) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ulTagBits as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(ck_gcm_params), + "::", + stringify!(ulTagBits) + ) + ); +} +impl Default for ck_gcm_params { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +pub type ck_ec_kdf_t = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ck_ecdh1_derive_params { + pub kdf: ck_ec_kdf_t, + pub ulSharedDataLen: ::std::os::raw::c_ulong, + pub pSharedData: *mut ::std::os::raw::c_uchar, + pub ulPublicDataLen: ::std::os::raw::c_ulong, + pub pPublicData: *mut ::std::os::raw::c_uchar, +} +#[test] +fn bindgen_test_layout_ck_ecdh1_derive_params() { + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(ck_ecdh1_derive_params)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_ecdh1_derive_params)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).kdf as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_ecdh1_derive_params), + "::", + stringify!(kdf) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ulSharedDataLen as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ck_ecdh1_derive_params), + "::", + stringify!(ulSharedDataLen) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pSharedData as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ck_ecdh1_derive_params), + "::", + stringify!(pSharedData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ulPublicDataLen as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(ck_ecdh1_derive_params), + "::", + stringify!(ulPublicDataLen) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pPublicData as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(ck_ecdh1_derive_params), + "::", + stringify!(pPublicData) + ) + ); +} +impl Default for ck_ecdh1_derive_params { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ck_key_derivation_string_data { + pub pData: *mut ::std::os::raw::c_uchar, + pub ulLen: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_ck_key_derivation_string_data() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ck_key_derivation_string_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_key_derivation_string_data)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pData as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_key_derivation_string_data), + "::", + stringify!(pData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ulLen as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ck_key_derivation_string_data), + "::", + stringify!(ulLen) + ) + ); +} +impl Default for ck_key_derivation_string_data { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ck_des_cbc_encrypt_data_params { + pub iv: [::std::os::raw::c_uchar; 8usize], + pub pData: *mut ::std::os::raw::c_uchar, + pub length: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_ck_des_cbc_encrypt_data_params() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(ck_des_cbc_encrypt_data_params)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_des_cbc_encrypt_data_params)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).iv as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_des_cbc_encrypt_data_params), + "::", + stringify!(iv) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pData as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ck_des_cbc_encrypt_data_params), + "::", + stringify!(pData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).length as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ck_des_cbc_encrypt_data_params), + "::", + stringify!(length) + ) + ); +} +impl Default for ck_des_cbc_encrypt_data_params { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ck_aes_cbc_encrypt_data_params { + pub iv: [::std::os::raw::c_uchar; 16usize], + pub pData: *mut ::std::os::raw::c_uchar, + pub length: ::std::os::raw::c_ulong, +} +#[test] +fn bindgen_test_layout_ck_aes_cbc_encrypt_data_params() { + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(ck_aes_cbc_encrypt_data_params)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ck_aes_cbc_encrypt_data_params)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).iv as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ck_aes_cbc_encrypt_data_params), + "::", + stringify!(iv) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).pData as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ck_aes_cbc_encrypt_data_params), + "::", + stringify!(pData) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).length as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(ck_aes_cbc_encrypt_data_params), + "::", + stringify!(length) + ) + ); +} +impl Default for ck_aes_cbc_encrypt_data_params { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +pub type CK_RV = ::std::os::raw::c_ulong; +pub type CK_NOTIFY = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + event: CK_NOTIFICATION, + application: *mut ::std::os::raw::c_void, + ) -> CK_RV, +>; +pub type CK_C_Initialize = + ::std::option::Option CK_RV>; +pub type CK_C_Finalize = + ::std::option::Option CK_RV>; +pub type CK_C_GetInfo = ::std::option::Option CK_RV>; +pub type CK_C_GetFunctionList = ::std::option::Option< + unsafe extern "C" fn(function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV, +>; +pub type CK_C_GetSlotList = ::std::option::Option< + unsafe extern "C" fn( + token_present: ::std::os::raw::c_uchar, + slot_list: *mut CK_SLOT_ID, + ulCount: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_GetSlotInfo = ::std::option::Option< + unsafe extern "C" fn(slotID: CK_SLOT_ID, info: *mut _CK_SLOT_INFO) -> CK_RV, +>; +pub type CK_C_GetTokenInfo = ::std::option::Option< + unsafe extern "C" fn(slotID: CK_SLOT_ID, info: *mut _CK_TOKEN_INFO) -> CK_RV, +>; +pub type CK_C_WaitForSlotEvent = ::std::option::Option< + unsafe extern "C" fn( + flags: CK_FLAGS, + slot: *mut CK_SLOT_ID, + pReserved: *mut ::std::os::raw::c_void, + ) -> CK_RV, +>; +pub type CK_C_GetMechanismList = ::std::option::Option< + unsafe extern "C" fn( + slotID: CK_SLOT_ID, + mechanism_list: *mut CK_MECHANISM_TYPE, + ulCount: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_GetMechanismInfo = ::std::option::Option< + unsafe extern "C" fn( + slotID: CK_SLOT_ID, + type_: CK_MECHANISM_TYPE, + info: *mut _CK_MECHANISM_INFO, + ) -> CK_RV, +>; +pub type CK_C_InitToken = ::std::option::Option< + unsafe extern "C" fn( + slotID: CK_SLOT_ID, + pin: *mut ::std::os::raw::c_uchar, + pin_len: ::std::os::raw::c_ulong, + label: *mut ::std::os::raw::c_uchar, + ) -> CK_RV, +>; +pub type CK_C_InitPIN = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + pin: *mut ::std::os::raw::c_uchar, + pin_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SetPIN = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + old_pin: *mut ::std::os::raw::c_uchar, + old_len: ::std::os::raw::c_ulong, + new_pin: *mut ::std::os::raw::c_uchar, + new_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_OpenSession = ::std::option::Option< + unsafe extern "C" fn( + slotID: CK_SLOT_ID, + flags: CK_FLAGS, + application: *mut ::std::os::raw::c_void, + notify: CK_NOTIFY, + session: *mut CK_SESSION_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_CloseSession = + ::std::option::Option CK_RV>; +pub type CK_C_CloseAllSessions = + ::std::option::Option CK_RV>; +pub type CK_C_GetSessionInfo = ::std::option::Option< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, info: *mut _CK_SESSION_INFO) -> CK_RV, +>; +pub type CK_C_GetOperationState = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + operation_state: *mut ::std::os::raw::c_uchar, + operation_state_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SetOperationState = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + operation_state: *mut ::std::os::raw::c_uchar, + operation_state_len: ::std::os::raw::c_ulong, + encryption_key: CK_OBJECT_HANDLE, + authentiation_key: CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_Login = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + user_type: CK_USER_TYPE, + pin: *mut ::std::os::raw::c_uchar, + pin_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_Logout = + ::std::option::Option CK_RV>; +pub type CK_C_CreateObject = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + object: *mut CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_CopyObject = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + new_object: *mut CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_DestroyObject = ::std::option::Option< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, object: CK_OBJECT_HANDLE) -> CK_RV, +>; +pub type CK_C_GetObjectSize = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + size: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_GetAttributeValue = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SetAttributeValue = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_FindObjectsInit = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_FindObjects = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: *mut CK_OBJECT_HANDLE, + max_object_count: ::std::os::raw::c_ulong, + object_count: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_FindObjectsFinal = + ::std::option::Option CK_RV>; +pub type CK_C_EncryptInit = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_Encrypt = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + data: *mut ::std::os::raw::c_uchar, + data_len: ::std::os::raw::c_ulong, + encrypted_data: *mut ::std::os::raw::c_uchar, + encrypted_data_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_EncryptUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + encrypted_part: *mut ::std::os::raw::c_uchar, + encrypted_part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_EncryptFinal = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + last_encrypted_part: *mut ::std::os::raw::c_uchar, + last_encrypted_part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DecryptInit = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_Decrypt = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + encrypted_data: *mut ::std::os::raw::c_uchar, + encrypted_data_len: ::std::os::raw::c_ulong, + data: *mut ::std::os::raw::c_uchar, + data_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DecryptUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + encrypted_part: *mut ::std::os::raw::c_uchar, + encrypted_part_len: ::std::os::raw::c_ulong, + part: *mut ::std::os::raw::c_uchar, + part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DecryptFinal = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + last_part: *mut ::std::os::raw::c_uchar, + last_part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DigestInit = ::std::option::Option< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, mechanism: *mut _CK_MECHANISM) -> CK_RV, +>; +pub type CK_C_Digest = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + data: *mut ::std::os::raw::c_uchar, + data_len: ::std::os::raw::c_ulong, + digest: *mut ::std::os::raw::c_uchar, + digest_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DigestUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DigestKey = ::std::option::Option< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, key: CK_OBJECT_HANDLE) -> CK_RV, +>; +pub type CK_C_DigestFinal = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + digest: *mut ::std::os::raw::c_uchar, + digest_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SignInit = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_Sign = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + data: *mut ::std::os::raw::c_uchar, + data_len: ::std::os::raw::c_ulong, + signature: *mut ::std::os::raw::c_uchar, + signature_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SignUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SignFinal = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + signature: *mut ::std::os::raw::c_uchar, + signature_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SignRecoverInit = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_SignRecover = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + data: *mut ::std::os::raw::c_uchar, + data_len: ::std::os::raw::c_ulong, + signature: *mut ::std::os::raw::c_uchar, + signature_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_VerifyInit = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_Verify = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + data: *mut ::std::os::raw::c_uchar, + data_len: ::std::os::raw::c_ulong, + signature: *mut ::std::os::raw::c_uchar, + signature_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_VerifyUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_VerifyFinal = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + signature: *mut ::std::os::raw::c_uchar, + signature_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_VerifyRecoverInit = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_VerifyRecover = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + signature: *mut ::std::os::raw::c_uchar, + signature_len: ::std::os::raw::c_ulong, + data: *mut ::std::os::raw::c_uchar, + data_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DigestEncryptUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + encrypted_part: *mut ::std::os::raw::c_uchar, + encrypted_part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DecryptDigestUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + encrypted_part: *mut ::std::os::raw::c_uchar, + encrypted_part_len: ::std::os::raw::c_ulong, + part: *mut ::std::os::raw::c_uchar, + part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_SignEncryptUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + encrypted_part: *mut ::std::os::raw::c_uchar, + encrypted_part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_DecryptVerifyUpdate = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + encrypted_part: *mut ::std::os::raw::c_uchar, + encrypted_part_len: ::std::os::raw::c_ulong, + part: *mut ::std::os::raw::c_uchar, + part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_GenerateKey = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + key: *mut CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_GenerateKeyPair = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + public_key_template: *mut _CK_ATTRIBUTE, + public_key_attribute_count: ::std::os::raw::c_ulong, + private_key_template: *mut _CK_ATTRIBUTE, + private_key_attribute_count: ::std::os::raw::c_ulong, + public_key: *mut CK_OBJECT_HANDLE, + private_key: *mut CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_WrapKey = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + wrapping_key: CK_OBJECT_HANDLE, + key: CK_OBJECT_HANDLE, + wrapped_key: *mut ::std::os::raw::c_uchar, + wrapped_key_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_UnwrapKey = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + unwrapping_key: CK_OBJECT_HANDLE, + wrapped_key: *mut ::std::os::raw::c_uchar, + wrapped_key_len: ::std::os::raw::c_ulong, + templ: *mut _CK_ATTRIBUTE, + attribute_count: ::std::os::raw::c_ulong, + key: *mut CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_DeriveKey = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + base_key: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + attribute_count: ::std::os::raw::c_ulong, + key: *mut CK_OBJECT_HANDLE, + ) -> CK_RV, +>; +pub type CK_C_SeedRandom = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + seed: *mut ::std::os::raw::c_uchar, + seed_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_GenerateRandom = ::std::option::Option< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + random_data: *mut ::std::os::raw::c_uchar, + random_len: ::std::os::raw::c_ulong, + ) -> CK_RV, +>; +pub type CK_C_GetFunctionStatus = + ::std::option::Option CK_RV>; +pub type CK_C_CancelFunction = + ::std::option::Option CK_RV>; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct _CK_FUNCTION_LIST { + pub version: _CK_VERSION, + pub C_Initialize: CK_C_Initialize, + pub C_Finalize: CK_C_Finalize, + pub C_GetInfo: CK_C_GetInfo, + pub C_GetFunctionList: CK_C_GetFunctionList, + pub C_GetSlotList: CK_C_GetSlotList, + pub C_GetSlotInfo: CK_C_GetSlotInfo, + pub C_GetTokenInfo: CK_C_GetTokenInfo, + pub C_GetMechanismList: CK_C_GetMechanismList, + pub C_GetMechanismInfo: CK_C_GetMechanismInfo, + pub C_InitToken: CK_C_InitToken, + pub C_InitPIN: CK_C_InitPIN, + pub C_SetPIN: CK_C_SetPIN, + pub C_OpenSession: CK_C_OpenSession, + pub C_CloseSession: CK_C_CloseSession, + pub C_CloseAllSessions: CK_C_CloseAllSessions, + pub C_GetSessionInfo: CK_C_GetSessionInfo, + pub C_GetOperationState: CK_C_GetOperationState, + pub C_SetOperationState: CK_C_SetOperationState, + pub C_Login: CK_C_Login, + pub C_Logout: CK_C_Logout, + pub C_CreateObject: CK_C_CreateObject, + pub C_CopyObject: CK_C_CopyObject, + pub C_DestroyObject: CK_C_DestroyObject, + pub C_GetObjectSize: CK_C_GetObjectSize, + pub C_GetAttributeValue: CK_C_GetAttributeValue, + pub C_SetAttributeValue: CK_C_SetAttributeValue, + pub C_FindObjectsInit: CK_C_FindObjectsInit, + pub C_FindObjects: CK_C_FindObjects, + pub C_FindObjectsFinal: CK_C_FindObjectsFinal, + pub C_EncryptInit: CK_C_EncryptInit, + pub C_Encrypt: CK_C_Encrypt, + pub C_EncryptUpdate: CK_C_EncryptUpdate, + pub C_EncryptFinal: CK_C_EncryptFinal, + pub C_DecryptInit: CK_C_DecryptInit, + pub C_Decrypt: CK_C_Decrypt, + pub C_DecryptUpdate: CK_C_DecryptUpdate, + pub C_DecryptFinal: CK_C_DecryptFinal, + pub C_DigestInit: CK_C_DigestInit, + pub C_Digest: CK_C_Digest, + pub C_DigestUpdate: CK_C_DigestUpdate, + pub C_DigestKey: CK_C_DigestKey, + pub C_DigestFinal: CK_C_DigestFinal, + pub C_SignInit: CK_C_SignInit, + pub C_Sign: CK_C_Sign, + pub C_SignUpdate: CK_C_SignUpdate, + pub C_SignFinal: CK_C_SignFinal, + pub C_SignRecoverInit: CK_C_SignRecoverInit, + pub C_SignRecover: CK_C_SignRecover, + pub C_VerifyInit: CK_C_VerifyInit, + pub C_Verify: CK_C_Verify, + pub C_VerifyUpdate: CK_C_VerifyUpdate, + pub C_VerifyFinal: CK_C_VerifyFinal, + pub C_VerifyRecoverInit: CK_C_VerifyRecoverInit, + pub C_VerifyRecover: CK_C_VerifyRecover, + pub C_DigestEncryptUpdate: CK_C_DigestEncryptUpdate, + pub C_DecryptDigestUpdate: CK_C_DecryptDigestUpdate, + pub C_SignEncryptUpdate: CK_C_SignEncryptUpdate, + pub C_DecryptVerifyUpdate: CK_C_DecryptVerifyUpdate, + pub C_GenerateKey: CK_C_GenerateKey, + pub C_GenerateKeyPair: CK_C_GenerateKeyPair, + pub C_WrapKey: CK_C_WrapKey, + pub C_UnwrapKey: CK_C_UnwrapKey, + pub C_DeriveKey: CK_C_DeriveKey, + pub C_SeedRandom: CK_C_SeedRandom, + pub C_GenerateRandom: CK_C_GenerateRandom, + pub C_GetFunctionStatus: CK_C_GetFunctionStatus, + pub C_CancelFunction: CK_C_CancelFunction, + pub C_WaitForSlotEvent: CK_C_WaitForSlotEvent, +} +#[test] +fn bindgen_test_layout__CK_FUNCTION_LIST() { + assert_eq!( + ::std::mem::size_of::<_CK_FUNCTION_LIST>(), + 552usize, + concat!("Size of: ", stringify!(_CK_FUNCTION_LIST)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_FUNCTION_LIST>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_FUNCTION_LIST)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).version as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(version) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Initialize as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Initialize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Finalize as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Finalize) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetInfo as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetInfo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetFunctionList as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetFunctionList) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetSlotList as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetSlotList) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetSlotInfo as *const _ as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetSlotInfo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetTokenInfo as *const _ as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetTokenInfo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetMechanismList as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetMechanismList) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetMechanismInfo as *const _ as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetMechanismInfo) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_InitToken as *const _ as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_InitToken) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_InitPIN as *const _ as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_InitPIN) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SetPIN as *const _ as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SetPIN) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_OpenSession as *const _ as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_OpenSession) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_CloseSession as *const _ as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_CloseSession) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_CloseAllSessions as *const _ as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_CloseAllSessions) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetSessionInfo as *const _ as usize + }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetSessionInfo) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetOperationState as *const _ as usize + }, + 136usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetOperationState) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SetOperationState as *const _ as usize + }, + 144usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SetOperationState) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Login as *const _ as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Login) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Logout as *const _ as usize }, + 160usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Logout) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_CreateObject as *const _ as usize + }, + 168usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_CreateObject) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_CopyObject as *const _ as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_CopyObject) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DestroyObject as *const _ as usize + }, + 184usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DestroyObject) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetObjectSize as *const _ as usize + }, + 192usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetObjectSize) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetAttributeValue as *const _ as usize + }, + 200usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetAttributeValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SetAttributeValue as *const _ as usize + }, + 208usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SetAttributeValue) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_FindObjectsInit as *const _ as usize + }, + 216usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_FindObjectsInit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_FindObjects as *const _ as usize }, + 224usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_FindObjects) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_FindObjectsFinal as *const _ as usize + }, + 232usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_FindObjectsFinal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_EncryptInit as *const _ as usize }, + 240usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_EncryptInit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Encrypt as *const _ as usize }, + 248usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Encrypt) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_EncryptUpdate as *const _ as usize + }, + 256usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_EncryptUpdate) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_EncryptFinal as *const _ as usize + }, + 264usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_EncryptFinal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DecryptInit as *const _ as usize }, + 272usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DecryptInit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Decrypt as *const _ as usize }, + 280usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Decrypt) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DecryptUpdate as *const _ as usize + }, + 288usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DecryptUpdate) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DecryptFinal as *const _ as usize + }, + 296usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DecryptFinal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DigestInit as *const _ as usize }, + 304usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DigestInit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Digest as *const _ as usize }, + 312usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Digest) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DigestUpdate as *const _ as usize + }, + 320usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DigestUpdate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DigestKey as *const _ as usize }, + 328usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DigestKey) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DigestFinal as *const _ as usize }, + 336usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DigestFinal) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SignInit as *const _ as usize }, + 344usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SignInit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Sign as *const _ as usize }, + 352usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Sign) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SignUpdate as *const _ as usize }, + 360usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SignUpdate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SignFinal as *const _ as usize }, + 368usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SignFinal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SignRecoverInit as *const _ as usize + }, + 376usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SignRecoverInit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SignRecover as *const _ as usize }, + 384usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SignRecover) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_VerifyInit as *const _ as usize }, + 392usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_VerifyInit) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_Verify as *const _ as usize }, + 400usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_Verify) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_VerifyUpdate as *const _ as usize + }, + 408usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_VerifyUpdate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_VerifyFinal as *const _ as usize }, + 416usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_VerifyFinal) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_VerifyRecoverInit as *const _ as usize + }, + 424usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_VerifyRecoverInit) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_VerifyRecover as *const _ as usize + }, + 432usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_VerifyRecover) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DigestEncryptUpdate as *const _ as usize + }, + 440usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DigestEncryptUpdate) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DecryptDigestUpdate as *const _ as usize + }, + 448usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DecryptDigestUpdate) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SignEncryptUpdate as *const _ as usize + }, + 456usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SignEncryptUpdate) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DecryptVerifyUpdate as *const _ as usize + }, + 464usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DecryptVerifyUpdate) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GenerateKey as *const _ as usize }, + 472usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GenerateKey) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GenerateKeyPair as *const _ as usize + }, + 480usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GenerateKeyPair) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_WrapKey as *const _ as usize }, + 488usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_WrapKey) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_UnwrapKey as *const _ as usize }, + 496usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_UnwrapKey) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_DeriveKey as *const _ as usize }, + 504usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_DeriveKey) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_SeedRandom as *const _ as usize }, + 512usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_SeedRandom) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GenerateRandom as *const _ as usize + }, + 520usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GenerateRandom) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_GetFunctionStatus as *const _ as usize + }, + 528usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_GetFunctionStatus) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_CancelFunction as *const _ as usize + }, + 536usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_CancelFunction) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_FUNCTION_LIST>())).C_WaitForSlotEvent as *const _ as usize + }, + 544usize, + concat!( + "Offset of field: ", + stringify!(_CK_FUNCTION_LIST), + "::", + stringify!(C_WaitForSlotEvent) + ) + ); +} +pub type CK_CREATEMUTEX = + ::std::option::Option CK_RV>; +pub type CK_DESTROYMUTEX = + ::std::option::Option CK_RV>; +pub type CK_LOCKMUTEX = + ::std::option::Option CK_RV>; +pub type CK_UNLOCKMUTEX = + ::std::option::Option CK_RV>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _CK_C_INITIALIZE_ARGS { + pub CreateMutex: CK_CREATEMUTEX, + pub DestroyMutex: CK_DESTROYMUTEX, + pub LockMutex: CK_LOCKMUTEX, + pub UnlockMutex: CK_UNLOCKMUTEX, + pub flags: CK_FLAGS, + pub pReserved: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout__CK_C_INITIALIZE_ARGS() { + assert_eq!( + ::std::mem::size_of::<_CK_C_INITIALIZE_ARGS>(), + 48usize, + concat!("Size of: ", stringify!(_CK_C_INITIALIZE_ARGS)) + ); + assert_eq!( + ::std::mem::align_of::<_CK_C_INITIALIZE_ARGS>(), + 8usize, + concat!("Alignment of ", stringify!(_CK_C_INITIALIZE_ARGS)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_C_INITIALIZE_ARGS>())).CreateMutex as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_CK_C_INITIALIZE_ARGS), + "::", + stringify!(CreateMutex) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_C_INITIALIZE_ARGS>())).DestroyMutex as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_CK_C_INITIALIZE_ARGS), + "::", + stringify!(DestroyMutex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_C_INITIALIZE_ARGS>())).LockMutex as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_CK_C_INITIALIZE_ARGS), + "::", + stringify!(LockMutex) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<_CK_C_INITIALIZE_ARGS>())).UnlockMutex as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_CK_C_INITIALIZE_ARGS), + "::", + stringify!(UnlockMutex) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_C_INITIALIZE_ARGS>())).flags as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_CK_C_INITIALIZE_ARGS), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<_CK_C_INITIALIZE_ARGS>())).pReserved as *const _ as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_CK_C_INITIALIZE_ARGS), + "::", + stringify!(pReserved) + ) + ); +} +impl Default for _CK_C_INITIALIZE_ARGS { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +pub type size_t = ::std::os::raw::c_ulong; +pub type wchar_t = ::std::os::raw::c_int; +pub type CK_BYTE = ::std::os::raw::c_uchar; +pub type CK_CHAR = ::std::os::raw::c_uchar; +pub type CK_UTF8CHAR = ::std::os::raw::c_uchar; +pub type CK_BBOOL = ::std::os::raw::c_uchar; +pub type CK_ULONG = ::std::os::raw::c_ulong; +pub type CK_LONG = ::std::os::raw::c_long; +pub type CK_BYTE_PTR = *mut CK_BYTE; +pub type CK_CHAR_PTR = *mut CK_CHAR; +pub type CK_UTF8CHAR_PTR = *mut CK_UTF8CHAR; +pub type CK_ULONG_PTR = *mut CK_ULONG; +pub type CK_VOID_PTR = *mut ::std::os::raw::c_void; +pub type CK_VOID_PTR_PTR = *mut *mut ::std::os::raw::c_void; +pub type CK_VERSION = _CK_VERSION; +pub type CK_VERSION_PTR = *mut _CK_VERSION; +pub type CK_INFO = _CK_INFO; +pub type CK_INFO_PTR = *mut _CK_INFO; +pub type CK_SLOT_ID_PTR = *mut CK_SLOT_ID; +pub type CK_SLOT_INFO = _CK_SLOT_INFO; +pub type CK_SLOT_INFO_PTR = *mut _CK_SLOT_INFO; +pub type CK_TOKEN_INFO = _CK_TOKEN_INFO; +pub type CK_TOKEN_INFO_PTR = *mut _CK_TOKEN_INFO; +pub type CK_SESSION_HANDLE_PTR = *mut CK_SESSION_HANDLE; +pub type CK_SESSION_INFO = _CK_SESSION_INFO; +pub type CK_SESSION_INFO_PTR = *mut _CK_SESSION_INFO; +pub type CK_OBJECT_HANDLE_PTR = *mut CK_OBJECT_HANDLE; +pub type CK_OBJECT_CLASS_PTR = *mut CK_OBJECT_CLASS; +pub type CK_ATTRIBUTE = _CK_ATTRIBUTE; +pub type CK_ATTRIBUTE_PTR = *mut _CK_ATTRIBUTE; +pub type CK_DATE = _CK_DATE; +pub type CK_DATE_PTR = *mut _CK_DATE; +pub type CK_MECHANISM_TYPE_PTR = *mut CK_MECHANISM_TYPE; +pub type CK_MECHANISM = _CK_MECHANISM; +pub type CK_MECHANISM_PTR = *mut _CK_MECHANISM; +pub type CK_MECHANISM_INFO = _CK_MECHANISM_INFO; +pub type CK_MECHANISM_INFO_PTR = *mut _CK_MECHANISM_INFO; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ck_otp_mechanism_info { + _unused: [u8; 0], +} +pub type CK_OTP_MECHANISM_INFO = ck_otp_mechanism_info; +pub type CK_OTP_MECHANISM_INFO_PTR = *mut ck_otp_mechanism_info; +pub type CK_FUNCTION_LIST = _CK_FUNCTION_LIST; +pub type CK_FUNCTION_LIST_PTR = *mut _CK_FUNCTION_LIST; +pub type CK_FUNCTION_LIST_PTR_PTR = *mut *mut _CK_FUNCTION_LIST; +pub type CK_C_INITIALIZE_ARGS = _CK_C_INITIALIZE_ARGS; +pub type CK_C_INITIALIZE_ARGS_PTR = *mut _CK_C_INITIALIZE_ARGS; +pub type CK_RSA_PKCS_PSS_PARAMS = ck_rsa_pkcs_pss_params; +pub type CK_RSA_PKCS_PSS_PARAMS_PTR = *mut ck_rsa_pkcs_pss_params; +pub type CK_RSA_PKCS_OAEP_PARAMS = ck_rsa_pkcs_oaep_params; +pub type CK_RSA_PKCS_OAEP_PARAMS_PTR = *mut ck_rsa_pkcs_oaep_params; +pub type CK_AES_CTR_PARAMS = ck_aes_ctr_params; +pub type CK_AES_CTR_PARAMS_PTR = *mut ck_aes_ctr_params; +pub type CK_GCM_PARAMS = ck_gcm_params; +pub type CK_GCM_PARAMS_PTR = *mut ck_gcm_params; +pub type CK_ECDH1_DERIVE_PARAMS = ck_ecdh1_derive_params; +pub type CK_ECDH1_DERIVE_PARAMS_PTR = *mut ck_ecdh1_derive_params; +pub type CK_KEY_DERIVATION_STRING_DATA = ck_key_derivation_string_data; +pub type CK_KEY_DERIVATION_STRING_DATA_PTR = *mut ck_key_derivation_string_data; +pub type CK_DES_CBC_ENCRYPT_DATA_PARAMS = ck_des_cbc_encrypt_data_params; +pub type CK_DES_CBC_ENCRYPT_DATA_PARAMS_PTR = *mut ck_des_cbc_encrypt_data_params; +pub type CK_AES_CBC_ENCRYPT_DATA_PARAMS = ck_aes_cbc_encrypt_data_params; +pub type CK_AES_CBC_ENCRYPT_DATA_PARAMS_PTR = *mut ck_aes_cbc_encrypt_data_params; +extern crate libloading; +pub struct Pkcs11 { + __library: ::libloading::Library, + pub C_GetFunctionList: Result< + unsafe extern "C" fn(function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV, + ::libloading::Error, + >, +} +impl Pkcs11 { + pub unsafe fn new

(path: P) -> Result + where + P: AsRef<::std::ffi::OsStr>, + { + let library = ::libloading::Library::new(path)?; + Self::from_library(library) + } + pub unsafe fn from_library(library: L) -> Result + where + L: Into<::libloading::Library>, + { + let __library = library.into(); + let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); + Ok(Pkcs11 { + __library, + C_GetFunctionList, + }) + } + pub unsafe fn C_GetFunctionList(&self, function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV { + (self + .C_GetFunctionList + .as_ref() + .expect("Expected function, got error."))(function_list) + } +} diff --git a/cryptoki-sys/src/lib.rs b/cryptoki-sys/src/lib.rs index 380996ef..3a92f711 100644 --- a/cryptoki-sys/src/lib.rs +++ b/cryptoki-sys/src/lib.rs @@ -70,6 +70,16 @@ include!(concat!( "/src/bindings/x86_64-apple-darwin.rs" )); +#[cfg(all( + not(feature = "generate-bindings"), + target_arch = "aarch64", + target_os = "macos" +))] +include!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/src/bindings/aarch64-apple-darwin.rs" +)); + // If the "generate-bindings" feature is on, use the generated bindings. #[cfg(feature = "generate-bindings")] include!(concat!(env!("OUT_DIR"), "/pkcs11_bindings.rs")); From 67b019915ea30c2a327847e7c1e3b2274a783f3f Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Wed, 9 Feb 2022 11:21:41 +0000 Subject: [PATCH 6/7] Add MacOS targets to testing Signed-off-by: Ionut Mihalcea --- .github/workflows/ci.yml | 4 +++- ci.sh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6f54d9e..10e5438f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,9 @@ jobs: rustup target add aarch64-unknown-linux-gnu && rustup target add i686-unknown-linux-gnu && rustup target add powerpc64-unknown-linux-gnu && - rustup target add powerpc64le-unknown-linux-gnu + rustup target add powerpc64le-unknown-linux-gnu && + rustup target add x86_64-apple-darwin && + rustup target add aarch64-apple-darwin - name: Test script env: diff --git a/ci.sh b/ci.sh index dd395c7c..30cda35f 100755 --- a/ci.sh +++ b/ci.sh @@ -16,6 +16,8 @@ RUST_BACKTRACE=1 cargo build --target aarch64-unknown-linux-gnu RUST_BACKTRACE=1 cargo build --target i686-unknown-linux-gnu RUST_BACKTRACE=1 cargo build --target powerpc64-unknown-linux-gnu RUST_BACKTRACE=1 cargo build --target powerpc64le-unknown-linux-gnu +RUST_BACKTRACE=1 cargo build --target x86_64-apple-darwin +RUST_BACKTRACE=1 cargo build --target aarch64-apple-darwin pushd cryptoki-sys RUST_BACKTRACE=1 cargo build --features generate-bindings From 9dbf06a6caa6de3cd96095ca739d83a06ea1e90b Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Thu, 10 Feb 2022 14:37:23 +0000 Subject: [PATCH 7/7] Bump version numbers for cryptoki v0.2.1 Signed-off-by: Ionut Mihalcea --- cryptoki-sys/Cargo.toml | 2 +- cryptoki/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cryptoki-sys/Cargo.toml b/cryptoki-sys/Cargo.toml index 12469ed1..de1ebf94 100644 --- a/cryptoki-sys/Cargo.toml +++ b/cryptoki-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptoki-sys" -version = "0.1.2" +version = "0.1.3" authors = ["Contributors to the Parsec project"] edition = '2018' description = "FFI wrapper around the PKCS #11 API" diff --git a/cryptoki/Cargo.toml b/cryptoki/Cargo.toml index fe912f34..c9184cab 100644 --- a/cryptoki/Cargo.toml +++ b/cryptoki/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptoki" -version = "0.2.0" +version = "0.2.1" authors = ["Contributors to the Parsec project"] edition = '2018' description = "Rust-native wrapper around the PKCS #11 API" @@ -17,7 +17,7 @@ log = "0.4.14" derivative = "2.2.0" secrecy = "0.7.0" psa-crypto = { version = "0.9.0", default-features = false, optional = true } -cryptoki-sys = { path = "../cryptoki-sys", version = "0.1.2" } +cryptoki-sys = { path = "../cryptoki-sys", version = "0.1.3" } [dev-dependencies] num-traits = "0.2.14"