From 6db620c52629daf64b20433b80c6d14069f4aed6 Mon Sep 17 00:00:00 2001 From: Arjen Nienhuis Date: Wed, 21 Jun 2023 00:02:19 +0200 Subject: [PATCH] Make generic bindings The platform specific bindings are similar, except for: - the `packed` attribute - the layout_tests By removing the tests and adding `cfg_attr` for `packed` you get a binding that works cross platform. Signed-off-by: Arjen Nienhuis --- cryptoki-sys/build.rs | 54 +- cryptoki-sys/regenerate_bindings.sh | 4 + cryptoki-sys/src/bindings/generic.rs | 3178 ++++++++++++++++++++++++++ cryptoki-sys/src/lib.rs | 18 + 4 files changed, 3224 insertions(+), 30 deletions(-) create mode 100644 cryptoki-sys/src/bindings/generic.rs diff --git a/cryptoki-sys/build.rs b/cryptoki-sys/build.rs index 47fb3946..b95d6c1f 100644 --- a/cryptoki-sys/build.rs +++ b/cryptoki-sys/build.rs @@ -5,30 +5,6 @@ fn main() { { generate::generate_bindings(); } - - #[cfg(not(feature = "generate-bindings"))] - { - use std::str::FromStr; - use target_lexicon::{Architecture, OperatingSystem, Triple}; - - let target = Triple::from_str(&std::env::var("TARGET").unwrap()) - .expect("Failed to parse target triple"); - match (target.architecture, target.operating_system) { - (Architecture::Arm(_), OperatingSystem::Linux) => {} - (Architecture::Aarch64(_), OperatingSystem::Linux) => {} - (Architecture::X86_64, OperatingSystem::Linux) => {} - (Architecture::X86_32(_), OperatingSystem::Linux) => {} - (Architecture::Powerpc64, OperatingSystem::Linux) => {} - (Architecture::Powerpc64le, OperatingSystem::Linux) => {} - (Architecture::X86_64, OperatingSystem::Darwin) => {} - (Architecture::Aarch64(_), OperatingSystem::Darwin) => {} - (Architecture::X86_64, OperatingSystem::Windows) => {} - (Architecture::X86_64, OperatingSystem::Freebsd) => {} - (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); - } - } - } } // Only on a specific feature @@ -81,7 +57,19 @@ mod generate { } pub fn generate_bindings() { - let bindings = bindgen::Builder::default() + let make_generic: bool = std::env::var_os("MAKE_GENERIC_BINDINGS").is_some(); + let mut builder = bindgen::Builder::default(); + if make_generic { + // only WIN32 bindings are "packed". It's easier to "unpack" for other architectures + // __declspec is not needed and causes problems + const GENERIC_PRELUDE: &str = "#define _WIN32 1\n#define __declspec(x)\n"; + builder = builder + // layout tests are not generic + .layout_tests(false) + .header_contents("generic-prelude.h", GENERIC_PRELUDE) + } + + builder = builder .header("pkcs11.h") .dynamic_library_name("Pkcs11") // The PKCS11 library works in a slightly different way to most shared libraries. We have @@ -98,14 +86,20 @@ mod generate { .derive_debug(true) // Derive the `Default` trait for the generated structs where possible. .derive_default(true) - .parse_callbacks(Box::new(CargoCallbacks)) - .generate() - .expect("Unable to generate bindings"); + .parse_callbacks(Box::new(CargoCallbacks)); + + let bindings = builder.generate().expect("Unable to generate bindings"); + + let mut data = bindings.to_string(); + if make_generic { + const PACK_ALWAYS: &str = "#[repr(C, packed)]"; + const PACK_WINDOWS: &str = "#[repr(C)]\n#[cfg_attr(windows, repr(packed))]"; + data = data.replace(PACK_ALWAYS, PACK_WINDOWS); + } // Write the bindings to the $OUT_DIR/pkcs11_bindings.rs file. let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); - bindings - .write_to_file(out_path.join("pkcs11_bindings.rs")) + std::fs::write(out_path.join("pkcs11_bindings.rs"), data) .expect("Couldn't write bindings!"); } } diff --git a/cryptoki-sys/regenerate_bindings.sh b/cryptoki-sys/regenerate_bindings.sh index afc8d468..d90c5267 100755 --- a/cryptoki-sys/regenerate_bindings.sh +++ b/cryptoki-sys/regenerate_bindings.sh @@ -5,6 +5,10 @@ set -xeuf -o pipefail +find ../target/ -name "pkcs11_bindings.rs" -delete +MAKE_GENERIC_BINDINGS=1 cargo build --features generate-bindings +find ../target/ -name "pkcs11_bindings.rs" | xargs -I '{}' cp '{}' src/bindings/generic.rs + targets="aarch64-unknown-linux-gnu arm-unknown-linux-gnueabi x86_64-pc-windows-msvc i686-unknown-linux-gnu powerpc64-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-apple-darwin aarch64-apple-darwin x86_64-unknown-freebsd" TARGET_INSTALLED= diff --git a/cryptoki-sys/src/bindings/generic.rs b/cryptoki-sys/src/bindings/generic.rs new file mode 100644 index 00000000..e78ab1b9 --- /dev/null +++ b/cryptoki-sys/src/bindings/generic.rs @@ -0,0 +1,3178 @@ +/* automatically generated by rust-bindgen 0.63.0 */ + +pub const PKCS11_H: u32 = 1; +pub const CRYPTOKI_VERSION_MAJOR: CK_BYTE = 2; +pub const CRYPTOKI_VERSION_MINOR: CK_BYTE = 40; +pub const P11_KIT_CRYPTOKI_VERSION_REVISION: u32 = 0; +pub const CRYPTOKI_COMPAT: u32 = 1; +pub const CKF_RNG: CK_FLAGS = 1; +pub const CKF_WRITE_PROTECTED: CK_FLAGS = 2; +pub const CKF_LOGIN_REQUIRED: CK_FLAGS = 4; +pub const CKF_USER_PIN_INITIALIZED: CK_FLAGS = 8; +pub const CKF_RESTORE_KEY_NOT_NEEDED: CK_FLAGS = 32; +pub const CKF_CLOCK_ON_TOKEN: CK_FLAGS = 64; +pub const CKF_PROTECTED_AUTHENTICATION_PATH: CK_FLAGS = 256; +pub const CKF_DUAL_CRYPTO_OPERATIONS: CK_FLAGS = 512; +pub const CKF_TOKEN_INITIALIZED: CK_FLAGS = 1024; +pub const CKF_SECONDARY_AUTHENTICATION: CK_FLAGS = 2048; +pub const CKF_USER_PIN_COUNT_LOW: CK_FLAGS = 65536; +pub const CKF_USER_PIN_FINAL_TRY: CK_FLAGS = 131072; +pub const CKF_USER_PIN_LOCKED: CK_FLAGS = 262144; +pub const CKF_USER_PIN_TO_BE_CHANGED: CK_FLAGS = 524288; +pub const CKF_SO_PIN_COUNT_LOW: CK_FLAGS = 1048576; +pub const CKF_SO_PIN_FINAL_TRY: CK_FLAGS = 2097152; +pub const CKF_SO_PIN_LOCKED: CK_FLAGS = 4194304; +pub const CKF_SO_PIN_TO_BE_CHANGED: CK_FLAGS = 8388608; +pub const CKF_ERROR_STATE: CK_FLAGS = 16777216; +pub const CK_EFFECTIVELY_INFINITE: CK_ULONG = 0; +pub const CK_INVALID_HANDLE: CK_ULONG = 0; +pub const CKU_SO: CK_USER_TYPE = 0; +pub const CKU_USER: CK_USER_TYPE = 1; +pub const CKU_CONTEXT_SPECIFIC: CK_USER_TYPE = 2; +pub const CKS_RO_PUBLIC_SESSION: CK_STATE = 0; +pub const CKS_RO_USER_FUNCTIONS: CK_STATE = 1; +pub const CKS_RW_PUBLIC_SESSION: CK_STATE = 2; +pub const CKS_RW_USER_FUNCTIONS: CK_STATE = 3; +pub const CKS_RW_SO_FUNCTIONS: CK_STATE = 4; +pub const CKF_RW_SESSION: CK_FLAGS = 2; +pub const CKF_SERIAL_SESSION: CK_FLAGS = 4; +pub const CKO_DATA: CK_OBJECT_CLASS = 0; +pub const CKO_CERTIFICATE: CK_OBJECT_CLASS = 1; +pub const CKO_PUBLIC_KEY: CK_OBJECT_CLASS = 2; +pub const CKO_PRIVATE_KEY: CK_OBJECT_CLASS = 3; +pub const CKO_SECRET_KEY: CK_OBJECT_CLASS = 4; +pub const CKO_HW_FEATURE: CK_OBJECT_CLASS = 5; +pub const CKO_DOMAIN_PARAMETERS: CK_OBJECT_CLASS = 6; +pub const CKO_MECHANISM: CK_OBJECT_CLASS = 7; +pub const CKO_OTP_KEY: CK_OBJECT_CLASS = 8; +pub const CKH_MONOTONIC_COUNTER: CK_HW_FEATURE_TYPE = 1; +pub const CKH_CLOCK: CK_HW_FEATURE_TYPE = 2; +pub const CKH_USER_INTERFACE: CK_HW_FEATURE_TYPE = 3; +pub const CKK_RSA: CK_KEY_TYPE = 0; +pub const CKK_DSA: CK_KEY_TYPE = 1; +pub const CKK_DH: CK_KEY_TYPE = 2; +pub const CKK_ECDSA: CK_KEY_TYPE = 3; +pub const CKK_EC: CK_KEY_TYPE = 3; +pub const CKK_X9_42_DH: CK_KEY_TYPE = 4; +pub const CKK_KEA: CK_KEY_TYPE = 5; +pub const CKK_GENERIC_SECRET: CK_KEY_TYPE = 16; +pub const CKK_RC2: CK_KEY_TYPE = 17; +pub const CKK_RC4: CK_KEY_TYPE = 18; +pub const CKK_DES: CK_KEY_TYPE = 19; +pub const CKK_DES2: CK_KEY_TYPE = 20; +pub const CKK_DES3: CK_KEY_TYPE = 21; +pub const CKK_CAST: CK_KEY_TYPE = 22; +pub const CKK_CAST3: CK_KEY_TYPE = 23; +pub const CKK_CAST128: CK_KEY_TYPE = 24; +pub const CKK_RC5: CK_KEY_TYPE = 25; +pub const CKK_IDEA: CK_KEY_TYPE = 26; +pub const CKK_SKIPJACK: CK_KEY_TYPE = 27; +pub const CKK_BATON: CK_KEY_TYPE = 28; +pub const CKK_JUNIPER: CK_KEY_TYPE = 29; +pub const CKK_CDMF: CK_KEY_TYPE = 30; +pub const CKK_AES: CK_KEY_TYPE = 31; +pub const CKK_BLOWFISH: CK_KEY_TYPE = 32; +pub const CKK_TWOFISH: CK_KEY_TYPE = 33; +pub const CKK_SECURID: CK_KEY_TYPE = 34; +pub const CKK_HOTP: CK_KEY_TYPE = 35; +pub const CKK_ACTI: CK_KEY_TYPE = 36; +pub const CKK_CAMELLIA: CK_KEY_TYPE = 37; +pub const CKK_ARIA: CK_KEY_TYPE = 38; +pub const CKK_MD5_HMAC: CK_KEY_TYPE = 39; +pub const CKK_SHA_1_HMAC: CK_KEY_TYPE = 40; +pub const CKK_RIPEMD128_HMAC: CK_KEY_TYPE = 41; +pub const CKK_RIPEMD160_HMAC: CK_KEY_TYPE = 42; +pub const CKK_SHA256_HMAC: CK_KEY_TYPE = 43; +pub const CKK_SHA384_HMAC: CK_KEY_TYPE = 44; +pub const CKK_SHA512_HMAC: CK_KEY_TYPE = 45; +pub const CKK_SHA224_HMAC: CK_KEY_TYPE = 46; +pub const CKK_SEED: CK_KEY_TYPE = 47; +pub const CKK_GOSTR3410: CK_KEY_TYPE = 48; +pub const CKK_GOSTR3411: CK_KEY_TYPE = 49; +pub const CKK_GOST28147: CK_KEY_TYPE = 50; +pub const CKK_EC_EDWARDS: CK_KEY_TYPE = 64; +pub const CKC_X_509: CK_CERTIFICATE_TYPE = 0; +pub const CKC_X_509_ATTR_CERT: CK_CERTIFICATE_TYPE = 1; +pub const CKC_WTLS: CK_CERTIFICATE_TYPE = 2; +pub const CKA_CLASS: CK_ATTRIBUTE_TYPE = 0; +pub const CKA_TOKEN: CK_ATTRIBUTE_TYPE = 1; +pub const CKA_PRIVATE: CK_ATTRIBUTE_TYPE = 2; +pub const CKA_LABEL: CK_ATTRIBUTE_TYPE = 3; +pub const CKA_APPLICATION: CK_ATTRIBUTE_TYPE = 16; +pub const CKA_VALUE: CK_ATTRIBUTE_TYPE = 17; +pub const CKA_OBJECT_ID: CK_ATTRIBUTE_TYPE = 18; +pub const CKA_CERTIFICATE_TYPE: CK_ATTRIBUTE_TYPE = 128; +pub const CKA_ISSUER: CK_ATTRIBUTE_TYPE = 129; +pub const CKA_SERIAL_NUMBER: CK_ATTRIBUTE_TYPE = 130; +pub const CKA_AC_ISSUER: CK_ATTRIBUTE_TYPE = 131; +pub const CKA_OWNER: CK_ATTRIBUTE_TYPE = 132; +pub const CKA_ATTR_TYPES: CK_ATTRIBUTE_TYPE = 133; +pub const CKA_TRUSTED: CK_ATTRIBUTE_TYPE = 134; +pub const CKA_CERTIFICATE_CATEGORY: CK_ATTRIBUTE_TYPE = 135; +pub const CKA_JAVA_MIDP_SECURITY_DOMAIN: CK_ATTRIBUTE_TYPE = 136; +pub const CKA_URL: CK_ATTRIBUTE_TYPE = 137; +pub const CKA_HASH_OF_SUBJECT_PUBLIC_KEY: CK_ATTRIBUTE_TYPE = 138; +pub const CKA_HASH_OF_ISSUER_PUBLIC_KEY: CK_ATTRIBUTE_TYPE = 139; +pub const CKA_NAME_HASH_ALGORITHM: CK_ATTRIBUTE_TYPE = 140; +pub const CKA_CHECK_VALUE: CK_ATTRIBUTE_TYPE = 144; +pub const CKA_KEY_TYPE: CK_ATTRIBUTE_TYPE = 256; +pub const CKA_SUBJECT: CK_ATTRIBUTE_TYPE = 257; +pub const CKA_ID: CK_ATTRIBUTE_TYPE = 258; +pub const CKA_SENSITIVE: CK_ATTRIBUTE_TYPE = 259; +pub const CKA_ENCRYPT: CK_ATTRIBUTE_TYPE = 260; +pub const CKA_DECRYPT: CK_ATTRIBUTE_TYPE = 261; +pub const CKA_WRAP: CK_ATTRIBUTE_TYPE = 262; +pub const CKA_UNWRAP: CK_ATTRIBUTE_TYPE = 263; +pub const CKA_SIGN: CK_ATTRIBUTE_TYPE = 264; +pub const CKA_SIGN_RECOVER: CK_ATTRIBUTE_TYPE = 265; +pub const CKA_VERIFY: CK_ATTRIBUTE_TYPE = 266; +pub const CKA_VERIFY_RECOVER: CK_ATTRIBUTE_TYPE = 267; +pub const CKA_DERIVE: CK_ATTRIBUTE_TYPE = 268; +pub const CKA_START_DATE: CK_ATTRIBUTE_TYPE = 272; +pub const CKA_END_DATE: CK_ATTRIBUTE_TYPE = 273; +pub const CKA_MODULUS: CK_ATTRIBUTE_TYPE = 288; +pub const CKA_MODULUS_BITS: CK_ATTRIBUTE_TYPE = 289; +pub const CKA_PUBLIC_EXPONENT: CK_ATTRIBUTE_TYPE = 290; +pub const CKA_PRIVATE_EXPONENT: CK_ATTRIBUTE_TYPE = 291; +pub const CKA_PRIME_1: CK_ATTRIBUTE_TYPE = 292; +pub const CKA_PRIME_2: CK_ATTRIBUTE_TYPE = 293; +pub const CKA_EXPONENT_1: CK_ATTRIBUTE_TYPE = 294; +pub const CKA_EXPONENT_2: CK_ATTRIBUTE_TYPE = 295; +pub const CKA_COEFFICIENT: CK_ATTRIBUTE_TYPE = 296; +pub const CKA_PUBLIC_KEY_INFO: CK_ATTRIBUTE_TYPE = 297; +pub const CKA_PRIME: CK_ATTRIBUTE_TYPE = 304; +pub const CKA_SUBPRIME: CK_ATTRIBUTE_TYPE = 305; +pub const CKA_BASE: CK_ATTRIBUTE_TYPE = 306; +pub const CKA_PRIME_BITS: CK_ATTRIBUTE_TYPE = 307; +pub const CKA_SUB_PRIME_BITS: CK_ATTRIBUTE_TYPE = 308; +pub const CKA_VALUE_BITS: CK_ATTRIBUTE_TYPE = 352; +pub const CKA_VALUE_LEN: CK_ATTRIBUTE_TYPE = 353; +pub const CKA_EXTRACTABLE: CK_ATTRIBUTE_TYPE = 354; +pub const CKA_LOCAL: CK_ATTRIBUTE_TYPE = 355; +pub const CKA_NEVER_EXTRACTABLE: CK_ATTRIBUTE_TYPE = 356; +pub const CKA_ALWAYS_SENSITIVE: CK_ATTRIBUTE_TYPE = 357; +pub const CKA_KEY_GEN_MECHANISM: CK_ATTRIBUTE_TYPE = 358; +pub const CKA_MODIFIABLE: CK_ATTRIBUTE_TYPE = 368; +pub const CKA_COPYABLE: CK_ATTRIBUTE_TYPE = 369; +pub const CKA_DESTROYABLE: CK_ATTRIBUTE_TYPE = 370; +pub const CKA_ECDSA_PARAMS: CK_ATTRIBUTE_TYPE = 384; +pub const CKA_EC_PARAMS: CK_ATTRIBUTE_TYPE = 384; +pub const CKA_EC_POINT: CK_ATTRIBUTE_TYPE = 385; +pub const CKA_SECONDARY_AUTH: CK_ATTRIBUTE_TYPE = 512; +pub const CKA_AUTH_PIN_FLAGS: CK_ATTRIBUTE_TYPE = 513; +pub const CKA_ALWAYS_AUTHENTICATE: CK_ATTRIBUTE_TYPE = 514; +pub const CKA_WRAP_WITH_TRUSTED: CK_ATTRIBUTE_TYPE = 528; +pub const CKA_OTP_FORMAT: CK_ATTRIBUTE_TYPE = 544; +pub const CKA_OTP_LENGTH: CK_ATTRIBUTE_TYPE = 545; +pub const CKA_OTP_TIME_INTERVAL: CK_ATTRIBUTE_TYPE = 546; +pub const CKA_OTP_USER_FRIENDLY_MODE: CK_ATTRIBUTE_TYPE = 547; +pub const CKA_OTP_CHALLENGE_REQUIREMENT: CK_ATTRIBUTE_TYPE = 548; +pub const CKA_OTP_TIME_REQUIREMENT: CK_ATTRIBUTE_TYPE = 549; +pub const CKA_OTP_COUNTER_REQUIREMENT: CK_ATTRIBUTE_TYPE = 550; +pub const CKA_OTP_PIN_REQUIREMENT: CK_ATTRIBUTE_TYPE = 551; +pub const CKA_OTP_USER_IDENTIFIER: CK_ATTRIBUTE_TYPE = 554; +pub const CKA_OTP_SERVICE_IDENTIFIER: CK_ATTRIBUTE_TYPE = 555; +pub const CKA_OTP_SERVICE_LOGO: CK_ATTRIBUTE_TYPE = 556; +pub const CKA_OTP_SERVICE_LOGO_TYPE: CK_ATTRIBUTE_TYPE = 557; +pub const CKA_OTP_COUNTER: CK_ATTRIBUTE_TYPE = 558; +pub const CKA_OTP_TIME: CK_ATTRIBUTE_TYPE = 559; +pub const CKA_GOSTR3410_PARAMS: CK_ATTRIBUTE_TYPE = 592; +pub const CKA_GOSTR3411_PARAMS: CK_ATTRIBUTE_TYPE = 593; +pub const CKA_GOST28147_PARAMS: CK_ATTRIBUTE_TYPE = 594; +pub const CKA_HW_FEATURE_TYPE: CK_ATTRIBUTE_TYPE = 768; +pub const CKA_RESET_ON_INIT: CK_ATTRIBUTE_TYPE = 769; +pub const CKA_HAS_RESET: CK_ATTRIBUTE_TYPE = 770; +pub const CKA_PIXEL_X: CK_ATTRIBUTE_TYPE = 1024; +pub const CKA_PIXEL_Y: CK_ATTRIBUTE_TYPE = 1025; +pub const CKA_RESOLUTION: CK_ATTRIBUTE_TYPE = 1026; +pub const CKA_CHAR_ROWS: CK_ATTRIBUTE_TYPE = 1027; +pub const CKA_CHAR_COLUMNS: CK_ATTRIBUTE_TYPE = 1028; +pub const CKA_COLOR: CK_ATTRIBUTE_TYPE = 1029; +pub const CKA_BITS_PER_PIXEL: CK_ATTRIBUTE_TYPE = 1030; +pub const CKA_CHAR_SETS: CK_ATTRIBUTE_TYPE = 1152; +pub const CKA_ENCODING_METHODS: CK_ATTRIBUTE_TYPE = 1153; +pub const CKA_MIME_TYPES: CK_ATTRIBUTE_TYPE = 1154; +pub const CKA_MECHANISM_TYPE: CK_ATTRIBUTE_TYPE = 1280; +pub const CKA_REQUIRED_CMS_ATTRIBUTES: CK_ATTRIBUTE_TYPE = 1281; +pub const CKA_DEFAULT_CMS_ATTRIBUTES: CK_ATTRIBUTE_TYPE = 1282; +pub const CKA_SUPPORTED_CMS_ATTRIBUTES: CK_ATTRIBUTE_TYPE = 1283; +pub const CKM_RSA_PKCS_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 0; +pub const CKM_RSA_PKCS: CK_MECHANISM_TYPE = 1; +pub const CKM_RSA_9796: CK_MECHANISM_TYPE = 2; +pub const CKM_RSA_X_509: CK_MECHANISM_TYPE = 3; +pub const CKM_MD2_RSA_PKCS: CK_MECHANISM_TYPE = 4; +pub const CKM_MD5_RSA_PKCS: CK_MECHANISM_TYPE = 5; +pub const CKM_SHA1_RSA_PKCS: CK_MECHANISM_TYPE = 6; +pub const CKM_RIPEMD128_RSA_PKCS: CK_MECHANISM_TYPE = 7; +pub const CKM_RIPEMD160_RSA_PKCS: CK_MECHANISM_TYPE = 8; +pub const CKM_RSA_PKCS_OAEP: CK_MECHANISM_TYPE = 9; +pub const CKM_RSA_X9_31_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 10; +pub const CKM_RSA_X9_31: CK_MECHANISM_TYPE = 11; +pub const CKM_SHA1_RSA_X9_31: CK_MECHANISM_TYPE = 12; +pub const CKM_RSA_PKCS_PSS: CK_MECHANISM_TYPE = 13; +pub const CKM_SHA1_RSA_PKCS_PSS: CK_MECHANISM_TYPE = 14; +pub const CKM_DSA_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 16; +pub const CKM_DSA: CK_MECHANISM_TYPE = 17; +pub const CKM_DSA_SHA1: CK_MECHANISM_TYPE = 18; +pub const CKM_DSA_SHA224: CK_MECHANISM_TYPE = 19; +pub const CKM_DSA_SHA256: CK_MECHANISM_TYPE = 20; +pub const CKM_DSA_SHA384: CK_MECHANISM_TYPE = 21; +pub const CKM_DSA_SHA512: CK_MECHANISM_TYPE = 22; +pub const CKM_DH_PKCS_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 32; +pub const CKM_DH_PKCS_DERIVE: CK_MECHANISM_TYPE = 33; +pub const CKM_X9_42_DH_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 48; +pub const CKM_X9_42_DH_DERIVE: CK_MECHANISM_TYPE = 49; +pub const CKM_X9_42_DH_HYBRID_DERIVE: CK_MECHANISM_TYPE = 50; +pub const CKM_X9_42_MQV_DERIVE: CK_MECHANISM_TYPE = 51; +pub const CKM_SHA256_RSA_PKCS: CK_MECHANISM_TYPE = 64; +pub const CKM_SHA384_RSA_PKCS: CK_MECHANISM_TYPE = 65; +pub const CKM_SHA512_RSA_PKCS: CK_MECHANISM_TYPE = 66; +pub const CKM_SHA256_RSA_PKCS_PSS: CK_MECHANISM_TYPE = 67; +pub const CKM_SHA384_RSA_PKCS_PSS: CK_MECHANISM_TYPE = 68; +pub const CKM_SHA512_RSA_PKCS_PSS: CK_MECHANISM_TYPE = 69; +pub const CKM_SHA512_224: CK_MECHANISM_TYPE = 72; +pub const CKM_SHA512_224_HMAC: CK_MECHANISM_TYPE = 73; +pub const CKM_SHA512_224_HMAC_GENERAL: CK_MECHANISM_TYPE = 74; +pub const CKM_SHA512_224_KEY_DERIVATION: CK_MECHANISM_TYPE = 75; +pub const CKM_SHA512_256: CK_MECHANISM_TYPE = 76; +pub const CKM_SHA512_256_HMAC: CK_MECHANISM_TYPE = 77; +pub const CKM_SHA512_256_HMAC_GENERAL: CK_MECHANISM_TYPE = 78; +pub const CKM_SHA512_256_KEY_DERIVATION: CK_MECHANISM_TYPE = 79; +pub const CKM_SHA512_T: CK_MECHANISM_TYPE = 80; +pub const CKM_SHA512_T_HMAC: CK_MECHANISM_TYPE = 81; +pub const CKM_SHA512_T_HMAC_GENERAL: CK_MECHANISM_TYPE = 82; +pub const CKM_SHA512_T_KEY_DERIVATION: CK_MECHANISM_TYPE = 83; +pub const CKM_RC2_KEY_GEN: CK_MECHANISM_TYPE = 256; +pub const CKM_RC2_ECB: CK_MECHANISM_TYPE = 257; +pub const CKM_RC2_CBC: CK_MECHANISM_TYPE = 258; +pub const CKM_RC2_MAC: CK_MECHANISM_TYPE = 259; +pub const CKM_RC2_MAC_GENERAL: CK_MECHANISM_TYPE = 260; +pub const CKM_RC2_CBC_PAD: CK_MECHANISM_TYPE = 261; +pub const CKM_RC4_KEY_GEN: CK_MECHANISM_TYPE = 272; +pub const CKM_RC4: CK_MECHANISM_TYPE = 273; +pub const CKM_DES_KEY_GEN: CK_MECHANISM_TYPE = 288; +pub const CKM_DES_ECB: CK_MECHANISM_TYPE = 289; +pub const CKM_DES_CBC: CK_MECHANISM_TYPE = 290; +pub const CKM_DES_MAC: CK_MECHANISM_TYPE = 291; +pub const CKM_DES_MAC_GENERAL: CK_MECHANISM_TYPE = 292; +pub const CKM_DES_CBC_PAD: CK_MECHANISM_TYPE = 293; +pub const CKM_DES2_KEY_GEN: CK_MECHANISM_TYPE = 304; +pub const CKM_DES3_KEY_GEN: CK_MECHANISM_TYPE = 305; +pub const CKM_DES3_ECB: CK_MECHANISM_TYPE = 306; +pub const CKM_DES3_CBC: CK_MECHANISM_TYPE = 307; +pub const CKM_DES3_MAC: CK_MECHANISM_TYPE = 308; +pub const CKM_DES3_MAC_GENERAL: CK_MECHANISM_TYPE = 309; +pub const CKM_DES3_CBC_PAD: CK_MECHANISM_TYPE = 310; +pub const CKM_DES3_CMAC_GENERAL: CK_MECHANISM_TYPE = 311; +pub const CKM_DES3_CMAC: CK_MECHANISM_TYPE = 312; +pub const CKM_CDMF_KEY_GEN: CK_MECHANISM_TYPE = 320; +pub const CKM_CDMF_ECB: CK_MECHANISM_TYPE = 321; +pub const CKM_CDMF_CBC: CK_MECHANISM_TYPE = 322; +pub const CKM_CDMF_MAC: CK_MECHANISM_TYPE = 323; +pub const CKM_CDMF_MAC_GENERAL: CK_MECHANISM_TYPE = 324; +pub const CKM_CDMF_CBC_PAD: CK_MECHANISM_TYPE = 325; +pub const CKM_DES_OFB64: CK_MECHANISM_TYPE = 336; +pub const CKM_DES_OFB8: CK_MECHANISM_TYPE = 337; +pub const CKM_DES_CFB64: CK_MECHANISM_TYPE = 338; +pub const CKM_DES_CFB8: CK_MECHANISM_TYPE = 339; +pub const CKM_MD2: CK_MECHANISM_TYPE = 512; +pub const CKM_MD2_HMAC: CK_MECHANISM_TYPE = 513; +pub const CKM_MD2_HMAC_GENERAL: CK_MECHANISM_TYPE = 514; +pub const CKM_MD5: CK_MECHANISM_TYPE = 528; +pub const CKM_MD5_HMAC: CK_MECHANISM_TYPE = 529; +pub const CKM_MD5_HMAC_GENERAL: CK_MECHANISM_TYPE = 530; +pub const CKM_SHA_1: CK_MECHANISM_TYPE = 544; +pub const CKM_SHA_1_HMAC: CK_MECHANISM_TYPE = 545; +pub const CKM_SHA_1_HMAC_GENERAL: CK_MECHANISM_TYPE = 546; +pub const CKM_RIPEMD128: CK_MECHANISM_TYPE = 560; +pub const CKM_RIPEMD128_HMAC: CK_MECHANISM_TYPE = 561; +pub const CKM_RIPEMD128_HMAC_GENERAL: CK_MECHANISM_TYPE = 562; +pub const CKM_RIPEMD160: CK_MECHANISM_TYPE = 576; +pub const CKM_RIPEMD160_HMAC: CK_MECHANISM_TYPE = 577; +pub const CKM_RIPEMD160_HMAC_GENERAL: CK_MECHANISM_TYPE = 578; +pub const CKM_SHA256: CK_MECHANISM_TYPE = 592; +pub const CKM_SHA256_HMAC: CK_MECHANISM_TYPE = 593; +pub const CKM_SHA256_HMAC_GENERAL: CK_MECHANISM_TYPE = 594; +pub const CKM_SHA384: CK_MECHANISM_TYPE = 608; +pub const CKM_SHA384_HMAC: CK_MECHANISM_TYPE = 609; +pub const CKM_SHA384_HMAC_GENERAL: CK_MECHANISM_TYPE = 610; +pub const CKM_SHA512: CK_MECHANISM_TYPE = 624; +pub const CKM_SHA512_HMAC: CK_MECHANISM_TYPE = 625; +pub const CKM_SHA512_HMAC_GENERAL: CK_MECHANISM_TYPE = 626; +pub const CKM_SECURID_KEY_GEN: CK_MECHANISM_TYPE = 640; +pub const CKM_SECURID: CK_MECHANISM_TYPE = 642; +pub const CKM_HOTP_KEY_GEN: CK_MECHANISM_TYPE = 656; +pub const CKM_HOTP: CK_MECHANISM_TYPE = 657; +pub const CKM_ACTI: CK_MECHANISM_TYPE = 672; +pub const CKM_ACTI_KEY_GEN: CK_MECHANISM_TYPE = 673; +pub const CKM_CAST_KEY_GEN: CK_MECHANISM_TYPE = 768; +pub const CKM_CAST_ECB: CK_MECHANISM_TYPE = 769; +pub const CKM_CAST_CBC: CK_MECHANISM_TYPE = 770; +pub const CKM_CAST_MAC: CK_MECHANISM_TYPE = 771; +pub const CKM_CAST_MAC_GENERAL: CK_MECHANISM_TYPE = 772; +pub const CKM_CAST_CBC_PAD: CK_MECHANISM_TYPE = 773; +pub const CKM_CAST3_KEY_GEN: CK_MECHANISM_TYPE = 784; +pub const CKM_CAST3_ECB: CK_MECHANISM_TYPE = 785; +pub const CKM_CAST3_CBC: CK_MECHANISM_TYPE = 786; +pub const CKM_CAST3_MAC: CK_MECHANISM_TYPE = 787; +pub const CKM_CAST3_MAC_GENERAL: CK_MECHANISM_TYPE = 788; +pub const CKM_CAST3_CBC_PAD: CK_MECHANISM_TYPE = 789; +pub const CKM_CAST5_KEY_GEN: CK_MECHANISM_TYPE = 800; +pub const CKM_CAST128_KEY_GEN: CK_MECHANISM_TYPE = 800; +pub const CKM_CAST5_ECB: CK_MECHANISM_TYPE = 801; +pub const CKM_CAST128_ECB: CK_MECHANISM_TYPE = 801; +pub const CKM_CAST5_CBC: CK_MECHANISM_TYPE = 802; +pub const CKM_CAST128_CBC: CK_MECHANISM_TYPE = 802; +pub const CKM_CAST5_MAC: CK_MECHANISM_TYPE = 803; +pub const CKM_CAST128_MAC: CK_MECHANISM_TYPE = 803; +pub const CKM_CAST5_MAC_GENERAL: CK_MECHANISM_TYPE = 804; +pub const CKM_CAST128_MAC_GENERAL: CK_MECHANISM_TYPE = 804; +pub const CKM_CAST5_CBC_PAD: CK_MECHANISM_TYPE = 805; +pub const CKM_CAST128_CBC_PAD: CK_MECHANISM_TYPE = 805; +pub const CKM_RC5_KEY_GEN: CK_MECHANISM_TYPE = 816; +pub const CKM_RC5_ECB: CK_MECHANISM_TYPE = 817; +pub const CKM_RC5_CBC: CK_MECHANISM_TYPE = 818; +pub const CKM_RC5_MAC: CK_MECHANISM_TYPE = 819; +pub const CKM_RC5_MAC_GENERAL: CK_MECHANISM_TYPE = 820; +pub const CKM_RC5_CBC_PAD: CK_MECHANISM_TYPE = 821; +pub const CKM_IDEA_KEY_GEN: CK_MECHANISM_TYPE = 832; +pub const CKM_IDEA_ECB: CK_MECHANISM_TYPE = 833; +pub const CKM_IDEA_CBC: CK_MECHANISM_TYPE = 834; +pub const CKM_IDEA_MAC: CK_MECHANISM_TYPE = 835; +pub const CKM_IDEA_MAC_GENERAL: CK_MECHANISM_TYPE = 836; +pub const CKM_IDEA_CBC_PAD: CK_MECHANISM_TYPE = 837; +pub const CKM_GENERIC_SECRET_KEY_GEN: CK_MECHANISM_TYPE = 848; +pub const CKM_CONCATENATE_BASE_AND_KEY: CK_MECHANISM_TYPE = 864; +pub const CKM_CONCATENATE_BASE_AND_DATA: CK_MECHANISM_TYPE = 866; +pub const CKM_CONCATENATE_DATA_AND_BASE: CK_MECHANISM_TYPE = 867; +pub const CKM_XOR_BASE_AND_DATA: CK_MECHANISM_TYPE = 868; +pub const CKM_EXTRACT_KEY_FROM_KEY: CK_MECHANISM_TYPE = 869; +pub const CKM_SSL3_PRE_MASTER_KEY_GEN: CK_MECHANISM_TYPE = 880; +pub const CKM_SSL3_MASTER_KEY_DERIVE: CK_MECHANISM_TYPE = 881; +pub const CKM_SSL3_KEY_AND_MAC_DERIVE: CK_MECHANISM_TYPE = 882; +pub const CKM_SSL3_MASTER_KEY_DERIVE_DH: CK_MECHANISM_TYPE = 883; +pub const CKM_TLS_PRE_MASTER_KEY_GEN: CK_MECHANISM_TYPE = 884; +pub const CKM_TLS_MASTER_KEY_DERIVE: CK_MECHANISM_TYPE = 885; +pub const CKM_TLS_KEY_AND_MAC_DERIVE: CK_MECHANISM_TYPE = 886; +pub const CKM_TLS_MASTER_KEY_DERIVE_DH: CK_MECHANISM_TYPE = 887; +pub const CKM_TLS_PRF: CK_MECHANISM_TYPE = 888; +pub const CKM_SSL3_MD5_MAC: CK_MECHANISM_TYPE = 896; +pub const CKM_SSL3_SHA1_MAC: CK_MECHANISM_TYPE = 897; +pub const CKM_MD5_KEY_DERIVATION: CK_MECHANISM_TYPE = 912; +pub const CKM_MD2_KEY_DERIVATION: CK_MECHANISM_TYPE = 913; +pub const CKM_SHA1_KEY_DERIVATION: CK_MECHANISM_TYPE = 914; +pub const CKM_SHA256_KEY_DERIVATION: CK_MECHANISM_TYPE = 915; +pub const CKM_SHA384_KEY_DERIVATION: CK_MECHANISM_TYPE = 916; +pub const CKM_SHA512_KEY_DERIVATION: CK_MECHANISM_TYPE = 917; +pub const CKM_PBE_MD2_DES_CBC: CK_MECHANISM_TYPE = 928; +pub const CKM_PBE_MD5_DES_CBC: CK_MECHANISM_TYPE = 929; +pub const CKM_PBE_MD5_CAST_CBC: CK_MECHANISM_TYPE = 930; +pub const CKM_PBE_MD5_CAST3_CBC: CK_MECHANISM_TYPE = 931; +pub const CKM_PBE_MD5_CAST5_CBC: CK_MECHANISM_TYPE = 932; +pub const CKM_PBE_MD5_CAST128_CBC: CK_MECHANISM_TYPE = 932; +pub const CKM_PBE_SHA1_CAST5_CBC: CK_MECHANISM_TYPE = 933; +pub const CKM_PBE_SHA1_CAST128_CBC: CK_MECHANISM_TYPE = 933; +pub const CKM_PBE_SHA1_RC4_128: CK_MECHANISM_TYPE = 934; +pub const CKM_PBE_SHA1_RC4_40: CK_MECHANISM_TYPE = 935; +pub const CKM_PBE_SHA1_DES3_EDE_CBC: CK_MECHANISM_TYPE = 936; +pub const CKM_PBE_SHA1_DES2_EDE_CBC: CK_MECHANISM_TYPE = 937; +pub const CKM_PBE_SHA1_RC2_128_CBC: CK_MECHANISM_TYPE = 938; +pub const CKM_PBE_SHA1_RC2_40_CBC: CK_MECHANISM_TYPE = 939; +pub const CKM_PKCS5_PBKD2: CK_MECHANISM_TYPE = 944; +pub const CKM_PBA_SHA1_WITH_SHA1_HMAC: CK_MECHANISM_TYPE = 960; +pub const CKM_WTLS_PRE_MASTER_KEY_GEN: CK_MECHANISM_TYPE = 976; +pub const CKM_WTLS_MASTER_KEY_DERIVE: CK_MECHANISM_TYPE = 977; +pub const CKM_WTLS_MASTER_KEY_DERIVE_DH_ECC: CK_MECHANISM_TYPE = 978; +pub const CKM_WTLS_PRF: CK_MECHANISM_TYPE = 979; +pub const CKM_WTLS_SERVER_KEY_AND_MAC_DERIVE: CK_MECHANISM_TYPE = 980; +pub const CKM_WTLS_CLIENT_KEY_AND_MAC_DERIVE: CK_MECHANISM_TYPE = 981; +pub const CKM_TLS10_MAC_SERVER: CK_MECHANISM_TYPE = 982; +pub const CKM_TLS10_MAC_CLIENT: CK_MECHANISM_TYPE = 983; +pub const CKM_TLS12_MAC: CK_MECHANISM_TYPE = 984; +pub const CKM_TLS12_KDF: CK_MECHANISM_TYPE = 985; +pub const CKM_TLS12_MASTER_KEY_DERIVE: CK_MECHANISM_TYPE = 992; +pub const CKM_TLS12_KEY_AND_MAC_DERIVE: CK_MECHANISM_TYPE = 993; +pub const CKM_TLS12_MASTER_KEY_DERIVE_DH: CK_MECHANISM_TYPE = 994; +pub const CKM_TLS12_KEY_SAFE_DERIVE: CK_MECHANISM_TYPE = 995; +pub const CKM_TLS_MAC: CK_MECHANISM_TYPE = 996; +pub const CKM_TLS_KDF: CK_MECHANISM_TYPE = 997; +pub const CKM_KEY_WRAP_LYNKS: CK_MECHANISM_TYPE = 1024; +pub const CKM_KEY_WRAP_SET_OAEP: CK_MECHANISM_TYPE = 1025; +pub const CKM_CMS_SIG: CK_MECHANISM_TYPE = 1280; +pub const CKM_KIP_DERIVE: CK_MECHANISM_TYPE = 1296; +pub const CKM_KIP_WRAP: CK_MECHANISM_TYPE = 1297; +pub const CKM_KIP_MAC: CK_MECHANISM_TYPE = 1298; +pub const CKM_CAMELLIA_KEY_GEN: CK_MECHANISM_TYPE = 1360; +pub const CKM_CAMELLIA_CTR: CK_MECHANISM_TYPE = 1368; +pub const CKM_ARIA_KEY_GEN: CK_MECHANISM_TYPE = 1376; +pub const CKM_ARIA_ECB: CK_MECHANISM_TYPE = 1377; +pub const CKM_ARIA_CBC: CK_MECHANISM_TYPE = 1378; +pub const CKM_ARIA_MAC: CK_MECHANISM_TYPE = 1379; +pub const CKM_ARIA_MAC_GENERAL: CK_MECHANISM_TYPE = 1380; +pub const CKM_ARIA_CBC_PAD: CK_MECHANISM_TYPE = 1381; +pub const CKM_ARIA_ECB_ENCRYPT_DATA: CK_MECHANISM_TYPE = 1382; +pub const CKM_ARIA_CBC_ENCRYPT_DATA: CK_MECHANISM_TYPE = 1383; +pub const CKM_SEED_KEY_GEN: CK_MECHANISM_TYPE = 1616; +pub const CKM_SEED_ECB: CK_MECHANISM_TYPE = 1617; +pub const CKM_SEED_CBC: CK_MECHANISM_TYPE = 1618; +pub const CKM_SEED_MAC: CK_MECHANISM_TYPE = 1619; +pub const CKM_SEED_MAC_GENERAL: CK_MECHANISM_TYPE = 1620; +pub const CKM_SEED_CBC_PAD: CK_MECHANISM_TYPE = 1621; +pub const CKM_SEED_ECB_ENCRYPT_DATA: CK_MECHANISM_TYPE = 1622; +pub const CKM_SEED_CBC_ENCRYPT_DATA: CK_MECHANISM_TYPE = 1623; +pub const CKM_SKIPJACK_KEY_GEN: CK_MECHANISM_TYPE = 4096; +pub const CKM_SKIPJACK_ECB64: CK_MECHANISM_TYPE = 4097; +pub const CKM_SKIPJACK_CBC64: CK_MECHANISM_TYPE = 4098; +pub const CKM_SKIPJACK_OFB64: CK_MECHANISM_TYPE = 4099; +pub const CKM_SKIPJACK_CFB64: CK_MECHANISM_TYPE = 4100; +pub const CKM_SKIPJACK_CFB32: CK_MECHANISM_TYPE = 4101; +pub const CKM_SKIPJACK_CFB16: CK_MECHANISM_TYPE = 4102; +pub const CKM_SKIPJACK_CFB8: CK_MECHANISM_TYPE = 4103; +pub const CKM_SKIPJACK_WRAP: CK_MECHANISM_TYPE = 4104; +pub const CKM_SKIPJACK_PRIVATE_WRAP: CK_MECHANISM_TYPE = 4105; +pub const CKM_SKIPJACK_RELAYX: CK_MECHANISM_TYPE = 4106; +pub const CKM_KEA_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 4112; +pub const CKM_KEA_KEY_DERIVE: CK_MECHANISM_TYPE = 4113; +pub const CKM_FORTEZZA_TIMESTAMP: CK_MECHANISM_TYPE = 4128; +pub const CKM_BATON_KEY_GEN: CK_MECHANISM_TYPE = 4144; +pub const CKM_BATON_ECB128: CK_MECHANISM_TYPE = 4145; +pub const CKM_BATON_ECB96: CK_MECHANISM_TYPE = 4146; +pub const CKM_BATON_CBC128: CK_MECHANISM_TYPE = 4147; +pub const CKM_BATON_COUNTER: CK_MECHANISM_TYPE = 4148; +pub const CKM_BATON_SHUFFLE: CK_MECHANISM_TYPE = 4149; +pub const CKM_BATON_WRAP: CK_MECHANISM_TYPE = 4150; +pub const CKM_ECDSA_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 4160; +pub const CKM_EC_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 4160; +pub const CKM_ECDSA: CK_MECHANISM_TYPE = 4161; +pub const CKM_ECDSA_SHA1: CK_MECHANISM_TYPE = 4162; +pub const CKM_ECDSA_SHA224: CK_MECHANISM_TYPE = 4163; +pub const CKM_ECDSA_SHA256: CK_MECHANISM_TYPE = 4164; +pub const CKM_ECDSA_SHA384: CK_MECHANISM_TYPE = 4165; +pub const CKM_ECDSA_SHA512: CK_MECHANISM_TYPE = 4166; +pub const CKM_ECDH1_DERIVE: CK_MECHANISM_TYPE = 4176; +pub const CKM_ECDH1_COFACTOR_DERIVE: CK_MECHANISM_TYPE = 4177; +pub const CKM_ECMQV_DERIVE: CK_MECHANISM_TYPE = 4178; +pub const CKM_ECDH_AES_KEY_WRAP: CK_MECHANISM_TYPE = 4179; +pub const CKM_RSA_AES_KEY_WRAP: CK_MECHANISM_TYPE = 4180; +pub const CKM_JUNIPER_KEY_GEN: CK_MECHANISM_TYPE = 4192; +pub const CKM_JUNIPER_ECB128: CK_MECHANISM_TYPE = 4193; +pub const CKM_JUNIPER_CBC128: CK_MECHANISM_TYPE = 4194; +pub const CKM_JUNIPER_COUNTER: CK_MECHANISM_TYPE = 4195; +pub const CKM_JUNIPER_SHUFFLE: CK_MECHANISM_TYPE = 4196; +pub const CKM_JUNIPER_WRAP: CK_MECHANISM_TYPE = 4197; +pub const CKM_FASTHASH: CK_MECHANISM_TYPE = 4208; +pub const CKM_AES_KEY_GEN: CK_MECHANISM_TYPE = 4224; +pub const CKM_AES_ECB: CK_MECHANISM_TYPE = 4225; +pub const CKM_AES_CBC: CK_MECHANISM_TYPE = 4226; +pub const CKM_AES_MAC: CK_MECHANISM_TYPE = 4227; +pub const CKM_AES_MAC_GENERAL: CK_MECHANISM_TYPE = 4228; +pub const CKM_AES_CBC_PAD: CK_MECHANISM_TYPE = 4229; +pub const CKM_AES_CTR: CK_MECHANISM_TYPE = 4230; +pub const CKM_AES_GCM: CK_MECHANISM_TYPE = 4231; +pub const CKM_AES_CCM: CK_MECHANISM_TYPE = 4232; +pub const CKM_AES_CTS: CK_MECHANISM_TYPE = 4233; +pub const CKM_AES_CMAC: CK_MECHANISM_TYPE = 4234; +pub const CKM_AES_CMAC_GENERAL: CK_MECHANISM_TYPE = 4235; +pub const CKM_AES_XCBC_MAC: CK_MECHANISM_TYPE = 4236; +pub const CKM_AES_XCBC_MAC_96: CK_MECHANISM_TYPE = 4237; +pub const CKM_AES_GMAC: CK_MECHANISM_TYPE = 4238; +pub const CKM_BLOWFISH_KEY_GEN: CK_MECHANISM_TYPE = 4240; +pub const CKM_BLOWFISH_CBC: CK_MECHANISM_TYPE = 4241; +pub const CKM_TWOFISH_KEY_GEN: CK_MECHANISM_TYPE = 4242; +pub const CKM_TWOFISH_CBC: CK_MECHANISM_TYPE = 4243; +pub const CKM_BLOWFISH_CBC_PAD: CK_MECHANISM_TYPE = 4244; +pub const CKM_TWOFISH_CBC_PAD: CK_MECHANISM_TYPE = 4245; +pub const CKM_DES_ECB_ENCRYPT_DATA: CK_MECHANISM_TYPE = 4352; +pub const CKM_DES_CBC_ENCRYPT_DATA: CK_MECHANISM_TYPE = 4353; +pub const CKM_DES3_ECB_ENCRYPT_DATA: CK_MECHANISM_TYPE = 4354; +pub const CKM_DES3_CBC_ENCRYPT_DATA: CK_MECHANISM_TYPE = 4355; +pub const CKM_AES_ECB_ENCRYPT_DATA: CK_MECHANISM_TYPE = 4356; +pub const CKM_AES_CBC_ENCRYPT_DATA: CK_MECHANISM_TYPE = 4357; +pub const CKM_GOSTR3410_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 4608; +pub const CKM_GOSTR3410: CK_MECHANISM_TYPE = 4609; +pub const CKM_GOSTR3410_WITH_GOSTR3411: CK_MECHANISM_TYPE = 4610; +pub const CKM_GOSTR3410_KEY_WRAP: CK_MECHANISM_TYPE = 4611; +pub const CKM_GOSTR3410_DERIVE: CK_MECHANISM_TYPE = 4612; +pub const CKM_GOSTR3411: CK_MECHANISM_TYPE = 4624; +pub const CKM_GOSTR3411_HMAC: CK_MECHANISM_TYPE = 4625; +pub const CKM_GOST28147_KEY_GEN: CK_MECHANISM_TYPE = 4640; +pub const CKM_GOST28147_ECB: CK_MECHANISM_TYPE = 4641; +pub const CKM_GOST28147: CK_MECHANISM_TYPE = 4642; +pub const CKM_GOST28147_MAC: CK_MECHANISM_TYPE = 4643; +pub const CKM_GOST28147_KEY_WRAP: CK_MECHANISM_TYPE = 4644; +pub const CKM_DSA_PARAMETER_GEN: CK_MECHANISM_TYPE = 8192; +pub const CKM_DH_PKCS_PARAMETER_GEN: CK_MECHANISM_TYPE = 8193; +pub const CKM_X9_42_DH_PARAMETER_GEN: CK_MECHANISM_TYPE = 8194; +pub const CKM_DSA_PROBABLISTIC_PARAMETER_GEN: CK_MECHANISM_TYPE = 8195; +pub const CKM_DSA_SHAWE_TAYLOR_PARAMETER_GEN: CK_MECHANISM_TYPE = 8196; +pub const CKM_AES_OFB: CK_MECHANISM_TYPE = 8452; +pub const CKM_AES_CFB64: CK_MECHANISM_TYPE = 8453; +pub const CKM_AES_CFB8: CK_MECHANISM_TYPE = 8454; +pub const CKM_AES_CFB128: CK_MECHANISM_TYPE = 8455; +pub const CKM_AES_CFB1: CK_MECHANISM_TYPE = 8456; +pub const CKM_SHA224: CK_MECHANISM_TYPE = 597; +pub const CKM_SHA224_HMAC: CK_MECHANISM_TYPE = 598; +pub const CKM_SHA224_HMAC_GENERAL: CK_MECHANISM_TYPE = 599; +pub const CKM_SHA224_RSA_PKCS: CK_MECHANISM_TYPE = 70; +pub const CKM_SHA224_RSA_PKCS_PSS: CK_MECHANISM_TYPE = 71; +pub const CKM_SHA224_KEY_DERIVATION: CK_MECHANISM_TYPE = 918; +pub const CKM_CAMELLIA_ECB: CK_MECHANISM_TYPE = 1361; +pub const CKM_CAMELLIA_CBC: CK_MECHANISM_TYPE = 1362; +pub const CKM_CAMELLIA_MAC: CK_MECHANISM_TYPE = 1363; +pub const CKM_CAMELLIA_MAC_GENERAL: CK_MECHANISM_TYPE = 1364; +pub const CKM_CAMELLIA_CBC_PAD: CK_MECHANISM_TYPE = 1365; +pub const CKM_CAMELLIA_ECB_ENCRYPT_DATA: CK_MECHANISM_TYPE = 1366; +pub const CKM_CAMELLIA_CBC_ENCRYPT_DATA: CK_MECHANISM_TYPE = 1367; +pub const CKM_AES_KEY_WRAP: CK_MECHANISM_TYPE = 8457; +pub const CKM_AES_KEY_WRAP_PAD: CK_MECHANISM_TYPE = 8458; +pub const CKM_RSA_PKCS_TPM_1_1: CK_MECHANISM_TYPE = 16385; +pub const CKM_RSA_PKCS_OAEP_TPM_1_1: CK_MECHANISM_TYPE = 16386; +pub const CKM_EC_EDWARDS_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 4181; +pub const CKM_EC_MONTGOMERY_KEY_PAIR_GEN: CK_MECHANISM_TYPE = 4182; +pub const CKM_EDDSA: CK_MECHANISM_TYPE = 4183; +pub const CK_OTP_FORMAT_DECIMAL: CK_ULONG = 0; +pub const CK_OTP_FORMAT_HEXADECIMAL: CK_ULONG = 1; +pub const CK_OTP_FORMAT_ALPHANUMERIC: CK_ULONG = 2; +pub const CK_OTP_FORMAT_BINARY: CK_ULONG = 3; +pub const CK_OTP_PARAM_IGNORED: CK_ULONG = 0; +pub const CK_OTP_PARAM_OPTIONAL: CK_ULONG = 1; +pub const CK_OTP_PARAM_MANDATORY: CK_ULONG = 2; +pub const CK_OTP_VALUE: CK_ULONG = 0; +pub const CK_OTP_PIN: CK_ULONG = 1; +pub const CK_OTP_CHALLENGE: CK_ULONG = 2; +pub const CK_OTP_TIME: CK_ULONG = 3; +pub const CK_OTP_COUNTER: CK_ULONG = 4; +pub const CK_OTP_FLAGS: CK_ULONG = 5; +pub const CK_OTP_OUTPUT_LENGTH: CK_ULONG = 6; +pub const CK_OTP_FORMAT: CK_ULONG = 7; +pub const CKF_NEXT_OTP: CK_FLAGS = 1; +pub const CKF_EXCLUDE_TIME: CK_FLAGS = 2; +pub const CKF_EXCLUDE_COUNTER: CK_FLAGS = 4; +pub const CKF_EXCLUDE_CHALLENGE: CK_FLAGS = 8; +pub const CKF_EXCLUDE_PIN: CK_FLAGS = 16; +pub const CKF_USER_FRIENDLY_OTP: CK_FLAGS = 32; +pub const CKN_OTP_CHANGED: CK_NOTIFICATION = 1; +pub const CKG_MGF1_SHA1: CK_RSA_PKCS_MGF_TYPE = 1; +pub const CKG_MGF1_SHA224: CK_RSA_PKCS_MGF_TYPE = 5; +pub const CKG_MGF1_SHA256: CK_RSA_PKCS_MGF_TYPE = 2; +pub const CKG_MGF1_SHA384: CK_RSA_PKCS_MGF_TYPE = 3; +pub const CKG_MGF1_SHA512: CK_RSA_PKCS_MGF_TYPE = 4; +pub const CKD_NULL: CK_EC_KDF_TYPE = 1; +pub const CKD_SHA1_KDF: CK_EC_KDF_TYPE = 2; +pub const CKD_SHA1_KDF_ASN1: CK_EC_KDF_TYPE = 3; +pub const CKD_SHA1_KDF_CONCATENATE: CK_EC_KDF_TYPE = 4; +pub const CKD_SHA224_KDF: CK_EC_KDF_TYPE = 5; +pub const CKD_SHA256_KDF: CK_EC_KDF_TYPE = 6; +pub const CKD_SHA384_KDF: CK_EC_KDF_TYPE = 7; +pub const CKD_SHA512_KDF: CK_EC_KDF_TYPE = 8; +pub const CKD_CPDIVERSIFY_KDF: CK_EC_KDF_TYPE = 9; +pub const CKF_HW: CK_FLAGS = 1; +pub const CKF_ENCRYPT: CK_FLAGS = 256; +pub const CKF_DECRYPT: CK_FLAGS = 512; +pub const CKF_DIGEST: CK_FLAGS = 1024; +pub const CKF_SIGN: CK_FLAGS = 2048; +pub const CKF_SIGN_RECOVER: CK_FLAGS = 4096; +pub const CKF_VERIFY: CK_FLAGS = 8192; +pub const CKF_VERIFY_RECOVER: CK_FLAGS = 16384; +pub const CKF_GENERATE: CK_FLAGS = 32768; +pub const CKF_GENERATE_KEY_PAIR: CK_FLAGS = 65536; +pub const CKF_WRAP: CK_FLAGS = 131072; +pub const CKF_UNWRAP: CK_FLAGS = 262144; +pub const CKF_DERIVE: CK_FLAGS = 524288; +pub const CKF_EC_F_P: CK_FLAGS = 1048576; +pub const CKF_EC_F_2M: CK_FLAGS = 2097152; +pub const CKF_EC_ECPARAMETERS: CK_FLAGS = 4194304; +pub const CKF_EC_NAMEDCURVE: CK_FLAGS = 8388608; +pub const CKF_EC_UNCOMPRESS: CK_FLAGS = 16777216; +pub const CKF_EC_COMPRESS: CK_FLAGS = 33554432; +pub const CKF_DONT_BLOCK: CK_FLAGS = 1; +pub const CKF_LIBRARY_CANT_CREATE_OS_THREADS: CK_FLAGS = 1; +pub const CKF_OS_LOCKING_OK: CK_FLAGS = 2; +pub const CKR_OK: CK_RV = 0; +pub const CKR_CANCEL: CK_RV = 1; +pub const CKR_HOST_MEMORY: CK_RV = 2; +pub const CKR_SLOT_ID_INVALID: CK_RV = 3; +pub const CKR_GENERAL_ERROR: CK_RV = 5; +pub const CKR_FUNCTION_FAILED: CK_RV = 6; +pub const CKR_ARGUMENTS_BAD: CK_RV = 7; +pub const CKR_NO_EVENT: CK_RV = 8; +pub const CKR_NEED_TO_CREATE_THREADS: CK_RV = 9; +pub const CKR_CANT_LOCK: CK_RV = 10; +pub const CKR_ATTRIBUTE_READ_ONLY: CK_RV = 16; +pub const CKR_ATTRIBUTE_SENSITIVE: CK_RV = 17; +pub const CKR_ATTRIBUTE_TYPE_INVALID: CK_RV = 18; +pub const CKR_ATTRIBUTE_VALUE_INVALID: CK_RV = 19; +pub const CKR_ACTION_PROHIBITED: CK_RV = 27; +pub const CKR_DATA_INVALID: CK_RV = 32; +pub const CKR_DATA_LEN_RANGE: CK_RV = 33; +pub const CKR_DEVICE_ERROR: CK_RV = 48; +pub const CKR_DEVICE_MEMORY: CK_RV = 49; +pub const CKR_DEVICE_REMOVED: CK_RV = 50; +pub const CKR_ENCRYPTED_DATA_INVALID: CK_RV = 64; +pub const CKR_ENCRYPTED_DATA_LEN_RANGE: CK_RV = 65; +pub const CKR_FUNCTION_CANCELED: CK_RV = 80; +pub const CKR_FUNCTION_NOT_PARALLEL: CK_RV = 81; +pub const CKR_FUNCTION_NOT_SUPPORTED: CK_RV = 84; +pub const CKR_KEY_HANDLE_INVALID: CK_RV = 96; +pub const CKR_KEY_SIZE_RANGE: CK_RV = 98; +pub const CKR_KEY_TYPE_INCONSISTENT: CK_RV = 99; +pub const CKR_KEY_NOT_NEEDED: CK_RV = 100; +pub const CKR_KEY_CHANGED: CK_RV = 101; +pub const CKR_KEY_NEEDED: CK_RV = 102; +pub const CKR_KEY_INDIGESTIBLE: CK_RV = 103; +pub const CKR_KEY_FUNCTION_NOT_PERMITTED: CK_RV = 104; +pub const CKR_KEY_NOT_WRAPPABLE: CK_RV = 105; +pub const CKR_KEY_UNEXTRACTABLE: CK_RV = 106; +pub const CKR_MECHANISM_INVALID: CK_RV = 112; +pub const CKR_MECHANISM_PARAM_INVALID: CK_RV = 113; +pub const CKR_OBJECT_HANDLE_INVALID: CK_RV = 130; +pub const CKR_OPERATION_ACTIVE: CK_RV = 144; +pub const CKR_OPERATION_NOT_INITIALIZED: CK_RV = 145; +pub const CKR_PIN_INCORRECT: CK_RV = 160; +pub const CKR_PIN_INVALID: CK_RV = 161; +pub const CKR_PIN_LEN_RANGE: CK_RV = 162; +pub const CKR_PIN_EXPIRED: CK_RV = 163; +pub const CKR_PIN_LOCKED: CK_RV = 164; +pub const CKR_SESSION_CLOSED: CK_RV = 176; +pub const CKR_SESSION_COUNT: CK_RV = 177; +pub const CKR_SESSION_HANDLE_INVALID: CK_RV = 179; +pub const CKR_SESSION_PARALLEL_NOT_SUPPORTED: CK_RV = 180; +pub const CKR_SESSION_READ_ONLY: CK_RV = 181; +pub const CKR_SESSION_EXISTS: CK_RV = 182; +pub const CKR_SESSION_READ_ONLY_EXISTS: CK_RV = 183; +pub const CKR_SESSION_READ_WRITE_SO_EXISTS: CK_RV = 184; +pub const CKR_SIGNATURE_INVALID: CK_RV = 192; +pub const CKR_SIGNATURE_LEN_RANGE: CK_RV = 193; +pub const CKR_TEMPLATE_INCOMPLETE: CK_RV = 208; +pub const CKR_TEMPLATE_INCONSISTENT: CK_RV = 209; +pub const CKR_TOKEN_NOT_PRESENT: CK_RV = 224; +pub const CKR_TOKEN_NOT_RECOGNIZED: CK_RV = 225; +pub const CKR_TOKEN_WRITE_PROTECTED: CK_RV = 226; +pub const CKR_UNWRAPPING_KEY_HANDLE_INVALID: CK_RV = 240; +pub const CKR_UNWRAPPING_KEY_SIZE_RANGE: CK_RV = 241; +pub const CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT: CK_RV = 242; +pub const CKR_USER_ALREADY_LOGGED_IN: CK_RV = 256; +pub const CKR_USER_NOT_LOGGED_IN: CK_RV = 257; +pub const CKR_USER_PIN_NOT_INITIALIZED: CK_RV = 258; +pub const CKR_USER_TYPE_INVALID: CK_RV = 259; +pub const CKR_USER_ANOTHER_ALREADY_LOGGED_IN: CK_RV = 260; +pub const CKR_USER_TOO_MANY_TYPES: CK_RV = 261; +pub const CKR_WRAPPED_KEY_INVALID: CK_RV = 272; +pub const CKR_WRAPPED_KEY_LEN_RANGE: CK_RV = 274; +pub const CKR_WRAPPING_KEY_HANDLE_INVALID: CK_RV = 275; +pub const CKR_WRAPPING_KEY_SIZE_RANGE: CK_RV = 276; +pub const CKR_WRAPPING_KEY_TYPE_INCONSISTENT: CK_RV = 277; +pub const CKR_RANDOM_SEED_NOT_SUPPORTED: CK_RV = 288; +pub const CKR_RANDOM_NO_RNG: CK_RV = 289; +pub const CKR_DOMAIN_PARAMS_INVALID: CK_RV = 304; +pub const CKR_BUFFER_TOO_SMALL: CK_RV = 336; +pub const CKR_SAVED_STATE_INVALID: CK_RV = 352; +pub const CKR_INFORMATION_SENSITIVE: CK_RV = 368; +pub const CKR_STATE_UNSAVEABLE: CK_RV = 384; +pub const CKR_CRYPTOKI_NOT_INITIALIZED: CK_RV = 400; +pub const CKR_CRYPTOKI_ALREADY_INITIALIZED: CK_RV = 401; +pub const CKR_MUTEX_BAD: CK_RV = 416; +pub const CKR_MUTEX_NOT_LOCKED: CK_RV = 417; +pub const CKR_NEW_PIN_MODE: CK_RV = 432; +pub const CKR_NEXT_OTP: CK_RV = 433; +pub const CKR_EXCEEDED_MAX_ITERATIONS: CK_RV = 448; +pub const CKR_FIPS_SELF_TEST_FAILED: CK_RV = 449; +pub const CKR_LIBRARY_LOAD_FAILED: CK_RV = 450; +pub const CKR_PIN_TOO_WEAK: CK_RV = 451; +pub const CKR_PUBLIC_KEY_INVALID: CK_RV = 452; +pub const CKR_FUNCTION_REJECTED: CK_RV = 512; +pub const CKZ_DATA_SPECIFIED: CK_RSA_PKCS_OAEP_SOURCE_TYPE = 1; +pub const CK_FALSE: CK_BBOOL = 0; +pub const CK_TRUE: CK_BBOOL = 1; +pub const FALSE: u32 = 0; +pub const TRUE: u32 = 1; +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, +} +#[repr(C)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +pub type CK_NOTIFICATION = ::std::os::raw::c_ulong; +pub const CKN_SURRENDER: ::std::os::raw::c_ulong = 0; +pub type CK_SLOT_ID = ::std::os::raw::c_ulong; +#[repr(C)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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() + } + } +} +pub const CKF_TOKEN_PRESENT: ::std::os::raw::c_ulong = 1; +pub const CKF_REMOVABLE_DEVICE: ::std::os::raw::c_ulong = 2; +pub const CKF_HW_SLOT: ::std::os::raw::c_ulong = 4; +pub const CKF_ARRAY_ATTRIBUTE: ::std::os::raw::c_ulong = 1073741824; +#[repr(C)] +#[cfg_attr(windows, repr(packed))] +#[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], +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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], +} +pub type CK_MECHANISM_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +pub type CK_PARAM_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[derive(Debug, Copy, Clone)] +pub struct CK_OTP_PARAMS { + pub pParams: *mut CK_OTP_PARAM, + pub ulCount: ::std::os::raw::c_ulong, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[derive(Debug, Copy, Clone)] +pub struct CK_OTP_SIGNATURE_INFO { + pub pParams: *mut CK_OTP_PARAM, + pub ulCount: ::std::os::raw::c_ulong, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +pub type CK_RSA_PKCS_OAEP_SOURCE_TYPE = ::std::os::raw::c_ulong; +#[repr(C)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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], +} +#[repr(C)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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)] +#[cfg_attr(windows, repr(packed))] +#[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, +} +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 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_Initialize: Result< + unsafe extern "C" fn(init_args: *mut ::std::os::raw::c_void) -> CK_RV, + ::libloading::Error, + >, + pub C_Finalize: Result< + unsafe extern "C" fn(pReserved: *mut ::std::os::raw::c_void) -> CK_RV, + ::libloading::Error, + >, + pub C_GetInfo: Result CK_RV, ::libloading::Error>, + pub C_GetFunctionList: Result< + unsafe extern "C" fn(function_list: *mut *mut _CK_FUNCTION_LIST) -> CK_RV, + ::libloading::Error, + >, + pub C_GetSlotList: Result< + 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, + ::libloading::Error, + >, + pub C_GetSlotInfo: Result< + unsafe extern "C" fn(slotID: CK_SLOT_ID, info: *mut _CK_SLOT_INFO) -> CK_RV, + ::libloading::Error, + >, + pub C_GetTokenInfo: Result< + unsafe extern "C" fn(slotID: CK_SLOT_ID, info: *mut _CK_TOKEN_INFO) -> CK_RV, + ::libloading::Error, + >, + pub C_WaitForSlotEvent: Result< + unsafe extern "C" fn( + flags: CK_FLAGS, + slot: *mut CK_SLOT_ID, + pReserved: *mut ::std::os::raw::c_void, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_GetMechanismList: Result< + unsafe extern "C" fn( + slotID: CK_SLOT_ID, + mechanism_list: *mut CK_MECHANISM_TYPE, + ulCount: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_GetMechanismInfo: Result< + unsafe extern "C" fn( + slotID: CK_SLOT_ID, + type_: CK_MECHANISM_TYPE, + info: *mut _CK_MECHANISM_INFO, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_InitToken: Result< + 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, + ::libloading::Error, + >, + pub C_InitPIN: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + pin: *mut ::std::os::raw::c_uchar, + pin_len: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_SetPIN: Result< + 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, + ::libloading::Error, + >, + pub C_OpenSession: Result< + 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, + ::libloading::Error, + >, + pub C_CloseSession: + Result CK_RV, ::libloading::Error>, + pub C_CloseAllSessions: + Result CK_RV, ::libloading::Error>, + pub C_GetSessionInfo: Result< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, info: *mut _CK_SESSION_INFO) -> CK_RV, + ::libloading::Error, + >, + pub C_GetOperationState: Result< + 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, + ::libloading::Error, + >, + pub C_SetOperationState: Result< + 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, + ::libloading::Error, + >, + pub C_Login: Result< + 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, + ::libloading::Error, + >, + pub C_Logout: + Result CK_RV, ::libloading::Error>, + pub C_CreateObject: Result< + 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, + ::libloading::Error, + >, + pub C_CopyObject: Result< + 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, + ::libloading::Error, + >, + pub C_DestroyObject: Result< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, object: CK_OBJECT_HANDLE) -> CK_RV, + ::libloading::Error, + >, + pub C_GetObjectSize: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + size: *mut ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_GetAttributeValue: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_SetAttributeValue: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_FindObjectsInit: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_FindObjects: Result< + 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, + ::libloading::Error, + >, + pub C_FindObjectsFinal: + Result CK_RV, ::libloading::Error>, + pub C_EncryptInit: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_Encrypt: Result< + 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, + ::libloading::Error, + >, + pub C_EncryptUpdate: Result< + 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, + ::libloading::Error, + >, + pub C_EncryptFinal: Result< + 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, + ::libloading::Error, + >, + pub C_DecryptInit: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_Decrypt: Result< + 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, + ::libloading::Error, + >, + pub C_DecryptUpdate: Result< + 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, + ::libloading::Error, + >, + pub C_DecryptFinal: Result< + 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, + ::libloading::Error, + >, + pub C_DigestInit: Result< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, mechanism: *mut _CK_MECHANISM) -> CK_RV, + ::libloading::Error, + >, + pub C_Digest: Result< + 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, + ::libloading::Error, + >, + pub C_DigestUpdate: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_DigestKey: Result< + unsafe extern "C" fn(session: CK_SESSION_HANDLE, key: CK_OBJECT_HANDLE) -> CK_RV, + ::libloading::Error, + >, + pub C_DigestFinal: Result< + 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, + ::libloading::Error, + >, + pub C_SignInit: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_Sign: Result< + 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, + ::libloading::Error, + >, + pub C_SignUpdate: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_SignFinal: Result< + 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, + ::libloading::Error, + >, + pub C_SignRecoverInit: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_SignRecover: Result< + 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, + ::libloading::Error, + >, + pub C_VerifyInit: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_Verify: Result< + 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, + ::libloading::Error, + >, + pub C_VerifyUpdate: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_VerifyFinal: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + signature: *mut ::std::os::raw::c_uchar, + signature_len: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_VerifyRecoverInit: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_VerifyRecover: Result< + 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, + ::libloading::Error, + >, + pub C_DigestEncryptUpdate: Result< + 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, + ::libloading::Error, + >, + pub C_DecryptDigestUpdate: Result< + 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, + ::libloading::Error, + >, + pub C_SignEncryptUpdate: Result< + 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, + ::libloading::Error, + >, + pub C_DecryptVerifyUpdate: Result< + 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, + ::libloading::Error, + >, + pub C_GenerateKey: Result< + 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, + ::libloading::Error, + >, + pub C_GenerateKeyPair: Result< + 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, + ::libloading::Error, + >, + pub C_WrapKey: Result< + 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, + ::libloading::Error, + >, + pub C_UnwrapKey: Result< + 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, + ::libloading::Error, + >, + pub C_DeriveKey: Result< + 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, + ::libloading::Error, + >, + pub C_SeedRandom: Result< + unsafe extern "C" fn( + session: CK_SESSION_HANDLE, + seed: *mut ::std::os::raw::c_uchar, + seed_len: ::std::os::raw::c_ulong, + ) -> CK_RV, + ::libloading::Error, + >, + pub C_GenerateRandom: Result< + 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, + ::libloading::Error, + >, + pub C_GetFunctionStatus: + Result CK_RV, ::libloading::Error>, + pub C_CancelFunction: + Result 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_Initialize = __library.get(b"C_Initialize\0").map(|sym| *sym); + let C_Finalize = __library.get(b"C_Finalize\0").map(|sym| *sym); + let C_GetInfo = __library.get(b"C_GetInfo\0").map(|sym| *sym); + let C_GetFunctionList = __library.get(b"C_GetFunctionList\0").map(|sym| *sym); + let C_GetSlotList = __library.get(b"C_GetSlotList\0").map(|sym| *sym); + let C_GetSlotInfo = __library.get(b"C_GetSlotInfo\0").map(|sym| *sym); + let C_GetTokenInfo = __library.get(b"C_GetTokenInfo\0").map(|sym| *sym); + let C_WaitForSlotEvent = __library.get(b"C_WaitForSlotEvent\0").map(|sym| *sym); + let C_GetMechanismList = __library.get(b"C_GetMechanismList\0").map(|sym| *sym); + let C_GetMechanismInfo = __library.get(b"C_GetMechanismInfo\0").map(|sym| *sym); + let C_InitToken = __library.get(b"C_InitToken\0").map(|sym| *sym); + let C_InitPIN = __library.get(b"C_InitPIN\0").map(|sym| *sym); + let C_SetPIN = __library.get(b"C_SetPIN\0").map(|sym| *sym); + let C_OpenSession = __library.get(b"C_OpenSession\0").map(|sym| *sym); + let C_CloseSession = __library.get(b"C_CloseSession\0").map(|sym| *sym); + let C_CloseAllSessions = __library.get(b"C_CloseAllSessions\0").map(|sym| *sym); + let C_GetSessionInfo = __library.get(b"C_GetSessionInfo\0").map(|sym| *sym); + let C_GetOperationState = __library.get(b"C_GetOperationState\0").map(|sym| *sym); + let C_SetOperationState = __library.get(b"C_SetOperationState\0").map(|sym| *sym); + let C_Login = __library.get(b"C_Login\0").map(|sym| *sym); + let C_Logout = __library.get(b"C_Logout\0").map(|sym| *sym); + let C_CreateObject = __library.get(b"C_CreateObject\0").map(|sym| *sym); + let C_CopyObject = __library.get(b"C_CopyObject\0").map(|sym| *sym); + let C_DestroyObject = __library.get(b"C_DestroyObject\0").map(|sym| *sym); + let C_GetObjectSize = __library.get(b"C_GetObjectSize\0").map(|sym| *sym); + let C_GetAttributeValue = __library.get(b"C_GetAttributeValue\0").map(|sym| *sym); + let C_SetAttributeValue = __library.get(b"C_SetAttributeValue\0").map(|sym| *sym); + let C_FindObjectsInit = __library.get(b"C_FindObjectsInit\0").map(|sym| *sym); + let C_FindObjects = __library.get(b"C_FindObjects\0").map(|sym| *sym); + let C_FindObjectsFinal = __library.get(b"C_FindObjectsFinal\0").map(|sym| *sym); + let C_EncryptInit = __library.get(b"C_EncryptInit\0").map(|sym| *sym); + let C_Encrypt = __library.get(b"C_Encrypt\0").map(|sym| *sym); + let C_EncryptUpdate = __library.get(b"C_EncryptUpdate\0").map(|sym| *sym); + let C_EncryptFinal = __library.get(b"C_EncryptFinal\0").map(|sym| *sym); + let C_DecryptInit = __library.get(b"C_DecryptInit\0").map(|sym| *sym); + let C_Decrypt = __library.get(b"C_Decrypt\0").map(|sym| *sym); + let C_DecryptUpdate = __library.get(b"C_DecryptUpdate\0").map(|sym| *sym); + let C_DecryptFinal = __library.get(b"C_DecryptFinal\0").map(|sym| *sym); + let C_DigestInit = __library.get(b"C_DigestInit\0").map(|sym| *sym); + let C_Digest = __library.get(b"C_Digest\0").map(|sym| *sym); + let C_DigestUpdate = __library.get(b"C_DigestUpdate\0").map(|sym| *sym); + let C_DigestKey = __library.get(b"C_DigestKey\0").map(|sym| *sym); + let C_DigestFinal = __library.get(b"C_DigestFinal\0").map(|sym| *sym); + let C_SignInit = __library.get(b"C_SignInit\0").map(|sym| *sym); + let C_Sign = __library.get(b"C_Sign\0").map(|sym| *sym); + let C_SignUpdate = __library.get(b"C_SignUpdate\0").map(|sym| *sym); + let C_SignFinal = __library.get(b"C_SignFinal\0").map(|sym| *sym); + let C_SignRecoverInit = __library.get(b"C_SignRecoverInit\0").map(|sym| *sym); + let C_SignRecover = __library.get(b"C_SignRecover\0").map(|sym| *sym); + let C_VerifyInit = __library.get(b"C_VerifyInit\0").map(|sym| *sym); + let C_Verify = __library.get(b"C_Verify\0").map(|sym| *sym); + let C_VerifyUpdate = __library.get(b"C_VerifyUpdate\0").map(|sym| *sym); + let C_VerifyFinal = __library.get(b"C_VerifyFinal\0").map(|sym| *sym); + let C_VerifyRecoverInit = __library.get(b"C_VerifyRecoverInit\0").map(|sym| *sym); + let C_VerifyRecover = __library.get(b"C_VerifyRecover\0").map(|sym| *sym); + let C_DigestEncryptUpdate = __library.get(b"C_DigestEncryptUpdate\0").map(|sym| *sym); + let C_DecryptDigestUpdate = __library.get(b"C_DecryptDigestUpdate\0").map(|sym| *sym); + let C_SignEncryptUpdate = __library.get(b"C_SignEncryptUpdate\0").map(|sym| *sym); + let C_DecryptVerifyUpdate = __library.get(b"C_DecryptVerifyUpdate\0").map(|sym| *sym); + let C_GenerateKey = __library.get(b"C_GenerateKey\0").map(|sym| *sym); + let C_GenerateKeyPair = __library.get(b"C_GenerateKeyPair\0").map(|sym| *sym); + let C_WrapKey = __library.get(b"C_WrapKey\0").map(|sym| *sym); + let C_UnwrapKey = __library.get(b"C_UnwrapKey\0").map(|sym| *sym); + let C_DeriveKey = __library.get(b"C_DeriveKey\0").map(|sym| *sym); + let C_SeedRandom = __library.get(b"C_SeedRandom\0").map(|sym| *sym); + let C_GenerateRandom = __library.get(b"C_GenerateRandom\0").map(|sym| *sym); + let C_GetFunctionStatus = __library.get(b"C_GetFunctionStatus\0").map(|sym| *sym); + let C_CancelFunction = __library.get(b"C_CancelFunction\0").map(|sym| *sym); + Ok(Pkcs11 { + __library, + C_Initialize, + C_Finalize, + C_GetInfo, + C_GetFunctionList, + C_GetSlotList, + C_GetSlotInfo, + C_GetTokenInfo, + C_WaitForSlotEvent, + C_GetMechanismList, + C_GetMechanismInfo, + C_InitToken, + C_InitPIN, + C_SetPIN, + C_OpenSession, + C_CloseSession, + C_CloseAllSessions, + C_GetSessionInfo, + C_GetOperationState, + C_SetOperationState, + C_Login, + C_Logout, + C_CreateObject, + C_CopyObject, + C_DestroyObject, + C_GetObjectSize, + C_GetAttributeValue, + C_SetAttributeValue, + C_FindObjectsInit, + C_FindObjects, + C_FindObjectsFinal, + C_EncryptInit, + C_Encrypt, + C_EncryptUpdate, + C_EncryptFinal, + C_DecryptInit, + C_Decrypt, + C_DecryptUpdate, + C_DecryptFinal, + C_DigestInit, + C_Digest, + C_DigestUpdate, + C_DigestKey, + C_DigestFinal, + C_SignInit, + C_Sign, + C_SignUpdate, + C_SignFinal, + C_SignRecoverInit, + C_SignRecover, + C_VerifyInit, + C_Verify, + C_VerifyUpdate, + C_VerifyFinal, + C_VerifyRecoverInit, + C_VerifyRecover, + C_DigestEncryptUpdate, + C_DecryptDigestUpdate, + C_SignEncryptUpdate, + C_DecryptVerifyUpdate, + C_GenerateKey, + C_GenerateKeyPair, + C_WrapKey, + C_UnwrapKey, + C_DeriveKey, + C_SeedRandom, + C_GenerateRandom, + C_GetFunctionStatus, + C_CancelFunction, + }) + } + pub unsafe fn C_Initialize(&self, init_args: *mut ::std::os::raw::c_void) -> CK_RV { + (self + .C_Initialize + .as_ref() + .expect("Expected function, got error."))(init_args) + } + pub unsafe fn C_Finalize(&self, pReserved: *mut ::std::os::raw::c_void) -> CK_RV { + (self + .C_Finalize + .as_ref() + .expect("Expected function, got error."))(pReserved) + } + pub unsafe fn C_GetInfo(&self, info: *mut _CK_INFO) -> CK_RV { + (self + .C_GetInfo + .as_ref() + .expect("Expected function, got error."))(info) + } + 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) + } + pub unsafe fn C_GetSlotList( + &self, + token_present: ::std::os::raw::c_uchar, + slot_list: *mut CK_SLOT_ID, + ulCount: *mut ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_GetSlotList + .as_ref() + .expect("Expected function, got error."))(token_present, slot_list, ulCount) + } + pub unsafe fn C_GetSlotInfo(&self, slotID: CK_SLOT_ID, info: *mut _CK_SLOT_INFO) -> CK_RV { + (self + .C_GetSlotInfo + .as_ref() + .expect("Expected function, got error."))(slotID, info) + } + pub unsafe fn C_GetTokenInfo(&self, slotID: CK_SLOT_ID, info: *mut _CK_TOKEN_INFO) -> CK_RV { + (self + .C_GetTokenInfo + .as_ref() + .expect("Expected function, got error."))(slotID, info) + } + pub unsafe fn C_WaitForSlotEvent( + &self, + flags: CK_FLAGS, + slot: *mut CK_SLOT_ID, + pReserved: *mut ::std::os::raw::c_void, + ) -> CK_RV { + (self + .C_WaitForSlotEvent + .as_ref() + .expect("Expected function, got error."))(flags, slot, pReserved) + } + pub unsafe fn C_GetMechanismList( + &self, + slotID: CK_SLOT_ID, + mechanism_list: *mut CK_MECHANISM_TYPE, + ulCount: *mut ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_GetMechanismList + .as_ref() + .expect("Expected function, got error."))(slotID, mechanism_list, ulCount) + } + pub unsafe fn C_GetMechanismInfo( + &self, + slotID: CK_SLOT_ID, + type_: CK_MECHANISM_TYPE, + info: *mut _CK_MECHANISM_INFO, + ) -> CK_RV { + (self + .C_GetMechanismInfo + .as_ref() + .expect("Expected function, got error."))(slotID, type_, info) + } + pub unsafe fn C_InitToken( + &self, + 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 { + (self + .C_InitToken + .as_ref() + .expect("Expected function, got error."))(slotID, pin, pin_len, label) + } + pub unsafe fn C_InitPIN( + &self, + session: CK_SESSION_HANDLE, + pin: *mut ::std::os::raw::c_uchar, + pin_len: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_InitPIN + .as_ref() + .expect("Expected function, got error."))(session, pin, pin_len) + } + pub unsafe fn C_SetPIN( + &self, + 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 { + (self + .C_SetPIN + .as_ref() + .expect("Expected function, got error."))( + session, old_pin, old_len, new_pin, new_len + ) + } + pub unsafe fn C_OpenSession( + &self, + slotID: CK_SLOT_ID, + flags: CK_FLAGS, + application: *mut ::std::os::raw::c_void, + notify: CK_NOTIFY, + session: *mut CK_SESSION_HANDLE, + ) -> CK_RV { + (self + .C_OpenSession + .as_ref() + .expect("Expected function, got error."))( + slotID, flags, application, notify, session + ) + } + pub unsafe fn C_CloseSession(&self, session: CK_SESSION_HANDLE) -> CK_RV { + (self + .C_CloseSession + .as_ref() + .expect("Expected function, got error."))(session) + } + pub unsafe fn C_CloseAllSessions(&self, slotID: CK_SLOT_ID) -> CK_RV { + (self + .C_CloseAllSessions + .as_ref() + .expect("Expected function, got error."))(slotID) + } + pub unsafe fn C_GetSessionInfo( + &self, + session: CK_SESSION_HANDLE, + info: *mut _CK_SESSION_INFO, + ) -> CK_RV { + (self + .C_GetSessionInfo + .as_ref() + .expect("Expected function, got error."))(session, info) + } + pub unsafe fn C_GetOperationState( + &self, + session: CK_SESSION_HANDLE, + operation_state: *mut ::std::os::raw::c_uchar, + operation_state_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_GetOperationState + .as_ref() + .expect("Expected function, got error."))( + session, operation_state, operation_state_len + ) + } + pub unsafe fn C_SetOperationState( + &self, + 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 { + (self + .C_SetOperationState + .as_ref() + .expect("Expected function, got error."))( + session, + operation_state, + operation_state_len, + encryption_key, + authentiation_key, + ) + } + pub unsafe fn C_Login( + &self, + 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 { + (self + .C_Login + .as_ref() + .expect("Expected function, got error."))(session, user_type, pin, pin_len) + } + pub unsafe fn C_Logout(&self, session: CK_SESSION_HANDLE) -> CK_RV { + (self + .C_Logout + .as_ref() + .expect("Expected function, got error."))(session) + } + pub unsafe fn C_CreateObject( + &self, + session: CK_SESSION_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + object: *mut CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_CreateObject + .as_ref() + .expect("Expected function, got error."))(session, templ, ulCount, object) + } + pub unsafe fn C_CopyObject( + &self, + 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 { + (self + .C_CopyObject + .as_ref() + .expect("Expected function, got error."))( + session, object, templ, ulCount, new_object + ) + } + pub unsafe fn C_DestroyObject( + &self, + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_DestroyObject + .as_ref() + .expect("Expected function, got error."))(session, object) + } + pub unsafe fn C_GetObjectSize( + &self, + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + size: *mut ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_GetObjectSize + .as_ref() + .expect("Expected function, got error."))(session, object, size) + } + pub unsafe fn C_GetAttributeValue( + &self, + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_GetAttributeValue + .as_ref() + .expect("Expected function, got error."))(session, object, templ, ulCount) + } + pub unsafe fn C_SetAttributeValue( + &self, + session: CK_SESSION_HANDLE, + object: CK_OBJECT_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_SetAttributeValue + .as_ref() + .expect("Expected function, got error."))(session, object, templ, ulCount) + } + pub unsafe fn C_FindObjectsInit( + &self, + session: CK_SESSION_HANDLE, + templ: *mut _CK_ATTRIBUTE, + ulCount: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_FindObjectsInit + .as_ref() + .expect("Expected function, got error."))(session, templ, ulCount) + } + pub unsafe fn C_FindObjects( + &self, + 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 { + (self + .C_FindObjects + .as_ref() + .expect("Expected function, got error."))( + session, + object, + max_object_count, + object_count, + ) + } + pub unsafe fn C_FindObjectsFinal(&self, session: CK_SESSION_HANDLE) -> CK_RV { + (self + .C_FindObjectsFinal + .as_ref() + .expect("Expected function, got error."))(session) + } + pub unsafe fn C_EncryptInit( + &self, + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_EncryptInit + .as_ref() + .expect("Expected function, got error."))(session, mechanism, key) + } + pub unsafe fn C_Encrypt( + &self, + 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 { + (self + .C_Encrypt + .as_ref() + .expect("Expected function, got error."))( + session, + data, + data_len, + encrypted_data, + encrypted_data_len, + ) + } + pub unsafe fn C_EncryptUpdate( + &self, + 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 { + (self + .C_EncryptUpdate + .as_ref() + .expect("Expected function, got error."))( + session, + part, + part_len, + encrypted_part, + encrypted_part_len, + ) + } + pub unsafe fn C_EncryptFinal( + &self, + 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 { + (self + .C_EncryptFinal + .as_ref() + .expect("Expected function, got error."))( + session, + last_encrypted_part, + last_encrypted_part_len, + ) + } + pub unsafe fn C_DecryptInit( + &self, + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_DecryptInit + .as_ref() + .expect("Expected function, got error."))(session, mechanism, key) + } + pub unsafe fn C_Decrypt( + &self, + 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 { + (self + .C_Decrypt + .as_ref() + .expect("Expected function, got error."))( + session, + encrypted_data, + encrypted_data_len, + data, + data_len, + ) + } + pub unsafe fn C_DecryptUpdate( + &self, + 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 { + (self + .C_DecryptUpdate + .as_ref() + .expect("Expected function, got error."))( + session, + encrypted_part, + encrypted_part_len, + part, + part_len, + ) + } + pub unsafe fn C_DecryptFinal( + &self, + session: CK_SESSION_HANDLE, + last_part: *mut ::std::os::raw::c_uchar, + last_part_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_DecryptFinal + .as_ref() + .expect("Expected function, got error."))(session, last_part, last_part_len) + } + pub unsafe fn C_DigestInit( + &self, + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + ) -> CK_RV { + (self + .C_DigestInit + .as_ref() + .expect("Expected function, got error."))(session, mechanism) + } + pub unsafe fn C_Digest( + &self, + 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 { + (self + .C_Digest + .as_ref() + .expect("Expected function, got error."))( + session, data, data_len, digest, digest_len + ) + } + pub unsafe fn C_DigestUpdate( + &self, + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_DigestUpdate + .as_ref() + .expect("Expected function, got error."))(session, part, part_len) + } + pub unsafe fn C_DigestKey(&self, session: CK_SESSION_HANDLE, key: CK_OBJECT_HANDLE) -> CK_RV { + (self + .C_DigestKey + .as_ref() + .expect("Expected function, got error."))(session, key) + } + pub unsafe fn C_DigestFinal( + &self, + session: CK_SESSION_HANDLE, + digest: *mut ::std::os::raw::c_uchar, + digest_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_DigestFinal + .as_ref() + .expect("Expected function, got error."))(session, digest, digest_len) + } + pub unsafe fn C_SignInit( + &self, + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_SignInit + .as_ref() + .expect("Expected function, got error."))(session, mechanism, key) + } + pub unsafe fn C_Sign( + &self, + 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 { + (self.C_Sign.as_ref().expect("Expected function, got error."))( + session, + data, + data_len, + signature, + signature_len, + ) + } + pub unsafe fn C_SignUpdate( + &self, + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_SignUpdate + .as_ref() + .expect("Expected function, got error."))(session, part, part_len) + } + pub unsafe fn C_SignFinal( + &self, + session: CK_SESSION_HANDLE, + signature: *mut ::std::os::raw::c_uchar, + signature_len: *mut ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_SignFinal + .as_ref() + .expect("Expected function, got error."))(session, signature, signature_len) + } + pub unsafe fn C_SignRecoverInit( + &self, + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_SignRecoverInit + .as_ref() + .expect("Expected function, got error."))(session, mechanism, key) + } + pub unsafe fn C_SignRecover( + &self, + 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 { + (self + .C_SignRecover + .as_ref() + .expect("Expected function, got error."))( + session, + data, + data_len, + signature, + signature_len, + ) + } + pub unsafe fn C_VerifyInit( + &self, + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_VerifyInit + .as_ref() + .expect("Expected function, got error."))(session, mechanism, key) + } + pub unsafe fn C_Verify( + &self, + 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 { + (self + .C_Verify + .as_ref() + .expect("Expected function, got error."))( + session, + data, + data_len, + signature, + signature_len, + ) + } + pub unsafe fn C_VerifyUpdate( + &self, + session: CK_SESSION_HANDLE, + part: *mut ::std::os::raw::c_uchar, + part_len: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_VerifyUpdate + .as_ref() + .expect("Expected function, got error."))(session, part, part_len) + } + pub unsafe fn C_VerifyFinal( + &self, + session: CK_SESSION_HANDLE, + signature: *mut ::std::os::raw::c_uchar, + signature_len: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_VerifyFinal + .as_ref() + .expect("Expected function, got error."))(session, signature, signature_len) + } + pub unsafe fn C_VerifyRecoverInit( + &self, + session: CK_SESSION_HANDLE, + mechanism: *mut _CK_MECHANISM, + key: CK_OBJECT_HANDLE, + ) -> CK_RV { + (self + .C_VerifyRecoverInit + .as_ref() + .expect("Expected function, got error."))(session, mechanism, key) + } + pub unsafe fn C_VerifyRecover( + &self, + 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 { + (self + .C_VerifyRecover + .as_ref() + .expect("Expected function, got error."))( + session, + signature, + signature_len, + data, + data_len, + ) + } + pub unsafe fn C_DigestEncryptUpdate( + &self, + 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 { + (self + .C_DigestEncryptUpdate + .as_ref() + .expect("Expected function, got error."))( + session, + part, + part_len, + encrypted_part, + encrypted_part_len, + ) + } + pub unsafe fn C_DecryptDigestUpdate( + &self, + 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 { + (self + .C_DecryptDigestUpdate + .as_ref() + .expect("Expected function, got error."))( + session, + encrypted_part, + encrypted_part_len, + part, + part_len, + ) + } + pub unsafe fn C_SignEncryptUpdate( + &self, + 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 { + (self + .C_SignEncryptUpdate + .as_ref() + .expect("Expected function, got error."))( + session, + part, + part_len, + encrypted_part, + encrypted_part_len, + ) + } + pub unsafe fn C_DecryptVerifyUpdate( + &self, + 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 { + (self + .C_DecryptVerifyUpdate + .as_ref() + .expect("Expected function, got error."))( + session, + encrypted_part, + encrypted_part_len, + part, + part_len, + ) + } + pub unsafe fn C_GenerateKey( + &self, + 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 { + (self + .C_GenerateKey + .as_ref() + .expect("Expected function, got error."))( + session, mechanism, templ, ulCount, key + ) + } + pub unsafe fn C_GenerateKeyPair( + &self, + 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 { + (self + .C_GenerateKeyPair + .as_ref() + .expect("Expected function, got error."))( + session, + mechanism, + public_key_template, + public_key_attribute_count, + private_key_template, + private_key_attribute_count, + public_key, + private_key, + ) + } + pub unsafe fn C_WrapKey( + &self, + 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 { + (self + .C_WrapKey + .as_ref() + .expect("Expected function, got error."))( + session, + mechanism, + wrapping_key, + key, + wrapped_key, + wrapped_key_len, + ) + } + pub unsafe fn C_UnwrapKey( + &self, + 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 { + (self + .C_UnwrapKey + .as_ref() + .expect("Expected function, got error."))( + session, + mechanism, + unwrapping_key, + wrapped_key, + wrapped_key_len, + templ, + attribute_count, + key, + ) + } + pub unsafe fn C_DeriveKey( + &self, + 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 { + (self + .C_DeriveKey + .as_ref() + .expect("Expected function, got error."))( + session, + mechanism, + base_key, + templ, + attribute_count, + key, + ) + } + pub unsafe fn C_SeedRandom( + &self, + session: CK_SESSION_HANDLE, + seed: *mut ::std::os::raw::c_uchar, + seed_len: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_SeedRandom + .as_ref() + .expect("Expected function, got error."))(session, seed, seed_len) + } + pub unsafe fn C_GenerateRandom( + &self, + session: CK_SESSION_HANDLE, + random_data: *mut ::std::os::raw::c_uchar, + random_len: ::std::os::raw::c_ulong, + ) -> CK_RV { + (self + .C_GenerateRandom + .as_ref() + .expect("Expected function, got error."))(session, random_data, random_len) + } + pub unsafe fn C_GetFunctionStatus(&self, session: CK_SESSION_HANDLE) -> CK_RV { + (self + .C_GetFunctionStatus + .as_ref() + .expect("Expected function, got error."))(session) + } + pub unsafe fn C_CancelFunction(&self, session: CK_SESSION_HANDLE) -> CK_RV { + (self + .C_CancelFunction + .as_ref() + .expect("Expected function, got error."))(session) + } +} diff --git a/cryptoki-sys/src/lib.rs b/cryptoki-sys/src/lib.rs index f9cc6cc9..3ad6eca0 100644 --- a/cryptoki-sys/src/lib.rs +++ b/cryptoki-sys/src/lib.rs @@ -105,6 +105,24 @@ include!(concat!( "/src/bindings/x86_64-unknown-freebsd.rs" )); +// For supported targets: use the generated and committed bindings. +#[cfg(not(any( + feature = "generate-bindings", + all(target_arch = "x86_64", target_os = "linux"), + all(target_arch = "x86", target_os = "linux"), + all(target_arch = "powerpc64", target_os = "linux"), + all(target_arch = "aarch64", target_os = "linux"), + all(target_arch = "arm", target_os = "linux"), + all(target_arch = "x86_64", target_os = "macos"), + all(target_arch = "aarch64", target_os = "macos"), + all(target_arch = "x86_64", target_os = "windows"), + all(target_arch = "x86_64", target_os = "freebsd"), +)))] +include!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/src/bindings/generic.rs" +)); + // If the "generate-bindings" feature is on, use the generated bindings. #[cfg(feature = "generate-bindings")] include!(concat!(env!("OUT_DIR"), "/pkcs11_bindings.rs"));