@@ -15,6 +15,15 @@ mod generate {
15
15
pub struct CargoCallbacks ;
16
16
17
17
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
+
18
27
fn int_macro ( & self , name : & str , _: i64 ) -> Option < callbacks:: IntKind > {
19
28
let prefixes = [
20
29
( "CK_" , "CK_ULONG" ) ,
@@ -23,16 +32,22 @@ mod generate {
23
32
( "CKD_" , "CK_EC_KDF_TYPE" ) ,
24
33
( "CKF_" , "CK_FLAGS" ) ,
25
34
( "CKG_MGF1_" , "CK_RSA_PKCS_MGF_TYPE" ) ,
35
+ ( "CKG" , "CK_GENERATOR_FUNCTION" ) ,
26
36
( "CKH_" , "CK_HW_FEATURE_TYPE" ) ,
27
37
( "CKK_" , "CK_KEY_TYPE" ) ,
28
38
( "CKM_" , "CK_MECHANISM_TYPE" ) ,
29
39
( "CKN_" , "CK_NOTIFICATION" ) ,
30
40
( "CKO_" , "CK_OBJECT_CLASS" ) ,
41
+ (
42
+ "CKP_PKCS5_PBKD2_" ,
43
+ "CK_PKCS5_PBKD2_PSEUDO_RANDOM_FUNCTION_TYPE" ,
44
+ ) ,
31
45
( "CKP_" , "CK_PROFILE_ID" ) ,
32
46
( "CKR_" , "CK_RV" ) ,
33
47
( "CKS_" , "CK_STATE" ) ,
34
48
( "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" ) ,
36
51
( "CRYPTOKI_VERSION_" , "CK_BYTE" ) ,
37
52
] ;
38
53
@@ -59,6 +74,8 @@ mod generate {
59
74
pub fn generate_bindings ( ) {
60
75
let make_generic: bool = std:: env:: var_os ( "MAKE_GENERIC_BINDINGS" ) . is_some ( ) ;
61
76
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 " ) ;
62
79
if make_generic {
63
80
// only WIN32 bindings are "packed". It's easier to "unpack" for other architectures
64
81
// __declspec is not needed and causes problems
@@ -70,7 +87,7 @@ mod generate {
70
87
}
71
88
72
89
builder = builder
73
- . header ( "pkcs11.h" )
90
+ . header ( "vendor/ pkcs11.h" )
74
91
. dynamic_library_name ( "Pkcs11" )
75
92
// The PKCS11 library works in a slightly different way to most shared libraries. We have
76
93
// to call `C_GetFunctionList`, which returns a list of pointers to the _actual_ library
@@ -79,7 +96,7 @@ mod generate {
79
96
// This is needed because no types will be generated if `allowlist_function` is used.
80
97
// Unsure if this is a bug.
81
98
. allowlist_type ( "*" )
82
- . allowlist_file ( "pkcs11.h" )
99
+ . allowlist_file ( "vendor/ pkcs11.h" )
83
100
// See this issue: https://github.com/parallaxsecond/rust-cryptoki/issues/12
84
101
. blocklist_type ( "max_align_t" )
85
102
// Derive the `Debug` trait for the generated structs where possible.
0 commit comments