MongoDB C++ Driver mongocxx-3.6.7
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 <mongocxx/config/prelude.hpp>
18
19#include <bsoncxx/stdx/optional.hpp>
20#include <bsoncxx/types.hpp>
21#include <bsoncxx/types/bson_value/view_or_value.hpp>
22#include <mongocxx/stdx.hpp>
23
24namespace mongocxx {
25MONGOCXX_INLINE_NAMESPACE_BEGIN
26
27class client_encryption;
28
29namespace options {
30
34class 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
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
129MONGOCXX_INLINE_NAMESPACE_END
130} // namespace mongocxx
131
132#include <mongocxx/config/postlude.hpp>
Class representing a view-or-value variant type.
Definition: view_or_value.hpp:30
Definition: client_encryption.hpp:28
Class representing options for explicit client-side encryption.
Definition: encrypt.hpp:34
const stdx::optional< std::string > & key_alt_name() const
Gets the current key alt name.
encrypt & key_id(bsoncxx::types::bson_value::view_or_value key_id)
Sets the key to use for this encryption operation.
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< bsoncxx::types::bson_value::view_or_value > & key_id() const
Gets the key_id.
encryption_algorithm
Determines which AEAD_AES_256_CBC algorithm to use with HMAC_SHA_512 when encrypting data.
Definition: encrypt.hpp:80
encrypt & algorithm(encryption_algorithm algorithm)
Sets the algorithm to use for encryption.
const stdx::optional< encryption_algorithm > & algorithm() const
Gets the current algorithm.
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24