Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump bindgen for version 0.2.x of crate #82

Merged
merged 6 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cryptoki-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
28 changes: 28 additions & 0 deletions cryptoki-sys/regenerate_bindings.sh
Original file line number Diff line number Diff line change
@@ -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
145 changes: 78 additions & 67 deletions cryptoki-sys/src/bindings/aarch64-unknown-linux-gnu.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::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;
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::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;
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
Expand Down Expand Up @@ -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::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
pub type CK_RV = ::std::os::raw::c_ulong;
Expand Down Expand Up @@ -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::<Self>::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::<max_align_t>(),
32usize,
concat!("Size of: ", stringify!(max_align_t))
);
assert_eq!(
::std::mem::align_of::<max_align_t>(),
16usize,
concat!("Alignment of ", stringify!(max_align_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<max_align_t>())).__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::<max_align_t>())).__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;
Expand Down Expand Up @@ -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<L>(library: L) -> Result<Self, ::libloading::Error>
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)
}
}
Loading