1unsafe extern "C" {
4 #[doc = " Returns the version string for libmongocrypt.\n\n @param[out] len An optional length of the returned string. May be NULL.\n @returns a NULL terminated version string for libmongocrypt."]
5 pub fn mongocrypt_version(len: *mut u32) -> *const ::std::os::raw::c_char;
6}
7unsafe extern "C" {
8 #[doc = " Returns true if libmongocrypt was built with native crypto support.\n\n If libmongocrypt was not built with native crypto support, setting crypto\n hooks is required.\n\n @returns True if libmongocrypt was built with native crypto support."]
9 pub fn mongocrypt_is_crypto_available() -> bool;
10}
11#[doc = " A non-owning view of a byte buffer.\n\n When constructing a mongocrypt_binary_t it is the responsibility of the\n caller to maintain the lifetime of the viewed data. However, all public\n functions that take a mongocrypt_binary_t as an argument will make a copy of\n the viewed data. For example, the following is valid:\n\n @code{.c}\n mongocrypt_binary_t bin = mongocrypt_binary_new_from_data(mydata, mylen);\n assert (mongocrypt_setopt_kms_provider_local (crypt), bin);\n // The viewed data of bin has been copied. Ok to free the view and the data.\n mongocrypt_binary_destroy (bin);\n my_free_fn (mydata);\n @endcode\n\n Functions with a mongocrypt_binary_t* out guarantee the lifetime of the\n viewed data to live as long as the parent object. For example, @ref\n mongocrypt_ctx_mongo_op guarantees that the viewed data of\n mongocrypt_binary_t is valid until the parent ctx is destroyed with @ref\n mongocrypt_ctx_destroy.\n\n The `mongocrypt_binary_t` struct definition is public.\n Consumers may rely on the struct layout."]
12#[repr(C)]
13#[derive(Debug, Copy, Clone)]
14pub struct _mongocrypt_binary_t {
15 pub data: *mut ::std::os::raw::c_void,
16 pub len: u32,
17}
18#[allow(clippy::unnecessary_operation, clippy::identity_op)]
19const _: () = {
20 ["Size of _mongocrypt_binary_t"][::std::mem::size_of::<_mongocrypt_binary_t>() - 16usize];
21 ["Alignment of _mongocrypt_binary_t"][::std::mem::align_of::<_mongocrypt_binary_t>() - 8usize];
22 ["Offset of field: _mongocrypt_binary_t::data"]
23 [::std::mem::offset_of!(_mongocrypt_binary_t, data) - 0usize];
24 ["Offset of field: _mongocrypt_binary_t::len"]
25 [::std::mem::offset_of!(_mongocrypt_binary_t, len) - 8usize];
26};
27#[doc = " A non-owning view of a byte buffer.\n\n When constructing a mongocrypt_binary_t it is the responsibility of the\n caller to maintain the lifetime of the viewed data. However, all public\n functions that take a mongocrypt_binary_t as an argument will make a copy of\n the viewed data. For example, the following is valid:\n\n @code{.c}\n mongocrypt_binary_t bin = mongocrypt_binary_new_from_data(mydata, mylen);\n assert (mongocrypt_setopt_kms_provider_local (crypt), bin);\n // The viewed data of bin has been copied. Ok to free the view and the data.\n mongocrypt_binary_destroy (bin);\n my_free_fn (mydata);\n @endcode\n\n Functions with a mongocrypt_binary_t* out guarantee the lifetime of the\n viewed data to live as long as the parent object. For example, @ref\n mongocrypt_ctx_mongo_op guarantees that the viewed data of\n mongocrypt_binary_t is valid until the parent ctx is destroyed with @ref\n mongocrypt_ctx_destroy.\n\n The `mongocrypt_binary_t` struct definition is public.\n Consumers may rely on the struct layout."]
28pub type mongocrypt_binary_t = _mongocrypt_binary_t;
29unsafe extern "C" {
30 #[doc = " Create a new non-owning view of a buffer (data + length).\n\n Use this to create a mongocrypt_binary_t used for output parameters.\n\n @returns A new mongocrypt_binary_t."]
31 pub fn mongocrypt_binary_new() -> *mut mongocrypt_binary_t;
32}
33unsafe extern "C" {
34 #[doc = " Create a new non-owning view of a buffer (data + length).\n\n @param[in] data A pointer to an array of bytes. This data is not copied. @p\n data must outlive the binary object.\n @param[in] len The length of the @p data byte array.\n\n @returns A new @ref mongocrypt_binary_t."]
35 pub fn mongocrypt_binary_new_from_data(data: *mut u8, len: u32) -> *mut mongocrypt_binary_t;
36}
37unsafe extern "C" {
38 #[doc = " Get a pointer to the viewed data.\n\n @param[in] binary The @ref mongocrypt_binary_t.\n\n @returns A pointer to the viewed data."]
39 pub fn mongocrypt_binary_data(binary: *const mongocrypt_binary_t) -> *mut u8;
40}
41unsafe extern "C" {
42 #[doc = " Get the length of the viewed data.\n\n @param[in] binary The @ref mongocrypt_binary_t.\n\n @returns The length of the viewed data."]
43 pub fn mongocrypt_binary_len(binary: *const mongocrypt_binary_t) -> u32;
44}
45unsafe extern "C" {
46 #[doc = " Free the @ref mongocrypt_binary_t.\n\n This does not free the viewed data.\n\n @param[in] binary The mongocrypt_binary_t destroy."]
47 pub fn mongocrypt_binary_destroy(binary: *mut mongocrypt_binary_t);
48}
49#[repr(C)]
50#[derive(Debug, Copy, Clone)]
51pub struct _mongocrypt_status_t {
52 _unused: [u8; 0],
53}
54#[doc = " Indicates success or contains error information.\n\n Functions like @ref mongocrypt_ctx_encrypt_init follow a pattern to expose a\n status. A boolean is returned. True indicates success, and false indicates\n failure. On failure a status on the handle is set, and is accessible with a\n corresponding (handle)_status function. E.g. @ref mongocrypt_ctx_status."]
55pub type mongocrypt_status_t = _mongocrypt_status_t;
56pub const mongocrypt_status_type_t_MONGOCRYPT_STATUS_OK: mongocrypt_status_type_t = 0;
57pub const mongocrypt_status_type_t_MONGOCRYPT_STATUS_ERROR_CLIENT: mongocrypt_status_type_t = 1;
58pub const mongocrypt_status_type_t_MONGOCRYPT_STATUS_ERROR_KMS: mongocrypt_status_type_t = 2;
59pub const mongocrypt_status_type_t_MONGOCRYPT_STATUS_ERROR_CRYPT_SHARED: mongocrypt_status_type_t =
60 3;
61#[doc = " Indicates the type of error."]
62pub type mongocrypt_status_type_t = ::std::os::raw::c_uint;
63unsafe extern "C" {
64 #[doc = " Create a new status object.\n\n Use a new status object to retrieve the status from a handle by passing\n this as an out-parameter to functions like @ref mongocrypt_ctx_status.\n When done, destroy it with @ref mongocrypt_status_destroy.\n\n @returns A new status object."]
65 pub fn mongocrypt_status_new() -> *mut mongocrypt_status_t;
66}
67unsafe extern "C" {
68 #[doc = " Set a status object with message, type, and code.\n\n Use this to set the @ref mongocrypt_status_t given in the crypto hooks.\n\n @param[in] type The status type.\n @param[in] code The status code.\n @param[in] message The message.\n @param[in] message_len Due to historical behavior, pass 1 + the string length\n of @p message (which differs from other functions accepting string\n arguments).\n Alternatively, if message is NULL terminated this may be -1 to tell\n mongocrypt\n to determine the string's length with strlen.\n"]
69 pub fn mongocrypt_status_set(
70 status: *mut mongocrypt_status_t,
71 type_: mongocrypt_status_type_t,
72 code: u32,
73 message: *const ::std::os::raw::c_char,
74 message_len: i32,
75 );
76}
77unsafe extern "C" {
78 #[doc = " Indicates success or the type of error.\n\n @param[in] status The status object.\n\n @returns A @ref mongocrypt_status_type_t."]
79 pub fn mongocrypt_status_type(status: *mut mongocrypt_status_t) -> mongocrypt_status_type_t;
80}
81unsafe extern "C" {
82 #[doc = " Get an error code or 0.\n\n @param[in] status The status object.\n\n @returns An error code."]
83 pub fn mongocrypt_status_code(status: *mut mongocrypt_status_t) -> u32;
84}
85unsafe extern "C" {
86 #[doc = " Get the error message associated with a status or NULL.\n\n @param[in] status The status object.\n @param[out] len An optional length of the returned string (excluding the\n trailing NULL byte). May be NULL.\n\n @returns A NULL terminated error message or NULL."]
87 pub fn mongocrypt_status_message(
88 status: *mut mongocrypt_status_t,
89 len: *mut u32,
90 ) -> *const ::std::os::raw::c_char;
91}
92unsafe extern "C" {
93 #[doc = " Returns true if the status indicates success.\n\n @param[in] status The status to check.\n\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
94 pub fn mongocrypt_status_ok(status: *mut mongocrypt_status_t) -> bool;
95}
96unsafe extern "C" {
97 #[doc = " Free the memory for a status object.\n\n @param[in] status The status to destroy."]
98 pub fn mongocrypt_status_destroy(status: *mut mongocrypt_status_t);
99}
100pub const mongocrypt_log_level_t_MONGOCRYPT_LOG_LEVEL_FATAL: mongocrypt_log_level_t = 0;
101pub const mongocrypt_log_level_t_MONGOCRYPT_LOG_LEVEL_ERROR: mongocrypt_log_level_t = 1;
102pub const mongocrypt_log_level_t_MONGOCRYPT_LOG_LEVEL_WARNING: mongocrypt_log_level_t = 2;
103pub const mongocrypt_log_level_t_MONGOCRYPT_LOG_LEVEL_INFO: mongocrypt_log_level_t = 3;
104pub const mongocrypt_log_level_t_MONGOCRYPT_LOG_LEVEL_TRACE: mongocrypt_log_level_t = 4;
105#[doc = " Indicates the type of log message."]
106pub type mongocrypt_log_level_t = ::std::os::raw::c_uint;
107#[doc = " A log callback function. Set a custom log callback with @ref\n mongocrypt_setopt_log_handler.\n\n @param[in] message A NULL terminated message.\n @param[in] message_len The length of message.\n @param[in] ctx A context provided by the caller of @ref\n mongocrypt_setopt_log_handler."]
108pub type mongocrypt_log_fn_t = ::std::option::Option<
109 unsafe extern "C" fn(
110 level: mongocrypt_log_level_t,
111 message: *const ::std::os::raw::c_char,
112 message_len: u32,
113 ctx: *mut ::std::os::raw::c_void,
114 ),
115>;
116#[repr(C)]
117#[derive(Debug, Copy, Clone)]
118pub struct _mongocrypt_t {
119 _unused: [u8; 0],
120}
121#[doc = " The top-level handle to libmongocrypt.\n\n Create a mongocrypt_t handle to perform operations within libmongocrypt:\n encryption, decryption, registering log callbacks, etc.\n\n Functions on a mongocrypt_t are thread safe, though functions on derived\n handles (e.g. mongocrypt_ctx_t) are not and must be owned by a single\n thread. See each handle's documentation for thread-safety considerations.\n\n Multiple mongocrypt_t handles may be created."]
122pub type mongocrypt_t = _mongocrypt_t;
123unsafe extern "C" {
124 #[doc = " Allocate a new @ref mongocrypt_t object.\n\n Set options using mongocrypt_setopt_* functions, then initialize with @ref\n mongocrypt_init. When done with the @ref mongocrypt_t, free with @ref\n mongocrypt_destroy.\n\n @returns A new @ref mongocrypt_t object."]
125 pub fn mongocrypt_new() -> *mut mongocrypt_t;
126}
127unsafe extern "C" {
128 #[doc = " Set a handler on the @ref mongocrypt_t object to get called on every log\n message.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] log_fn The log callback.\n @param[in] log_ctx A context passed as an argument to the log callback every\n invocation.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
129 pub fn mongocrypt_setopt_log_handler(
130 crypt: *mut mongocrypt_t,
131 log_fn: mongocrypt_log_fn_t,
132 log_ctx: *mut ::std::os::raw::c_void,
133 ) -> bool;
134}
135unsafe extern "C" {
136 #[doc = " Enable or disable KMS retry behavior.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] enable A boolean indicating whether to retry operations.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
137 pub fn mongocrypt_setopt_retry_kms(crypt: *mut mongocrypt_t, enable: bool) -> bool;
138}
139unsafe extern "C" {
140 #[doc = " Enable support for multiple collection schemas. Required to support $lookup.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
141 pub fn mongocrypt_setopt_enable_multiple_collinfo(crypt: *mut mongocrypt_t) -> bool;
142}
143unsafe extern "C" {
144 #[doc = " Configure an AWS KMS provider on the @ref mongocrypt_t object.\n\n This has been superseded by the more flexible:\n @ref mongocrypt_setopt_kms_providers\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] aws_access_key_id The AWS access key ID used to generate KMS\n messages.\n @param[in] aws_access_key_id_len The string length (in bytes) of @p\n aws_access_key_id. Pass -1 to determine the string length with strlen (must\n be NULL terminated).\n @param[in] aws_secret_access_key The AWS secret access key used to generate\n KMS messages.\n @param[in] aws_secret_access_key_len The string length (in bytes) of @p\n aws_secret_access_key. Pass -1 to determine the string length with strlen\n (must be NULL terminated).\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
145 pub fn mongocrypt_setopt_kms_provider_aws(
146 crypt: *mut mongocrypt_t,
147 aws_access_key_id: *const ::std::os::raw::c_char,
148 aws_access_key_id_len: i32,
149 aws_secret_access_key: *const ::std::os::raw::c_char,
150 aws_secret_access_key_len: i32,
151 ) -> bool;
152}
153unsafe extern "C" {
154 #[doc = " Configure a local KMS provider on the @ref mongocrypt_t object.\n\n This has been superseded by the more flexible:\n @ref mongocrypt_setopt_kms_providers\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] key A 96 byte master key used to encrypt and decrypt key vault\n keys. The viewed data is copied. It is valid to destroy @p key with @ref\n mongocrypt_binary_destroy immediately after.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
155 pub fn mongocrypt_setopt_kms_provider_local(
156 crypt: *mut mongocrypt_t,
157 key: *mut mongocrypt_binary_t,
158 ) -> bool;
159}
160unsafe extern "C" {
161 #[doc = " Configure KMS providers with a BSON document.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] kms_providers A BSON document mapping the KMS provider names\n to credentials. Set a KMS provider value to an empty document to supply\n credentials on-demand with @ref mongocrypt_ctx_provide_kms_providers.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
162 pub fn mongocrypt_setopt_kms_providers(
163 crypt: *mut mongocrypt_t,
164 kms_providers: *mut mongocrypt_binary_t,
165 ) -> bool;
166}
167unsafe extern "C" {
168 #[doc = " Set a local schema map for encryption.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] schema_map A BSON document representing the schema map supplied by\n the user. The keys are collection namespaces and values are JSON schemas. The\n viewed data copied. It is valid to destroy @p schema_map with @ref\n mongocrypt_binary_destroy immediately after.\n @pre @p crypt has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_status"]
169 pub fn mongocrypt_setopt_schema_map(
170 crypt: *mut mongocrypt_t,
171 schema_map: *mut mongocrypt_binary_t,
172 ) -> bool;
173}
174unsafe extern "C" {
175 #[doc = " Set a local EncryptedFieldConfigMap for encryption.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] efc_map A BSON document representing the EncryptedFieldConfigMap\n supplied by the user. The keys are collection namespaces and values are\n EncryptedFieldConfigMap documents. The viewed data copied. It is valid to\n destroy @p efc_map with @ref mongocrypt_binary_destroy immediately after.\n @pre @p crypt has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_status"]
176 pub fn mongocrypt_setopt_encrypted_field_config_map(
177 crypt: *mut mongocrypt_t,
178 efc_map: *mut mongocrypt_binary_t,
179 ) -> bool;
180}
181unsafe extern "C" {
182 #[doc = " @brief Append an additional search directory to the search path for loading\n the crypt_shared dynamic library.\n\n @param[in] crypt The @ref mongocrypt_t object to update\n @param[in] path A null-terminated sequence of bytes for the search path. On\n some filesystems, this may be arbitrary bytes. On other filesystems, this may\n be required to be a valid UTF-8 code unit sequence. If the leading element of\n the path is the literal string \"$ORIGIN\", that substring will be replaced\n with the directory path containing the executable libmongocrypt module. If\n the path string is literal \"$SYSTEM\", then libmongocrypt will defer to the\n system's library resolution mechanism to find the crypt_shared library.\n\n @note If no crypt_shared dynamic library is found in any of the directories\n specified by the search paths loaded here, @ref mongocrypt_init() will still\n succeed and continue to operate without crypt_shared.\n\n @note The search paths are searched in the order that they are appended. This\n allows one to provide a precedence in how the library will be discovered. For\n example, appending known directories before appending \"$SYSTEM\" will allow\n one to supersede the system's installed library, but still fall-back to it if\n the library wasn't found otherwise. If one does not ever append \"$SYSTEM\",\n then the system's library-search mechanism will never be consulted.\n\n @note If an absolute path to the library is specified using\n @ref mongocrypt_setopt_set_crypt_shared_lib_path_override, then paths\n appended here will have no effect."]
183 pub fn mongocrypt_setopt_append_crypt_shared_lib_search_path(
184 crypt: *mut mongocrypt_t,
185 path: *const ::std::os::raw::c_char,
186 );
187}
188unsafe extern "C" {
189 #[doc = " @brief Set a single override path for loading the crypt_shared dynamic\n library.\n\n @param[in] crypt The @ref mongocrypt_t object to update\n @param[in] path A null-terminated sequence of bytes for a path to the\n crypt_shared dynamic library. On some filesystems, this may be arbitrary\n bytes. On other filesystems, this may be required to be a valid UTF-8 code\n unit sequence. If the leading element of the path is the literal string\n `$ORIGIN`, that substring will be replaced with the directory path containing\n the executable libmongocrypt module.\n\n @note This function will do no IO nor path validation. All validation will\n occur during the call to @ref mongocrypt_init.\n\n @note If a crypt_shared library path override is specified here, then no\n paths given to @ref mongocrypt_setopt_append_crypt_shared_lib_search_path\n will be consulted when opening the crypt_shared library.\n\n @note If a path is provided via this API and @ref mongocrypt_init fails to\n initialize a valid crypt_shared library instance for the path specified, then\n the initialization of mongocrypt_t will fail with an error."]
190 pub fn mongocrypt_setopt_set_crypt_shared_lib_path_override(
191 crypt: *mut mongocrypt_t,
192 path: *const ::std::os::raw::c_char,
193 );
194}
195unsafe extern "C" {
196 #[doc = " @brief Opt-into handling the MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS state.\n\n If set, before entering the MONGOCRYPT_CTX_NEED_KMS state,\n contexts may enter the MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS state\n and then wait for credentials to be supplied through\n @ref mongocrypt_ctx_provide_kms_providers.\n\n A context will only enter MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS\n if an empty document was set for a KMS provider in @ref\n mongocrypt_setopt_kms_providers.\n\n @param[in] crypt The @ref mongocrypt_t object to update"]
197 pub fn mongocrypt_setopt_use_need_kms_credentials_state(crypt: *mut mongocrypt_t);
198}
199unsafe extern "C" {
200 #[doc = " @brief Opt-into handling the MONGOCRYPT_CTX_NEED_MONGO_COLLINFO_WITH_DB state.\n\n A context enters the MONGOCRYPT_CTX_NEED_MONGO_COLLINFO_WITH_DB state when\n processing a `bulkWrite` command. The target database of the `bulkWrite` may differ from the command database\n (\"admin\").\n\n @param[in] crypt The @ref mongocrypt_t object to update"]
201 pub fn mongocrypt_setopt_use_need_mongo_collinfo_with_db_state(crypt: *mut mongocrypt_t);
202}
203unsafe extern "C" {
204 #[doc = " Initialize new @ref mongocrypt_t object.\n\n Set options before using @ref mongocrypt_setopt_kms_provider_local, @ref\n mongocrypt_setopt_kms_provider_aws, or @ref mongocrypt_setopt_log_handler.\n\n @param[in] crypt The @ref mongocrypt_t object.\n\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status Failure may occur if previously\n set\n options are invalid."]
205 pub fn mongocrypt_init(crypt: *mut mongocrypt_t) -> bool;
206}
207unsafe extern "C" {
208 #[doc = " Get the status associated with a @ref mongocrypt_t object.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[out] status Receives the status.\n\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
209 pub fn mongocrypt_status(crypt: *mut mongocrypt_t, status: *mut mongocrypt_status_t) -> bool;
210}
211unsafe extern "C" {
212 #[doc = " Destroy the @ref mongocrypt_t object.\n\n @param[in] crypt The @ref mongocrypt_t object to destroy."]
213 pub fn mongocrypt_destroy(crypt: *mut mongocrypt_t);
214}
215unsafe extern "C" {
216 #[doc = " Obtain a nul-terminated version string of the loaded crypt_shared dynamic\n library, if available.\n\n If no crypt_shared was successfully loaded, this function returns NULL.\n\n @param[in] crypt The mongocrypt_t object after a successful call to\n mongocrypt_init.\n @param[out] len An optional output parameter to which the length of the\n returned string is written. If provided and no crypt_shared library was\n loaded, zero is written to *len.\n\n @return A nul-terminated string of the dynamically loaded crypt_shared\n library.\n\n @note For a numeric value that can be compared against, use\n @ref mongocrypt_crypt_shared_lib_version."]
217 pub fn mongocrypt_crypt_shared_lib_version_string(
218 crypt: *const mongocrypt_t,
219 len: *mut u32,
220 ) -> *const ::std::os::raw::c_char;
221}
222unsafe extern "C" {
223 #[doc = " @brief Obtain a 64-bit constant encoding the version of the loaded\n crypt_shared library, if available.\n\n @param[in] crypt The mongocrypt_t object after a successful call to\n mongocrypt_init.\n\n @return A 64-bit encoded version number, with the version encoded as four\n sixteen-bit integers, or zero if no crypt_shared library was loaded.\n\n The version is encoded as four 16-bit numbers, from high to low:\n\n - Major version\n - Minor version\n - Revision\n - Reserved\n\n For example, version 6.2.1 would be encoded as: 0x0006'0002'0001'0000"]
224 pub fn mongocrypt_crypt_shared_lib_version(crypt: *const mongocrypt_t) -> u64;
225}
226#[repr(C)]
227#[derive(Debug, Copy, Clone)]
228pub struct _mongocrypt_ctx_t {
229 _unused: [u8; 0],
230}
231#[doc = " Manages the state machine for encryption or decryption."]
232pub type mongocrypt_ctx_t = _mongocrypt_ctx_t;
233unsafe extern "C" {
234 #[doc = " Create a new uninitialized @ref mongocrypt_ctx_t.\n\n Initialize the context with functions like @ref mongocrypt_ctx_encrypt_init.\n When done, destroy it with @ref mongocrypt_ctx_destroy.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @returns A new context."]
235 pub fn mongocrypt_ctx_new(crypt: *mut mongocrypt_t) -> *mut mongocrypt_ctx_t;
236}
237unsafe extern "C" {
238 #[doc = " Get the status associated with a @ref mongocrypt_ctx_t object.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[out] status Receives the status.\n\n @returns True if the output is an ok status, false if it is an error\n status.\n\n @see mongocrypt_status_ok"]
239 pub fn mongocrypt_ctx_status(
240 ctx: *mut mongocrypt_ctx_t,
241 status: *mut mongocrypt_status_t,
242 ) -> bool;
243}
244unsafe extern "C" {
245 #[doc = " Set the key id to use for explicit encryption.\n\n It is an error to set both this and the key alt name.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] key_id The binary corresponding to the _id (a UUID) of the data\n key to use from the key vault collection. Note, the UUID must be encoded with\n RFC-4122 byte order. The viewed data is copied. It is valid to destroy\n @p key_id with @ref mongocrypt_binary_destroy immediately after.\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
246 pub fn mongocrypt_ctx_setopt_key_id(
247 ctx: *mut mongocrypt_ctx_t,
248 key_id: *mut mongocrypt_binary_t,
249 ) -> bool;
250}
251unsafe extern "C" {
252 #[doc = " Set the keyAltName to use for explicit encryption or\n data key creation.\n\n Pass the binary encoding a BSON document like the following:\n\n { \"keyAltName\" : (BSON UTF8 value) }\n\n For explicit encryption, it is an error to set both the keyAltName\n and the key id.\n\n For creating data keys, call this function repeatedly to set\n multiple keyAltNames.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] key_alt_name The name to use. The viewed data is copied. It is\n valid to destroy @p key_alt_name with @ref mongocrypt_binary_destroy\n immediately after.\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
253 pub fn mongocrypt_ctx_setopt_key_alt_name(
254 ctx: *mut mongocrypt_ctx_t,
255 key_alt_name: *mut mongocrypt_binary_t,
256 ) -> bool;
257}
258unsafe extern "C" {
259 #[doc = " Set the keyMaterial to use for encrypting data.\n\n Pass the binary encoding of a BSON document like the following:\n\n { \"keyMaterial\" : (BSON BINARY value) }\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] key_material The data encryption key to use. The viewed data is\n copied. It is valid to destroy @p key_material with @ref\n mongocrypt_binary_destroy immediately after.\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
260 pub fn mongocrypt_ctx_setopt_key_material(
261 ctx: *mut mongocrypt_ctx_t,
262 key_material: *mut mongocrypt_binary_t,
263 ) -> bool;
264}
265unsafe extern "C" {
266 #[doc = " Set the algorithm used for encryption to either\n deterministic or random encryption. This value\n should only be set when using explicit encryption.\n\n If -1 is passed in for \"len\", then \"algorithm\" is\n assumed to be a null-terminated string.\n\n Valid values for algorithm are:\n \"AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic\"\n \"AEAD_AES_256_CBC_HMAC_SHA_512-Random\"\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] algorithm A string specifying the algorithm to\n use for encryption.\n @param[in] len The length of the algorithm string.\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
267 pub fn mongocrypt_ctx_setopt_algorithm(
268 ctx: *mut mongocrypt_ctx_t,
269 algorithm: *const ::std::os::raw::c_char,
270 len: ::std::os::raw::c_int,
271 ) -> bool;
272}
273unsafe extern "C" {
274 #[doc = " Identify the AWS KMS master key to use for creating a data key.\n\n This has been superseded by the more flexible:\n @ref mongocrypt_ctx_setopt_key_encryption_key\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] region The AWS region.\n @param[in] region_len The string length of @p region. Pass -1 to determine\n the string length with strlen (must be NULL terminated).\n @param[in] cmk The Amazon Resource Name (ARN) of the customer master key\n (CMK).\n @param[in] cmk_len The string length of @p cmk_len. Pass -1 to determine the\n string length with strlen (must be NULL terminated).\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
275 pub fn mongocrypt_ctx_setopt_masterkey_aws(
276 ctx: *mut mongocrypt_ctx_t,
277 region: *const ::std::os::raw::c_char,
278 region_len: i32,
279 cmk: *const ::std::os::raw::c_char,
280 cmk_len: i32,
281 ) -> bool;
282}
283unsafe extern "C" {
284 #[doc = " Identify a custom AWS endpoint when creating a data key.\n This is used internally to construct the correct HTTP request\n (with the Host header set to this endpoint). This endpoint\n is persisted in the new data key, and will be returned via\n @ref mongocrypt_kms_ctx_endpoint.\n\n This has been superseded by the more flexible:\n @ref mongocrypt_ctx_setopt_key_encryption_key\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] endpoint The endpoint.\n @param[in] endpoint_len The string length of @p endpoint. Pass -1 to\n determine the string length with strlen (must be NULL terminated).\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
285 pub fn mongocrypt_ctx_setopt_masterkey_aws_endpoint(
286 ctx: *mut mongocrypt_ctx_t,
287 endpoint: *const ::std::os::raw::c_char,
288 endpoint_len: i32,
289 ) -> bool;
290}
291unsafe extern "C" {
292 #[doc = " Set the master key to \"local\" for creating a data key.\n This has been superseded by the more flexible:\n @ref mongocrypt_ctx_setopt_key_encryption_key\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
293 pub fn mongocrypt_ctx_setopt_masterkey_local(ctx: *mut mongocrypt_ctx_t) -> bool;
294}
295unsafe extern "C" {
296 #[doc = " Set key encryption key document for creating a data key or for rewrapping\n datakeys.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] bin BSON representing the key encryption key document with\n an additional \"provider\" field. The following forms are accepted:\n\n AWS\n {\n provider: \"aws\",\n region: <string>,\n key: <string>,\n endpoint: <optional string>\n }\n\n Azure\n {\n provider: \"azure\",\n keyVaultEndpoint: <string>,\n keyName: <string>,\n keyVersion: <optional string>\n }\n\n GCP\n {\n provider: \"gcp\",\n projectId: <string>,\n location: <string>,\n keyRing: <string>,\n keyName: <string>,\n keyVersion: <optional string>,\n endpoint: <optional string>\n }\n\n Local\n {\n provider: \"local\"\n }\n\n KMIP\n {\n provider: \"kmip\",\n keyId: <optional string>\n endpoint: <string>\n }\n\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status."]
297 pub fn mongocrypt_ctx_setopt_key_encryption_key(
298 ctx: *mut mongocrypt_ctx_t,
299 bin: *mut mongocrypt_binary_t,
300 ) -> bool;
301}
302unsafe extern "C" {
303 #[doc = " Initialize a context to create a data key.\n\n Associated options:\n - @ref mongocrypt_ctx_setopt_masterkey_aws\n - @ref mongocrypt_ctx_setopt_masterkey_aws_endpoint\n - @ref mongocrypt_ctx_setopt_masterkey_local\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status\n @pre A master key option has been set, and an associated KMS provider\n has been set on the parent @ref mongocrypt_t."]
304 pub fn mongocrypt_ctx_datakey_init(ctx: *mut mongocrypt_ctx_t) -> bool;
305}
306unsafe extern "C" {
307 #[doc = " Initialize a context for encryption.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] db The database name.\n @param[in] db_len The byte length of @p db. Pass -1 to determine the string\n length with strlen (must\n be NULL terminated).\n @param[in] cmd The BSON command to be encrypted. The viewed data is copied.\n It is valid to destroy @p cmd with @ref mongocrypt_binary_destroy immediately\n after.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
308 pub fn mongocrypt_ctx_encrypt_init(
309 ctx: *mut mongocrypt_ctx_t,
310 db: *const ::std::os::raw::c_char,
311 db_len: i32,
312 cmd: *mut mongocrypt_binary_t,
313 ) -> bool;
314}
315unsafe extern "C" {
316 #[doc = " Explicit helper method to encrypt a single BSON object. Contexts\n created for explicit encryption will not go through mongocryptd.\n\n To specify a key_id, algorithm, or iv to use, please use the\n corresponding mongocrypt_setopt methods before calling this.\n\n This method expects the passed-in BSON to be of the form:\n { \"v\" : BSON value to encrypt }\n\n The value of \"v\" is expected to be the BSON value passed to a driver\n ClientEncryption.encrypt helper.\n\n Associated options for FLE 1:\n - @ref mongocrypt_ctx_setopt_key_id\n - @ref mongocrypt_ctx_setopt_key_alt_name\n - @ref mongocrypt_ctx_setopt_algorithm\n\n Associated options for Queryable Encryption:\n - @ref mongocrypt_ctx_setopt_key_id\n - @ref mongocrypt_ctx_setopt_index_key_id\n - @ref mongocrypt_ctx_setopt_contention_factor\n - @ref mongocrypt_ctx_setopt_query_type\n - @ref mongocrypt_ctx_setopt_algorithm_range\n\n An error is returned if FLE 1 and Queryable Encryption incompatible options\n are set.\n\n @param[in] ctx A @ref mongocrypt_ctx_t.\n @param[in] msg A @ref mongocrypt_binary_t the plaintext BSON value. The\n viewed data is copied. It is valid to destroy @p msg with @ref\n mongocrypt_binary_destroy immediately after.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
317 pub fn mongocrypt_ctx_explicit_encrypt_init(
318 ctx: *mut mongocrypt_ctx_t,
319 msg: *mut mongocrypt_binary_t,
320 ) -> bool;
321}
322unsafe extern "C" {
323 #[doc = " Explicit helper method to encrypt a Match Expression or Aggregate Expression.\n Contexts created for explicit encryption will not go through mongocryptd.\n Requires query_type to be \"range\".\n\n This method expects the passed-in BSON to be of the form:\n { \"v\" : FLE2RangeFindDriverSpec }\n\n FLE2RangeFindDriverSpec is a BSON document with one of these forms:\n\n 1. A Match Expression of this form:\n {$and: [{<field>: {<op>: <value1>, {<field>: {<op>: <value2> }}]}\n 2. An Aggregate Expression of this form:\n {$and: [{<op>: [<fieldpath>, <value1>]}, {<op>: [<fieldpath>, <value2>]}]\n\n <op> may be $lt, $lte, $gt, or $gte.\n\n The value of \"v\" is expected to be the BSON value passed to a driver\n ClientEncryption.encryptExpression helper.\n\n Associated options for FLE 1:\n - @ref mongocrypt_ctx_setopt_key_id\n - @ref mongocrypt_ctx_setopt_key_alt_name\n - @ref mongocrypt_ctx_setopt_algorithm\n\n Associated options for Queryable Encryption:\n - @ref mongocrypt_ctx_setopt_key_id\n - @ref mongocrypt_ctx_setopt_index_key_id\n - @ref mongocrypt_ctx_setopt_contention_factor\n - @ref mongocrypt_ctx_setopt_query_type\n - @ref mongocrypt_ctx_setopt_algorithm_range\n\n An error is returned if FLE 1 and Queryable Encryption incompatible options\n are set.\n\n @param[in] ctx A @ref mongocrypt_ctx_t.\n @param[in] msg A @ref mongocrypt_binary_t the plaintext BSON value. The\n viewed data is copied. It is valid to destroy @p msg with @ref\n mongocrypt_binary_destroy immediately after.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
324 pub fn mongocrypt_ctx_explicit_encrypt_expression_init(
325 ctx: *mut mongocrypt_ctx_t,
326 msg: *mut mongocrypt_binary_t,
327 ) -> bool;
328}
329unsafe extern "C" {
330 #[doc = " Initialize a context for decryption.\n\n This method expects the passed-in BSON to be of the form:\n { \"v\" : BSON value to encrypt }\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] doc The document to be decrypted. The viewed data is copied. It is\n valid to destroy @p doc with @ref mongocrypt_binary_destroy immediately\n after.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
331 pub fn mongocrypt_ctx_decrypt_init(
332 ctx: *mut mongocrypt_ctx_t,
333 doc: *mut mongocrypt_binary_t,
334 ) -> bool;
335}
336unsafe extern "C" {
337 #[doc = " Explicit helper method to decrypt a single BSON object.\n\n Pass the binary encoding of a BSON document containing the BSON value to\n encrypt like the following:\n\n { \"v\" : (BSON BINARY value of subtype 6) }\n\n @param[in] ctx A @ref mongocrypt_ctx_t.\n @param[in] msg A @ref mongocrypt_binary_t the encrypted BSON. The viewed data\n is copied. It is valid to destroy @p msg with @ref mongocrypt_binary_destroy\n immediately after."]
338 pub fn mongocrypt_ctx_explicit_decrypt_init(
339 ctx: *mut mongocrypt_ctx_t,
340 msg: *mut mongocrypt_binary_t,
341 ) -> bool;
342}
343unsafe extern "C" {
344 #[doc = " @brief Initialize a context to rewrap datakeys.\n\n Associated options:\n - @ref mongocrypt_ctx_setopt_key_encryption_key\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] filter The filter to use for the find command on the key vault\n collection to retrieve datakeys to rewrap.\n @return A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status."]
345 pub fn mongocrypt_ctx_rewrap_many_datakey_init(
346 ctx: *mut mongocrypt_ctx_t,
347 filter: *mut mongocrypt_binary_t,
348 ) -> bool;
349}
350pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_ERROR: mongocrypt_ctx_state_t = 0;
351pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_NEED_MONGO_COLLINFO: mongocrypt_ctx_state_t = 1;
352pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_NEED_MONGO_COLLINFO_WITH_DB:
353 mongocrypt_ctx_state_t = 8;
354pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_NEED_MONGO_MARKINGS: mongocrypt_ctx_state_t = 2;
355pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_NEED_MONGO_KEYS: mongocrypt_ctx_state_t = 3;
356pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_NEED_KMS: mongocrypt_ctx_state_t = 4;
357pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS: mongocrypt_ctx_state_t = 7;
358pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_READY: mongocrypt_ctx_state_t = 5;
359pub const mongocrypt_ctx_state_t_MONGOCRYPT_CTX_DONE: mongocrypt_ctx_state_t = 6;
360#[doc = " Indicates the state of the @ref mongocrypt_ctx_t. Each state requires\n different handling. See [the integration\n guide](https://github.com/mongodb/libmongocrypt/blob/master/integrating.md#state-machine)\n for information on what to do for each state."]
361pub type mongocrypt_ctx_state_t = ::std::os::raw::c_uint;
362unsafe extern "C" {
363 #[doc = " Get the current state of a context.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @returns A @ref mongocrypt_ctx_state_t."]
364 pub fn mongocrypt_ctx_state(ctx: *mut mongocrypt_ctx_t) -> mongocrypt_ctx_state_t;
365}
366unsafe extern "C" {
367 #[doc = " Get BSON necessary to run the mongo operation when mongocrypt_ctx_t\n is in MONGOCRYPT_CTX_NEED_MONGO_* states.\n\n @p op_bson is a BSON document to be used for the operation.\n - For MONGOCRYPT_CTX_NEED_MONGO_COLLINFO(_WITH_DB) it is a listCollections filter.\n - For MONGOCRYPT_CTX_NEED_MONGO_KEYS it is a find filter.\n - For MONGOCRYPT_CTX_NEED_MONGO_MARKINGS it is a command to send to\n mongocryptd.\n\n The lifetime of @p op_bson is tied to the lifetime of @p ctx. It is valid\n until @ref mongocrypt_ctx_destroy is called.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[out] op_bson A BSON document for the MongoDB operation. The data\n viewed by @p op_bson is guaranteed to be valid until @p ctx is destroyed with\n @ref mongocrypt_ctx_destroy.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
368 pub fn mongocrypt_ctx_mongo_op(
369 ctx: *mut mongocrypt_ctx_t,
370 op_bson: *mut mongocrypt_binary_t,
371 ) -> bool;
372}
373unsafe extern "C" {
374 #[doc = " Get the database to run the mongo operation.\n\n Only applies when mongocrypt_ctx_t is in the state:\n MONGOCRYPT_CTX_NEED_MONGO_COLLINFO_WITH_DB.\n\n The lifetime of the returned string is tied to the lifetime of @p ctx. It is\n valid until @ref mongocrypt_ctx_destroy is called.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @returns A string or NULL. If NULL, an error status is set. Retrieve it with\n @ref mongocrypt_ctx_status"]
375 pub fn mongocrypt_ctx_mongo_db(ctx: *mut mongocrypt_ctx_t) -> *const ::std::os::raw::c_char;
376}
377unsafe extern "C" {
378 #[doc = " Feed a BSON reply or result when mongocrypt_ctx_t is in\n MONGOCRYPT_CTX_NEED_MONGO_* states. This may be called multiple times\n depending on the operation.\n\n reply is a BSON document result being fed back for this operation.\n - For MONGOCRYPT_CTX_NEED_MONGO_COLLINFO(_WITH_DB) it is a doc from a listCollections\n cursor. (Note, if listCollections returned no result, do not call this\n function.)\n - For MONGOCRYPT_CTX_NEED_MONGO_KEYS it is a doc from a find cursor.\n (Note, if find returned no results, do not call this function. reply must\n not\n be NULL.)\n - For MONGOCRYPT_CTX_NEED_MONGO_MARKINGS it is a reply from mongocryptd.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] reply A BSON document for the MongoDB operation. The viewed data\n is copied. It is valid to destroy @p reply with @ref\n mongocrypt_binary_destroy immediately after.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
379 pub fn mongocrypt_ctx_mongo_feed(
380 ctx: *mut mongocrypt_ctx_t,
381 reply: *mut mongocrypt_binary_t,
382 ) -> bool;
383}
384unsafe extern "C" {
385 #[doc = " Call when done feeding the reply (or replies) back to the context.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
386 pub fn mongocrypt_ctx_mongo_done(ctx: *mut mongocrypt_ctx_t) -> bool;
387}
388#[repr(C)]
389#[derive(Debug, Copy, Clone)]
390pub struct _mongocrypt_kms_ctx_t {
391 _unused: [u8; 0],
392}
393#[doc = " Manages a single KMS HTTP request/response."]
394pub type mongocrypt_kms_ctx_t = _mongocrypt_kms_ctx_t;
395unsafe extern "C" {
396 #[doc = " Get the next KMS handle.\n\n Multiple KMS handles may be retrieved at once. Drivers may do this to fan\n out multiple concurrent KMS HTTP requests. Feeding multiple KMS requests\n is thread-safe.\n\n If KMS handles are being handled synchronously, the driver can reuse the same\n TLS socket to send HTTP requests and receive responses.\n\n The returned KMS handle does not outlive `ctx`.\n\n @param[in] ctx A @ref mongocrypt_ctx_t.\n @returns a new @ref mongocrypt_kms_ctx_t or NULL."]
397 pub fn mongocrypt_ctx_next_kms_ctx(ctx: *mut mongocrypt_ctx_t) -> *mut mongocrypt_kms_ctx_t;
398}
399unsafe extern "C" {
400 #[doc = " Get the HTTP request message for a KMS handle.\n\n The lifetime of @p msg is tied to the lifetime of @p kms. It is valid\n until @ref mongocrypt_ctx_kms_done is called.\n\n @param[in] kms A @ref mongocrypt_kms_ctx_t.\n @param[out] msg The HTTP request to send to KMS. The data viewed by @p msg is\n guaranteed to be valid until the call of @ref mongocrypt_ctx_kms_done of the\n parent @ref mongocrypt_ctx_t.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_kms_ctx_status"]
401 pub fn mongocrypt_kms_ctx_message(
402 kms: *mut mongocrypt_kms_ctx_t,
403 msg: *mut mongocrypt_binary_t,
404 ) -> bool;
405}
406unsafe extern "C" {
407 #[doc = " Get the hostname from which to connect over TLS.\n\n The storage for @p endpoint is not owned by the caller, but\n is valid until calling @ref mongocrypt_ctx_kms_done.\n\n @param[in] kms A @ref mongocrypt_kms_ctx_t.\n @param[out] endpoint The output endpoint as a NULL terminated string.\n The endpoint consists of a hostname and port separated by a colon.\n E.g. \"example.com:123\". A port is always present.\n\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_kms_ctx_status"]
408 pub fn mongocrypt_kms_ctx_endpoint(
409 kms: *mut mongocrypt_kms_ctx_t,
410 endpoint: *mut *const ::std::os::raw::c_char,
411 ) -> bool;
412}
413unsafe extern "C" {
414 #[doc = " Indicates how many bytes to feed into @ref mongocrypt_kms_ctx_feed.\n\n @param[in] kms The @ref mongocrypt_kms_ctx_t.\n @returns The number of requested bytes."]
415 pub fn mongocrypt_kms_ctx_bytes_needed(kms: *mut mongocrypt_kms_ctx_t) -> u32;
416}
417unsafe extern "C" {
418 #[doc = " Indicates how long to sleep before sending this request.\n\n @param[in] kms The @ref mongocrypt_kms_ctx_t.\n @returns How long to sleep in microseconds."]
419 pub fn mongocrypt_kms_ctx_usleep(kms: *mut mongocrypt_kms_ctx_t) -> i64;
420}
421unsafe extern "C" {
422 #[doc = " Feed bytes from the HTTP response.\n\n Feeding more bytes than what has been returned in @ref\n mongocrypt_kms_ctx_bytes_needed is an error.\n\n @param[in] kms The @ref mongocrypt_kms_ctx_t.\n @param[in] bytes The bytes to feed. The viewed data is copied. It is valid to\n destroy @p bytes with @ref mongocrypt_binary_destroy immediately after.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_kms_ctx_status"]
423 pub fn mongocrypt_kms_ctx_feed(
424 kms: *mut mongocrypt_kms_ctx_t,
425 bytes: *mut mongocrypt_binary_t,
426 ) -> bool;
427}
428unsafe extern "C" {
429 #[doc = " Indicate a network-level failure.\n\n @param[in] kms The @ref mongocrypt_kms_ctx_t.\n @return A boolean indicating whether the failed request may be retried."]
430 pub fn mongocrypt_kms_ctx_fail(kms: *mut mongocrypt_kms_ctx_t) -> bool;
431}
432unsafe extern "C" {
433 #[doc = " Get the status associated with a @ref mongocrypt_kms_ctx_t object.\n\n @param[in] kms The @ref mongocrypt_kms_ctx_t object.\n @param[out] status Receives the status.\n\n @returns A boolean indicating success. If false, an error status is set."]
434 pub fn mongocrypt_kms_ctx_status(
435 kms: *mut mongocrypt_kms_ctx_t,
436 status: *mut mongocrypt_status_t,
437 ) -> bool;
438}
439unsafe extern "C" {
440 #[doc = " Get the KMS provider identifier associated with this KMS request.\n\n This is used to conditionally configure TLS connections based on the KMS\n request. It is useful for KMIP, which authenticates with a client\n certificate.\n\n @param[in] kms The @ref mongocrypt_kms_ctx_t object.\n @param[out] len Receives the length of the returned string. It may be NULL.\n If it is not NULL, it is set to the length of the returned string without\n the NULL terminator.\n\n @returns One of the NULL terminated static strings: \"aws\", \"azure\", \"gcp\", or\n \"kmip\"."]
441 pub fn mongocrypt_kms_ctx_get_kms_provider(
442 kms: *mut mongocrypt_kms_ctx_t,
443 len: *mut u32,
444 ) -> *const ::std::os::raw::c_char;
445}
446unsafe extern "C" {
447 #[doc = " Call when done handling all KMS contexts.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
448 pub fn mongocrypt_ctx_kms_done(ctx: *mut mongocrypt_ctx_t) -> bool;
449}
450unsafe extern "C" {
451 #[doc = " Call in response to the MONGOCRYPT_CTX_NEED_KMS_CREDENTIALS state\n to set per-context KMS provider settings. These follow the same format\n as @ref mongocrypt_setopt_kms_providers. If no keys are present in the\n BSON input, the KMS provider settings configured for the @ref mongocrypt_t\n at initialization are used.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] kms_providers_definition A BSON document mapping the KMS provider\n names to credentials.\n\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status."]
452 pub fn mongocrypt_ctx_provide_kms_providers(
453 ctx: *mut mongocrypt_ctx_t,
454 kms_providers_definition: *mut mongocrypt_binary_t,
455 ) -> bool;
456}
457unsafe extern "C" {
458 #[doc = " Perform the final encryption or decryption.\n\n @param[in] ctx A @ref mongocrypt_ctx_t.\n @param[out] out The final BSON. The data viewed by @p out is guaranteed\n to be valid until @p ctx is destroyed with @ref mongocrypt_ctx_destroy.\n The meaning of this BSON depends on the type of @p ctx.\n\n If @p ctx was initialized with @ref mongocrypt_ctx_encrypt_init, then\n this BSON is the (possibly) encrypted command to send to the server.\n\n If @p ctx was initialized with @ref mongocrypt_ctx_decrypt_init, then\n this BSON is the decrypted result to return to the user.\n\n If @p ctx was initialized with @ref mongocrypt_ctx_explicit_encrypt_init,\n then this BSON has the form { \"v\": (BSON binary) } where the BSON binary\n is the resulting encrypted value.\n\n If @p ctx was initialized with @ref mongocrypt_ctx_explicit_decrypt_init,\n then this BSON has the form { \"v\": (BSON value) } where the BSON value\n is the resulting decrypted value.\n\n If @p ctx was initialized with @ref mongocrypt_ctx_datakey_init, then\n this BSON is the document containing the new data key to be inserted into\n the key vault collection.\n\n If @p ctx was initialized with @ref mongocrypt_ctx_rewrap_many_datakey_init,\n then this BSON has the form:\n { \"v\": [{ \"_id\": ..., \"keyMaterial\": ..., \"masterKey\": ... }, ...] }\n where each BSON document in the array contains the updated fields of a\n rewrapped datakey to be bulk-updated into the key vault collection.\n Note: the updateDate field should be updated using the $currentDate operator.\n\n @returns a bool indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
459 pub fn mongocrypt_ctx_finalize(
460 ctx: *mut mongocrypt_ctx_t,
461 out: *mut mongocrypt_binary_t,
462 ) -> bool;
463}
464unsafe extern "C" {
465 #[doc = " Destroy and free all memory associated with a @ref mongocrypt_ctx_t.\n\n @param[in] ctx A @ref mongocrypt_ctx_t."]
466 pub fn mongocrypt_ctx_destroy(ctx: *mut mongocrypt_ctx_t);
467}
468#[doc = " An crypto AES-256-CBC encrypt or decrypt function.\n\n Note, @p in is already padded. Encrypt with padding disabled.\n @param[in] ctx An optional context object that may have been set when hooks\n were enabled.\n @param[in] key An encryption key (32 bytes for AES_256).\n @param[in] iv An initialization vector (16 bytes for AES_256);\n @param[in] in The input.\n @param[out] out A preallocated byte array for the output. See @ref\n mongocrypt_binary_data.\n @param[out] bytes_written Set this to the number of bytes written to @p out.\n @param[out] status An optional status to pass error messages. See @ref\n mongocrypt_status_set.\n @returns A boolean indicating success. If returning false, set @p status\n with a message indicating the error using @ref mongocrypt_status_set."]
469pub type mongocrypt_crypto_fn = ::std::option::Option<
470 unsafe extern "C" fn(
471 ctx: *mut ::std::os::raw::c_void,
472 key: *mut mongocrypt_binary_t,
473 iv: *mut mongocrypt_binary_t,
474 in_: *mut mongocrypt_binary_t,
475 out: *mut mongocrypt_binary_t,
476 bytes_written: *mut u32,
477 status: *mut mongocrypt_status_t,
478 ) -> bool,
479>;
480#[doc = " A crypto signature or HMAC function.\n\n Currently used in callbacks for HMAC SHA-512, HMAC SHA-256, and RSA SHA-256\n signature.\n\n @param[in] ctx An optional context object that may have been set when hooks\n were enabled.\n @param[in] key An encryption key (32 bytes for HMAC_SHA512).\n @param[in] in The input.\n @param[out] out A preallocated byte array for the output. See @ref\n mongocrypt_binary_data.\n @param[out] status An optional status to pass error messages. See @ref\n mongocrypt_status_set.\n @returns A boolean indicating success. If returning false, set @p status\n with a message indicating the error using @ref mongocrypt_status_set."]
481pub type mongocrypt_hmac_fn = ::std::option::Option<
482 unsafe extern "C" fn(
483 ctx: *mut ::std::os::raw::c_void,
484 key: *mut mongocrypt_binary_t,
485 in_: *mut mongocrypt_binary_t,
486 out: *mut mongocrypt_binary_t,
487 status: *mut mongocrypt_status_t,
488 ) -> bool,
489>;
490#[doc = " A crypto hash (SHA-256) function.\n\n @param[in] ctx An optional context object that may have been set when hooks\n were enabled.\n @param[in] in The input.\n @param[out] out A preallocated byte array for the output. See @ref\n mongocrypt_binary_data.\n @param[out] status An optional status to pass error messages. See @ref\n mongocrypt_status_set.\n @returns A boolean indicating success. If returning false, set @p status\n with a message indicating the error using @ref mongocrypt_status_set."]
491pub type mongocrypt_hash_fn = ::std::option::Option<
492 unsafe extern "C" fn(
493 ctx: *mut ::std::os::raw::c_void,
494 in_: *mut mongocrypt_binary_t,
495 out: *mut mongocrypt_binary_t,
496 status: *mut mongocrypt_status_t,
497 ) -> bool,
498>;
499#[doc = " A crypto secure random function.\n\n @param[in] ctx An optional context object that may have been set when hooks\n were enabled.\n @param[out] out A preallocated byte array for the output. See @ref\n mongocrypt_binary_data.\n @param[in] count The number of random bytes requested.\n @param[out] status An optional status to pass error messages. See @ref\n mongocrypt_status_set.\n @returns A boolean indicating success. If returning false, set @p status\n with a message indicating the error using @ref mongocrypt_status_set."]
500pub type mongocrypt_random_fn = ::std::option::Option<
501 unsafe extern "C" fn(
502 ctx: *mut ::std::os::raw::c_void,
503 out: *mut mongocrypt_binary_t,
504 count: u32,
505 status: *mut mongocrypt_status_t,
506 ) -> bool,
507>;
508unsafe extern "C" {
509 pub fn mongocrypt_setopt_crypto_hooks(
510 crypt: *mut mongocrypt_t,
511 aes_256_cbc_encrypt: mongocrypt_crypto_fn,
512 aes_256_cbc_decrypt: mongocrypt_crypto_fn,
513 random: mongocrypt_random_fn,
514 hmac_sha_512: mongocrypt_hmac_fn,
515 hmac_sha_256: mongocrypt_hmac_fn,
516 sha_256: mongocrypt_hash_fn,
517 ctx: *mut ::std::os::raw::c_void,
518 ) -> bool;
519}
520unsafe extern "C" {
521 #[doc = " Set a crypto hook for the AES256-CTR operations.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] aes_256_ctr_encrypt The crypto callback function for encrypt\n operation.\n @param[in] aes_256_ctr_decrypt The crypto callback function for decrypt\n operation.\n @param[in] ctx Unused.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_status\n"]
522 pub fn mongocrypt_setopt_aes_256_ctr(
523 crypt: *mut mongocrypt_t,
524 aes_256_ctr_encrypt: mongocrypt_crypto_fn,
525 aes_256_ctr_decrypt: mongocrypt_crypto_fn,
526 ctx: *mut ::std::os::raw::c_void,
527 ) -> bool;
528}
529unsafe extern "C" {
530 #[doc = " Set an AES256-ECB crypto hook for the AES256-CTR operations. If CTR hook was\n configured using @ref mongocrypt_setopt_aes_256_ctr, ECB hook will be\n ignored.\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] aes_256_ecb_encrypt The crypto callback function for encrypt\n operation.\n @param[in] ctx Unused.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_status\n"]
531 pub fn mongocrypt_setopt_aes_256_ecb(
532 crypt: *mut mongocrypt_t,
533 aes_256_ecb_encrypt: mongocrypt_crypto_fn,
534 ctx: *mut ::std::os::raw::c_void,
535 ) -> bool;
536}
537unsafe extern "C" {
538 #[doc = " Set a crypto hook for the RSASSA-PKCS1-v1_5 algorithm with a SHA-256 hash.\n\n See: https://tools.ietf.org/html/rfc3447#section-8.2\n\n Note: this function has the wrong name. It should be:\n mongocrypt_setopt_crypto_hook_sign_rsassa_pkcs1_v1_5\n\n @param[in] crypt The @ref mongocrypt_t object.\n @param[in] sign_rsaes_pkcs1_v1_5 The crypto callback function.\n @param[in] sign_ctx A context passed as an argument to the crypto callback\n every invocation.\n @pre @ref mongocrypt_init has not been called on @p crypt.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_status\n"]
539 pub fn mongocrypt_setopt_crypto_hook_sign_rsaes_pkcs1_v1_5(
540 crypt: *mut mongocrypt_t,
541 sign_rsaes_pkcs1_v1_5: mongocrypt_hmac_fn,
542 sign_ctx: *mut ::std::os::raw::c_void,
543 ) -> bool;
544}
545unsafe extern "C" {
546 #[doc = " @brief Opt-into skipping query analysis.\n\n If opted in:\n - The crypt_shared library will not attempt to be loaded.\n - A mongocrypt_ctx_t will never enter the MONGOCRYPT_CTX_NEED_MARKINGS state.\n\n @param[in] crypt The @ref mongocrypt_t object to update"]
547 pub fn mongocrypt_setopt_bypass_query_analysis(crypt: *mut mongocrypt_t);
548}
549unsafe extern "C" {
550 #[doc = " DEPRECATED: Use of `mongocrypt_setopt_use_range_v2` is deprecated. Range V2 is always enabled.\n\n @param[in] crypt The @ref mongocrypt_t object.\n\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_status"]
551 pub fn mongocrypt_setopt_use_range_v2(crypt: *mut mongocrypt_t) -> bool;
552}
553unsafe extern "C" {
554 #[doc = " Set the contention factor used for explicit encryption.\n The contention factor is only used for indexed Queryable Encryption.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] contention_factor\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status."]
555 pub fn mongocrypt_ctx_setopt_contention_factor(
556 ctx: *mut mongocrypt_ctx_t,
557 contention_factor: i64,
558 ) -> bool;
559}
560unsafe extern "C" {
561 #[doc = " Set the index key id to use for explicit Queryable Encryption.\n\n If the index key id not set, the key id from @ref\n mongocrypt_ctx_setopt_key_id is used.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] key_id The binary corresponding to the _id (a UUID) of the data\n key to use from the key vault collection. Note, the UUID must be encoded with\n RFC-4122 byte order. The viewed data is copied. It is valid to destroy\n @p key_id with @ref mongocrypt_binary_destroy immediately after.\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
562 pub fn mongocrypt_ctx_setopt_index_key_id(
563 ctx: *mut mongocrypt_ctx_t,
564 key_id: *mut mongocrypt_binary_t,
565 ) -> bool;
566}
567unsafe extern "C" {
568 #[doc = " Set the query type to use for explicit Queryable Encryption.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] query_type The query type string\n @param[in] len The length of query_type, or -1 for automatic\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
569 pub fn mongocrypt_ctx_setopt_query_type(
570 ctx: *mut mongocrypt_ctx_t,
571 query_type: *const ::std::os::raw::c_char,
572 len: ::std::os::raw::c_int,
573 ) -> bool;
574}
575unsafe extern "C" {
576 #[doc = " Set options for explicit encryption with the \"range\" algorithm.\n\n @p opts is a BSON document of the form:\n {\n \"min\": Optional<BSON value>,\n \"max\": Optional<BSON value>,\n \"sparsity\": Optional<Int64>,\n \"precision\": Optional<Int32>,\n \"trimFactor\": Optional<Int32>\n }\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] opts BSON.\n @pre @p ctx has not been initialized.\n @returns A boolean indicating success. If false, an error status is set.\n Retrieve it with @ref mongocrypt_ctx_status"]
577 pub fn mongocrypt_ctx_setopt_algorithm_range(
578 ctx: *mut mongocrypt_ctx_t,
579 opts: *mut mongocrypt_binary_t,
580 ) -> bool;
581}
582unsafe extern "C" {
583 #[doc = " Set options for explicit encryption with the \"textPreview\" algorithm.\n\n NOTE: \"textPreview\" is experimental only and may be removed in a future non-major release.\n @p opts is a BSON document of the form:\n {\n \"caseSensitive\": bool,\n . \"diacriticSensitive\": bool,\n . \"prefix\": Optional{\n . \"strMaxQueryLength\": Int32,\n . \"strMinQueryLength\": Int32,\n . },\n . \"suffix\": Optional{\n . \"strMaxQueryLength\": Int32,\n . \"strMinQueryLength\": Int32,\n . },\n . \"substring\": Optional{\n . \"strMaxLength\": Int32,\n . \"strMaxQueryLength\": Int32,\n . \"strMinQueryLength\": Int32,\n . },\n }\n\n \"prefix\" and \"suffix\" can both be set."]
584 pub fn mongocrypt_ctx_setopt_algorithm_text(
585 ctx: *mut mongocrypt_ctx_t,
586 opts: *mut mongocrypt_binary_t,
587 ) -> bool;
588}
589unsafe extern "C" {
590 #[doc = " Set the expiration time for the data encryption key cache. Defaults to 60 seconds if not set.\n\n @param[in] ctx The @ref mongocrypt_ctx_t object.\n @param[in] cache_expiration_ms The cache expiration time in milliseconds. If zero, the cache\n never expires."]
591 pub fn mongocrypt_setopt_key_expiration(
592 crypt: *mut mongocrypt_t,
593 cache_expiration_ms: u64,
594 ) -> bool;
595}