MongoDB C++ Driver  mongocxx-3.10.2
data_key.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 <string>
18 #include <vector>
19 
20 #include <mongocxx/client_encryption-fwd.hpp>
21 #include <mongocxx/options/data_key-fwd.hpp>
22 
23 #include <bsoncxx/document/view_or_value.hpp>
24 #include <bsoncxx/stdx/optional.hpp>
25 #include <mongocxx/stdx.hpp>
26 
27 #include <mongocxx/config/prelude.hpp>
28 
29 namespace mongocxx {
30 namespace v_noabi {
31 namespace options {
32 
36 class data_key {
37  public:
75  // keyId: Optional<String>, // keyId is the KMIP Unique Identifier to a 96 byte KMIP Secret
76  // // Data managed object.If keyId is omitted, the driver creates a
77  // // random 96 byte KMIP Secret Data managed object.
78  // endpoint: Optional<String> // Host with optional port.
93 
100  const stdx::optional<bsoncxx::v_noabi::document::view_or_value>& master_key() const;
101 
115  data_key& key_alt_names(std::vector<std::string> key_alt_names);
116 
123  const std::vector<std::string>& key_alt_names() const;
124 
143  using key_material_type = std::vector<uint8_t>;
145 
154  const stdx::optional<key_material_type>& key_material();
155 
156  private:
157  friend ::mongocxx::v_noabi::client_encryption;
158 
159  MONGOCXX_PRIVATE void* convert() const;
160 
161  stdx::optional<bsoncxx::v_noabi::document::view_or_value> _master_key;
162  std::vector<std::string> _key_alt_names;
163  stdx::optional<key_material_type> _key_material;
164 };
165 
166 } // namespace options
167 } // namespace v_noabi
168 } // namespace mongocxx
169 
170 // CXX-2770: missing include of postlude header.
171 #if defined(MONGOCXX_TEST_MACRO_GUARDS_FIX_MISSING_POSTLUDE)
172 #include <mongocxx/config/postlude.hpp>
173 #endif
Class representing options for data key generation for encryption.
Definition: data_key.hpp:36
data_key & master_key(bsoncxx::v_noabi::document::view_or_value master_key)
Sets a KMS-specific key used to encrypt the new data key.
std::vector< uint8_t > key_material_type
Sets the binary data for the key material.
Definition: data_key.hpp:143
const stdx::optional< bsoncxx::v_noabi::document::view_or_value > & master_key() const
Gets the master key.
const stdx::optional< key_material_type > & key_material()
Gets the keyMaterial as binary data.
const std::vector< std::string > & key_alt_names() const
Gets the alternate names for the data key.
data_key & key_alt_names(std::vector< std::string > key_alt_names)
Sets an optional list of string alternate names used to reference the key.
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19