1mod bindings;
2
3pub use bindings::*;
4use std::ffi::CStr;
5
6pub fn get_wolfssl_version_string() -> &'static str {
8 CStr::from_bytes_until_nul(LIBWOLFSSL_VERSION_STRING)
9 .unwrap()
10 .to_str()
11 .unwrap()
12}
13
14#[cfg(test)]
18mod tests {
19 use std::os::raw::c_int;
20
21 use test_case::test_case;
22 #[cfg(unix)]
23 type CurveGroupType = std::os::raw::c_uint;
24 #[cfg(windows)]
25 type CurveGroupType = std::os::raw::c_int;
26
27 use super::*;
28 #[test]
29 fn init_wolfssl() {
30 unsafe {
31 let res = wolfSSL_Init();
32 assert_eq!(res, WOLFSSL_SUCCESS as c_int);
33 }
34 }
35
36 #[cfg(feature = "postquantum")]
37 #[test_case(WOLFSSL_P521_KYBER_LEVEL5)]
38 #[cfg_attr(not(feature = "kyber_only"), test_case(WOLFSSL_SECP521R1MLKEM1024))]
39 fn test_post_quantum_available(group: CurveGroupType) {
40 unsafe {
41 let res = wolfSSL_Init();
43 assert_eq!(res, WOLFSSL_SUCCESS as c_int);
44
45 let method = wolfTLSv1_3_client_method();
47
48 let context = wolfSSL_CTX_new(method);
50
51 let ssl = wolfSSL_new(context);
53
54 let res = wolfSSL_UseKeyShare(ssl, group.try_into().unwrap());
55
56 assert_eq!(res, WOLFSSL_SUCCESS as c_int);
58 }
59 }
60
61 #[test]
62 fn test_wolfssl_version_is_not_empty() {
63 assert!(!get_wolfssl_version_string().is_empty())
64 }
65}