| 88 | } |
| 89 | |
| 90 | std::shared_ptr<Encryptor> |
| 91 | InternalFileEncryptor::InternalFileEncryptor::GetColumnEncryptor( |
| 92 | const std::string& column_path, bool metadata) { |
| 93 | // first look if we already got the encryptor from before |
| 94 | if (metadata) { |
| 95 | if (column_metadata_map_.find(column_path) != column_metadata_map_.end()) { |
| 96 | return column_metadata_map_.at(column_path); |
| 97 | } |
| 98 | } else { |
| 99 | if (column_data_map_.find(column_path) != column_data_map_.end()) { |
| 100 | return column_data_map_.at(column_path); |
| 101 | } |
| 102 | } |
| 103 | auto column_prop = properties_->column_encryption_properties(column_path); |
| 104 | if (column_prop == nullptr || !column_prop->is_encrypted()) { |
| 105 | return nullptr; |
| 106 | } |
| 107 | |
| 108 | const SecureString& key = column_prop->is_encrypted_with_footer_key() |
| 109 | ? properties_->footer_key() |
| 110 | : column_prop->key(); |
| 111 | |
| 112 | ParquetCipher::type algorithm = properties_->algorithm().algorithm; |
| 113 | auto aes_encryptor = metadata ? GetMetaAesEncryptor(algorithm, key.size()) |
| 114 | : GetDataAesEncryptor(algorithm, key.size()); |
| 115 | |
| 116 | std::string file_aad = properties_->file_aad(); |
| 117 | std::shared_ptr<Encryptor> encryptor = |
| 118 | std::make_shared<Encryptor>(aes_encryptor, key, file_aad, "", pool_); |
| 119 | if (metadata) |
| 120 | column_metadata_map_[column_path] = encryptor; |
| 121 | else |
| 122 | column_data_map_[column_path] = encryptor; |
| 123 | |
| 124 | return encryptor; |
| 125 | } |
| 126 | |
| 127 | int InternalFileEncryptor::MapKeyLenToEncryptorArrayIndex(int32_t key_len) const { |
| 128 | if (key_len == 16) |
nothing calls this directly
no test coverage detected