tin_ladybug_oqs_provider_sys/lib.rs
1use std::ffi::c_char;
2
3// These `use` statements are necessary to tell that rust compiler that we need
4// these libraries to be linked, even through no symbols from them are explicitly
5// referenced.
6// TODO: Do these need to be pub use?
7use openssl_sys as _;
8use oqs_sys as _;
9
10// TODO: add a nice doc comment that shows the linking process.
11
12// TODO: do I actually need to invoke bindgen? I think the answer is no. The only
13// two symbols that I actually use are the provider_init function (why isn't that
14// captured by bindgen?) and the provider name, which also isn't covered by bindgen.
15// include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
16// pub use ffi::*;
17
18// Unfortunately we have to do an itty-bitty lie here. oqs_prov.h does not export
19// the module name, nor does it export the init function.
20
21// DANGER: we lie about the function signature for the purpose of convenience.
22// https://github.com/openssl/openssl/blob/b85e6f534906f0bf9114386d227e481d2336a0ff/include/openssl/core.h#L193
23// ```
24// typedef int (OSSL_provider_init_fn)(const OSSL_CORE_HANDLE *handle,
25// const OSSL_DISPATCH *in,
26// const OSSL_DISPATCH **out,
27// void **provctx);
28// ```
29// Because we end up handwritten the bindings for add_builtin, as long as
30// both *share* the lie it isn't a problem.
31#[link(name = "oqsprovider", kind = "static")]
32extern "C" {
33 /// Entry point for the liboqs provider
34 pub fn oqs_provider_init();
35}
36
37/// Name of the OQS provider
38pub const OQS_PROV_NAME: *const c_char = c"oqsprovider".as_ptr();
39
40// extern "C" {
41// fn OSSL_PROVIDER_add_builtin(
42// ctx: *mut openssl_sys::OSSL_LIB_CTX,
43// name: *const c_char,
44// init: unsafe extern "C" fn(),
45// ) -> c_int;
46// }