MongoDB C++ Driver  mongocxx-3.7.0
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/stdx.hpp>
21 
22 #include <mongocxx/config/prelude.hpp>
23 
24 namespace mongocxx {
25 MONGOCXX_INLINE_NAMESPACE_BEGIN
26 
27 class client_encryption;
28 
29 namespace options {
30 
34 class MONGOCXX_API encrypt {
35  public:
53 
66  encrypt& key_alt_name(std::string name);
67 
74  const stdx::optional<std::string>& key_alt_name() const;
75 
80  enum class encryption_algorithm : std::uint8_t {
84  k_deterministic,
85 
89  k_random
90  };
91 
101  encrypt& algorithm(encryption_algorithm algorithm);
102 
109  const stdx::optional<encryption_algorithm>& algorithm() const;
110 
117  const stdx::optional<bsoncxx::types::bson_value::view_or_value>& key_id() const;
118 
119  private:
120  friend class mongocxx::client_encryption;
121  MONGOCXX_PRIVATE void* convert() const;
122 
123  stdx::optional<bsoncxx::types::bson_value::view_or_value> _key_id;
124  stdx::optional<std::string> _key_alt_name;
125  stdx::optional<encryption_algorithm> _algorithm;
126 };
127 
128 } // namespace options
129 MONGOCXX_INLINE_NAMESPACE_END
130 } // namespace mongocxx
131 
132 #include <mongocxx/config/postlude.hpp>
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
bsoncxx::view_or_value
Class representing a view-or-value variant type.
Definition: view_or_value.hpp:30
mongocxx::options::encrypt
Class representing options for explicit client-side encryption.
Definition: encrypt.hpp:34
mongocxx::options::encrypt::encryption_algorithm
encryption_algorithm
Determines which AEAD_AES_256_CBC algorithm to use with HMAC_SHA_512 when encrypting data.
Definition: encrypt.hpp:80
mongocxx::client_encryption
Class supporting operations for MongoDB Client-Side Field Level Encryption.
Definition: client_encryption.hpp:31