Skip to content

Commit be13433

Browse files
authored
Merge pull request #228 from Direktor799/feat/pkcs11-3.0
Feat/pkcs11 3.0
2 parents 024976f + 1eb78c5 commit be13433

19 files changed

+102113
-24584
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[codespell]
2-
skip = .git,target,Cargo.lock
2+
skip = .git,target,Cargo.lock,vendor
33
ignore-words-list = crate,keypair

cryptoki-sys/build.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ mod generate {
1515
pub struct CargoCallbacks;
1616

1717
impl callbacks::ParseCallbacks for CargoCallbacks {
18+
// skip processing CK_UNAVAILABLE_INFORMATION macro, more details in lib.rs
19+
fn will_parse_macro(&self, name: &str) -> callbacks::MacroParsingBehavior {
20+
if name == "CK_UNAVAILABLE_INFORMATION" {
21+
callbacks::MacroParsingBehavior::Ignore
22+
} else {
23+
callbacks::MacroParsingBehavior::Default
24+
}
25+
}
26+
1827
fn int_macro(&self, name: &str, _: i64) -> Option<callbacks::IntKind> {
1928
let prefixes = [
2029
("CK_", "CK_ULONG"),
@@ -23,16 +32,22 @@ mod generate {
2332
("CKD_", "CK_EC_KDF_TYPE"),
2433
("CKF_", "CK_FLAGS"),
2534
("CKG_MGF1_", "CK_RSA_PKCS_MGF_TYPE"),
35+
("CKG", "CK_GENERATOR_FUNCTION"),
2636
("CKH_", "CK_HW_FEATURE_TYPE"),
2737
("CKK_", "CK_KEY_TYPE"),
2838
("CKM_", "CK_MECHANISM_TYPE"),
2939
("CKN_", "CK_NOTIFICATION"),
3040
("CKO_", "CK_OBJECT_CLASS"),
41+
(
42+
"CKP_PKCS5_PBKD2_",
43+
"CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE",
44+
),
3145
("CKP_", "CK_PROFILE_ID"),
3246
("CKR_", "CK_RV"),
3347
("CKS_", "CK_STATE"),
3448
("CKU_", "CK_USER_TYPE"),
35-
("CKZ_", "CK_RSA_PKCS_OAEP_SOURCE_TYPE"),
49+
("CKZ_DATA_SPECIFIED", "CK_RSA_PKCS_OAEP_SOURCE_TYPE"),
50+
("CKZ_SALT_SPECIFIED", "CK_PKCS5_PBKDF2_SALT_SOURCE_TYPE"),
3651
("CRYPTOKI_VERSION_", "CK_BYTE"),
3752
];
3853

@@ -59,6 +74,8 @@ mod generate {
5974
pub fn generate_bindings() {
6075
let make_generic: bool = std::env::var_os("MAKE_GENERIC_BINDINGS").is_some();
6176
let mut builder = bindgen::Builder::default();
77+
// to be fully compatible with 2.4
78+
builder = builder.header_contents("enable-deprecated.h", "#define PKCS11_DEPRECATED 1\n");
6279
if make_generic {
6380
// only WIN32 bindings are "packed". It's easier to "unpack" for other architectures
6481
// __declspec is not needed and causes problems
@@ -70,7 +87,7 @@ mod generate {
7087
}
7188

7289
builder = builder
73-
.header("pkcs11.h")
90+
.header("vendor/pkcs11.h")
7491
.dynamic_library_name("Pkcs11")
7592
// The PKCS11 library works in a slightly different way to most shared libraries. We have
7693
// to call `C_GetFunctionList`, which returns a list of pointers to the _actual_ library
@@ -79,7 +96,7 @@ mod generate {
7996
// This is needed because no types will be generated if `allowlist_function` is used.
8097
// Unsure if this is a bug.
8198
.allowlist_type("*")
82-
.allowlist_file("pkcs11.h")
99+
.allowlist_file("vendor/pkcs11.h")
83100
// See this issue: https://github.com/parallaxsecond/rust-cryptoki/issues/12
84101
.blocklist_type("max_align_t")
85102
// Derive the `Debug` trait for the generated structs where possible.

0 commit comments

Comments
 (0)