mod bindings;
pub use bindings::*;
use std::ffi::CStr;
pub fn get_wolfssl_version_string() -> &'static str {
CStr::from_bytes_until_nul(LIBWOLFSSL_VERSION_STRING)
.unwrap()
.to_str()
.unwrap()
}
#[cfg(test)]
mod tests {
use std::os::raw::c_int;
use test_case::test_case;
#[cfg(unix)]
type CurveGroupType = std::os::raw::c_uint;
#[cfg(windows)]
type CurveGroupType = std::os::raw::c_int;
use super::*;
#[test]
fn init_wolfssl() {
unsafe {
let res = wolfSSL_Init();
assert_eq!(res, WOLFSSL_SUCCESS as c_int);
}
}
#[cfg(feature = "postquantum")]
#[test_case(WOLFSSL_SECP521R1MLKEM1024)]
fn test_post_quantum_available(group: CurveGroupType) {
unsafe {
let res = wolfSSL_Init();
assert_eq!(res, WOLFSSL_SUCCESS as c_int);
let method = wolfTLSv1_3_client_method();
let context = wolfSSL_CTX_new(method);
let ssl = wolfSSL_new(context);
let res = wolfSSL_UseKeyShare(ssl, group.try_into().unwrap());
assert_eq!(res, WOLFSSL_SUCCESS as c_int);
}
}
#[test]
fn test_wolfssl_version_is_not_empty() {
assert!(!get_wolfssl_version_string().is_empty())
}
}