MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
encrypt.hpp
1 // Copyright 2020 MongoDB Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <bsoncxx/stdx/optional.hpp>
18 #include <bsoncxx/types.hpp>
19 #include <bsoncxx/types/bson_value/view_or_value.hpp>
20 #include <mongocxx/options/range.hpp>
21 #include <mongocxx/stdx.hpp>
22 
23 #include <mongocxx/config/prelude.hpp>
24 
25 namespace mongocxx {
26 inline namespace v_noabi {
27 class client_encryption;
28 
29 namespace options {
30 
34 class MONGOCXX_API encrypt {
35  public:
53 
60  const stdx::optional<bsoncxx::types::bson_value::view_or_value>& key_id() const;
61 
74  encrypt& key_alt_name(std::string name);
75 
82  const stdx::optional<std::string>& key_alt_name() const;
83 
88  enum class encryption_algorithm : std::uint8_t {
92  k_deterministic,
93 
97  k_random,
98 
102  k_indexed,
103 
107  k_unindexed,
108 
115  k_range_preview,
116  };
117 
122  enum class encryption_query_type : std::uint8_t {
124  k_equality,
125 
129  k_range_preview,
130  };
131 
149 
158  const stdx::optional<encryption_algorithm>& algorithm() const;
159 
168  encrypt& contention_factor(int64_t contention_factor);
169 
176  const stdx::optional<int64_t>& contention_factor() const;
177 
187 
194  const stdx::optional<encryption_query_type>& query_type() const;
195 
205 
217  const stdx::optional<options::range>& range_opts() const;
218 
219  private:
220  friend class mongocxx::client_encryption;
221  MONGOCXX_PRIVATE void* convert() const;
222 
223  stdx::optional<bsoncxx::types::bson_value::view_or_value> _key_id;
224  stdx::optional<std::string> _key_alt_name;
225  stdx::optional<encryption_algorithm> _algorithm;
226  stdx::optional<int64_t> _contention_factor;
227  stdx::optional<encryption_query_type> _query_type;
228  stdx::optional<options::range> _range_opts;
229 };
230 
231 } // namespace options
232 } // namespace v_noabi
233 } // namespace mongocxx
234 
235 #include <mongocxx/config/postlude.hpp>
Class representing a view-or-value variant type.
Definition: view_or_value.hpp:29
Class supporting operations for MongoDB Client-Side Field Level Encryption.
Definition: client_encryption.hpp:38
Class representing options for explicit client-side encryption.
Definition: encrypt.hpp:34
encrypt & query_type(encryption_query_type query_type)
Sets the query type to use for encryption.
const stdx::optional< bsoncxx::types::bson_value::view_or_value > & key_id() const
Gets the key_id.
const stdx::optional< encryption_query_type > & query_type() const
Gets the current query type.
encrypt & key_alt_name(std::string name)
Sets a name by which to lookup a key from the key vault collection to use for this encryption operati...
const stdx::optional< int64_t > & contention_factor() const
Gets the current contention factor.
encryption_query_type
queryType only applies when algorithm is "indexed" or "rangePreview".
Definition: encrypt.hpp:122
encrypt & key_id(bsoncxx::types::bson_value::view_or_value key_id)
Sets the key to use for this encryption operation.
encrypt & range_opts(options::range opts)
Sets the range options to use for encryption.
encrypt & contention_factor(int64_t contention_factor)
Sets the contention factor to use for encryption.
const stdx::optional< encryption_algorithm > & algorithm() const
Gets the current algorithm.
const stdx::optional< options::range > & range_opts() const
Gets the current range options.
const stdx::optional< std::string > & key_alt_name() const
Gets the current key alt name.
encryption_algorithm
Determines which AEAD_AES_256_CBC algorithm to use with HMAC_SHA_512 when encrypting data.
Definition: encrypt.hpp:88
encrypt & algorithm(encryption_algorithm algorithm)
Sets the algorithm to use for encryption.
RangeOpts specifies index options for a Queryable Encryption field supporting "rangePreview" queries.
Definition: range.hpp:41
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24