Function mongocrypt_sys::mongocrypt_ctx_finalize

source ·
pub unsafe extern "C" fn mongocrypt_ctx_finalize(
    ctx: *mut mongocrypt_ctx_t,
    out: *mut mongocrypt_binary_t,
) -> bool
Expand description

Perform the final encryption or decryption.

@param[in] ctx A @ref mongocrypt_ctx_t. @param[out] out The final BSON. The data viewed by @p out is guaranteed to be valid until @p ctx is destroyed with @ref mongocrypt_ctx_destroy. The meaning of this BSON depends on the type of @p ctx.

If @p ctx was initialized with @ref mongocrypt_ctx_encrypt_init, then this BSON is the (possibly) encrypted command to send to the server.

If @p ctx was initialized with @ref mongocrypt_ctx_decrypt_init, then this BSON is the decrypted result to return to the user.

If @p ctx was initialized with @ref mongocrypt_ctx_explicit_encrypt_init, then this BSON has the form { “v”: (BSON binary) } where the BSON binary is the resulting encrypted value.

If @p ctx was initialized with @ref mongocrypt_ctx_explicit_decrypt_init, then this BSON has the form { “v”: (BSON value) } where the BSON value is the resulting decrypted value.

If @p ctx was initialized with @ref mongocrypt_ctx_datakey_init, then this BSON is the document containing the new data key to be inserted into the key vault collection.

If @p ctx was initialized with @ref mongocrypt_ctx_rewrap_many_datakey_init, then this BSON has the form: { “v”: [{ “_id”: …, “keyMaterial”: …, “masterKey”: … }, …] } where each BSON document in the array contains the updated fields of a rewrapped datakey to be bulk-updated into the key vault collection. Note: the updateDate field should be updated using the $currentDate operator.

@returns a bool indicating success. If false, an error status is set. Retrieve it with @ref mongocrypt_ctx_status