Skip to content

Commit

Permalink
Update encryptor impl
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Jul 11, 2024
1 parent 03315fc commit 329abf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 9 additions & 4 deletions cpp/src/parquet/encryption/internal_file_encryptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ InternalFileEncryptor::InternalFileEncryptor(FileEncryptionProperties* propertie
void InternalFileEncryptor::WipeOutEncryptionKeys() {
properties_->WipeOutEncryptionKeys();

for (auto const& i : all_encryptors_) {
i->WipeOut();
for (auto const& i : meta_encryptor_) {
if (i != nullptr) {
i->WipeOut();
}
}
for (auto const& i : data_encryptor_) {
if (i != nullptr) {
i->WipeOut();
}
}
}

Expand Down Expand Up @@ -151,7 +158,6 @@ encryption::AesEncryptor* InternalFileEncryptor::GetMetaAesEncryptor(
int index = MapKeyLenToEncryptorArrayIndex(key_len);
if (meta_encryptor_[index] == nullptr) {
meta_encryptor_[index] = encryption::AesEncryptor::Make(algorithm, key_len, true);
all_encryptors_.push_back(meta_encryptor_[index].get());
}
return meta_encryptor_[index].get();
}
Expand All @@ -162,7 +168,6 @@ encryption::AesEncryptor* InternalFileEncryptor::GetDataAesEncryptor(
int index = MapKeyLenToEncryptorArrayIndex(key_len);
if (data_encryptor_[index] == nullptr) {
data_encryptor_[index] = encryption::AesEncryptor::Make(algorithm, key_len, false);
all_encryptors_.push_back(data_encryptor_[index].get());
}
return data_encryptor_[index].get();
}
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/parquet/encryption/internal_file_encryptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class InternalFileEncryptor {
std::shared_ptr<Encryptor> footer_signing_encryptor_;
std::shared_ptr<Encryptor> footer_encryptor_;

std::vector<encryption::AesEncryptor*> all_encryptors_;

// Key must be 16, 24 or 32 bytes in length. Thus there could be up to three
// types of meta_encryptors and data_encryptors.
std::unique_ptr<encryption::AesEncryptor> meta_encryptor_[3];
Expand Down

0 comments on commit 329abf0

Please sign in to comment.