MongoDB C++ Driver mongocxx-3.6.7
Public Member Functions | List of all members
mongocxx::client_encryption Class Reference

Public Member Functions

 client_encryption (options::client_encryption opts)
 Creates a client_encryption object. More...
 
 ~client_encryption () noexcept
 Destroys a client_encryption.
 
bsoncxx::types::bson_value::value create_data_key (std::string kms_provider, const options::data_key &opts={})
 Creates a new key document and inserts into the key vault collection. More...
 
bsoncxx::types::bson_value::value encrypt (bsoncxx::types::bson_value::view value, const options::encrypt &opts)
 Encrypts a BSON value with a given key and algorithm. More...
 
bsoncxx::types::bson_value::value decrypt (bsoncxx::types::bson_value::view value)
 Decrypts an encrypted value (BSON binary of subtype 6). More...
 

Constructor & Destructor Documentation

◆ client_encryption()

mongocxx::client_encryption::client_encryption ( options::client_encryption  opts)

Creates a client_encryption object.

Parameters
optsAn object representing encryption options.
See also
https://docs.mongodb.com/ecosystem/use-cases/client-side-field-level-encryption-guide

Member Function Documentation

◆ create_data_key()

bsoncxx::types::bson_value::value mongocxx::client_encryption::create_data_key ( std::string  kms_provider,
const options::data_key opts = {} 
)

Creates a new key document and inserts into the key vault collection.

Parameters
kms_providerA string identifying the KMS service to use to encrypt the datakey (must be "aws" or "local")
optsOptional arguments, see options::data_key.
Returns
The id of the created document as a bson_value::value containing a UUID (BSON binary subtype 4).
Exceptions
mongocxx::exceptionif there is an error creating the key.
See also
https://docs.mongodb.com/ecosystem/use-cases/client-side-field-level-encryption-guide/#b-create-a-data-encryption-key

◆ decrypt()

bsoncxx::types::bson_value::value mongocxx::client_encryption::decrypt ( bsoncxx::types::bson_value::view  value)

Decrypts an encrypted value (BSON binary of subtype 6).

Parameters
Theencrypted value.
Returns
The original BSON value.
Exceptions
mongocxx::exceptionif there is an error decrypting the value.
See also
https://docs.mongodb.com/manual/reference/method/ClientEncryption.decrypt/#ClientEncryption.decrypt

◆ encrypt()

bsoncxx::types::bson_value::value mongocxx::client_encryption::encrypt ( bsoncxx::types::bson_value::view  value,
const options::encrypt opts 
)

Encrypts a BSON value with a given key and algorithm.

Parameters
valueThe BSON value to encrypt.
optsOptions must be given in order to specify an encryption algorithm and a key_id or key_alt_name. See options::encrypt.
Returns
The encrypted value (BSON binary subtype 6).
Exceptions
mongocxx::exceptionif there is an error encrypting the value.
See also
https://docs.mongodb.com/manual/reference/method/ClientEncryption.encrypt/#ClientEncryption.encrypt

The documentation for this class was generated from the following file: