File indexing completed on 2026-04-17 08:28:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include "arrow/util/concurrent_map.h"
0021 #include "arrow/util/secure_string.h"
0022
0023 #include "parquet/encryption/encryption.h"
0024 #include "parquet/encryption/file_system_key_material_store.h"
0025 #include "parquet/encryption/key_material.h"
0026 #include "parquet/encryption/key_toolkit.h"
0027 #include "parquet/encryption/key_toolkit_internal.h"
0028 #include "parquet/encryption/kms_client.h"
0029 #include "parquet/platform.h"
0030
0031 namespace parquet::encryption {
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 class PARQUET_EXPORT FileKeyUnwrapper : public DecryptionKeyRetriever {
0042 public:
0043
0044
0045
0046
0047
0048 FileKeyUnwrapper(std::shared_ptr<KeyToolkit> key_toolkit,
0049 const KmsConnectionConfig& kms_connection_config,
0050 double cache_lifetime_seconds, const std::string& file_path = "",
0051 const std::shared_ptr<::arrow::fs::FileSystem>& file_system = NULLPTR);
0052
0053
0054 FileKeyUnwrapper(KeyToolkit* key_toolkit,
0055 const KmsConnectionConfig& kms_connection_config,
0056 double cache_lifetime_seconds, const std::string& file_path = "",
0057 const std::shared_ptr<::arrow::fs::FileSystem>& file_system = NULLPTR);
0058
0059
0060
0061
0062 FileKeyUnwrapper(KeyToolkit* key_toolkit,
0063 const KmsConnectionConfig& kms_connection_config,
0064 double cache_lifetime_seconds,
0065 std::shared_ptr<FileKeyMaterialStore> key_material_store);
0066
0067
0068 ::arrow::util::SecureString GetKey(const std::string& key_metadata_bytes) override;
0069
0070
0071 KeyWithMasterId GetDataEncryptionKey(const KeyMaterial& key_material);
0072
0073 private:
0074 FileKeyUnwrapper(std::shared_ptr<KeyToolkit> key_toolkit_owner, KeyToolkit* key_toolkit,
0075 const KmsConnectionConfig& kms_connection_config,
0076 double cache_lifetime_seconds,
0077 std::shared_ptr<FileKeyMaterialStore> key_material_store,
0078 const std::string& file_path,
0079 const std::shared_ptr<::arrow::fs::FileSystem>& file_system);
0080
0081 std::shared_ptr<KmsClient> GetKmsClientFromConfigOrKeyMaterial(
0082 const KeyMaterial& key_material);
0083
0084
0085 std::shared_ptr<::arrow::util::ConcurrentMap<std::string, ::arrow::util::SecureString>>
0086 kek_per_kek_id_;
0087 std::shared_ptr<KeyToolkit> key_toolkit_owner_;
0088 KeyToolkit* key_toolkit_;
0089 KmsConnectionConfig kms_connection_config_;
0090 const double cache_entry_lifetime_seconds_;
0091 std::shared_ptr<FileKeyMaterialStore> key_material_store_;
0092 const std::string file_path_;
0093 std::shared_ptr<::arrow::fs::FileSystem> file_system_;
0094 };
0095
0096 }