wolfssl_sys/
lib.rs

1mod bindings;
2pub use bindings::*;
3
4/**
5 * Add more tests to gain more confidence in the bindings
6 */
7#[cfg(test)]
8mod tests {
9    use std::os::raw::c_int;
10    use test_case::test_case;
11
12    use super::*;
13    #[test]
14    fn init_wolfssl() {
15        unsafe {
16            let res = wolfSSL_Init();
17            assert_eq!(res, WOLFSSL_SUCCESS as c_int);
18        }
19    }
20
21    #[cfg(feature = "postquantum")]
22    #[test_case(WOLFSSL_P521_KYBER_LEVEL5)]
23    #[cfg_attr(not(feature = "kyber_only"), test_case(WOLFSSL_P521_ML_KEM_1024))]
24    fn test_post_quantum_available(group: std::os::raw::c_uint) {
25        unsafe {
26            // Init WolfSSL
27            let res = wolfSSL_Init();
28            assert_eq!(res, WOLFSSL_SUCCESS as c_int);
29
30            // Set up client method
31            let method = wolfTLSv1_3_client_method();
32
33            // Create context
34            let context = wolfSSL_CTX_new(method);
35
36            // Create new SSL stream
37            let ssl = wolfSSL_new(context);
38
39            let res = wolfSSL_UseKeyShare(ssl, group.try_into().unwrap());
40
41            // Check that Kyber/ML-KEM was enabled
42            assert_eq!(res, WOLFSSL_SUCCESS as c_int);
43        }
44    }
45}