iceberg-cpp
Loading...
Searching...
No Matches
in_memory_kms.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
24
25#include <cstdint>
26#include <span>
27#include <string>
28#include <string_view>
29#include <unordered_map>
30#include <vector>
31
34
35namespace iceberg {
36
42class ICEBERG_BUNDLE_EXPORT InMemoryKms : public KeyManagementClient {
43 public:
45 static constexpr std::string_view kName = "in-memory";
48 static constexpr std::string_view kKeyPropertyPrefix = "encryption.in-memory-kms.key.";
49
50 InMemoryKms() = default;
51 explicit InMemoryKms(std::unordered_map<std::string, std::vector<uint8_t>> master_keys)
52 : master_keys_(std::move(master_keys)) {}
53
55 static void Register();
56
59 const std::unordered_map<std::string, std::string>& properties) override;
60
61 Result<std::vector<uint8_t>> WrapKey(std::span<const uint8_t> key,
62 std::string_view wrapping_key_id) override;
63 Result<std::vector<uint8_t>> UnwrapKey(std::span<const uint8_t> wrapped_key,
64 std::string_view wrapping_key_id) override;
65
66 private:
67 Result<const std::vector<uint8_t>*> MasterKey(std::string_view id) const;
68
69 std::unordered_map<std::string, std::vector<uint8_t>> master_keys_;
70};
71
72} // namespace iceberg
KMS client with in-memory master keys. Not for production use.
Definition in_memory_kms.h:42
static void Register()
Register this client in KmsRegistry under kName.
Result< std::vector< uint8_t > > WrapKey(std::span< const uint8_t > key, std::string_view wrapping_key_id) override
Wrap (encrypt) a secret key with the master key wrapping_key_id.
Result< std::vector< uint8_t > > UnwrapKey(std::span< const uint8_t > wrapped_key, std::string_view wrapping_key_id) override
Unwrap a key returned by WrapKey.
Status Initialize(const std::unordered_map< std::string, std::string > &properties) override
Add master keys from encryption.in-memory-kms.key.<id> properties.
Wraps and unwraps secret keys with master keys kept in a KMS.
Definition key_management_client.h:45
Definition expected.h:1199
Define symbol visibility macros for bundled format integrations.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:34
STL namespace.