MCPcopy Create free account
hub / github.com/apache/arrow / GetKey

Method GetKey

cpp/src/parquet/encryption/file_key_unwrapper.cc:73–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73SecureString FileKeyUnwrapper::GetKey(const std::string& key_metadata_bytes) {
74 // key_metadata is expected to be in UTF8 encoding
75 ::arrow::util::InitializeUTF8();
76 if (!::arrow::util::ValidateUTF8(
77 reinterpret_cast<const uint8_t*>(key_metadata_bytes.data()),
78 key_metadata_bytes.size())) {
79 throw ParquetException("key metadata should be in UTF8 encoding");
80 }
81 KeyMetadata key_metadata = KeyMetadata::Parse(key_metadata_bytes);
82
83 KeyMaterial key_material;
84 if (key_metadata.key_material_stored_internally()) {
85 key_material = key_metadata.key_material();
86 } else {
87 if (key_material_store_ == nullptr) {
88 key_material_store_ =
89 FileSystemKeyMaterialStore::Make(file_path_, file_system_, false);
90 }
91 // External key material storage: key metadata contains a reference
92 // to a key in the material store
93 std::string key_id_in_file = key_metadata.key_reference();
94 std::string key_material_string = key_material_store_->GetKeyMaterial(key_id_in_file);
95 if (key_material_string.empty()) {
96 throw ParquetException("Could not find key material with ID '" + key_id_in_file +
97 "' in external key material file");
98 }
99 key_material = KeyMaterial::Parse(key_material_string);
100 }
101
102 return GetDataEncryptionKey(key_material).data_key();
103}
104
105KeyWithMasterId FileKeyUnwrapper::GetDataEncryptionKey(const KeyMaterial& key_material) {
106 auto kms_client = GetKmsClientFromConfigOrKeyMaterial(key_material);

Callers

nothing calls this directly

Calls 8

InitializeUTF8Function · 0.85
ParquetExceptionFunction · 0.85
ValidateUTF8Function · 0.50
ParseFunction · 0.50
MakeFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected