EnricoMi commented on code in PR #46017:
URL: https://github.com/apache/arrow/pull/46017#discussion_r2039330971


##########
cpp/src/parquet/encryption/encryption.cc:
##########
@@ -182,79 +175,75 @@ 
FileEncryptionProperties::Builder::disable_aad_prefix_storage() {
 }
 
 ColumnEncryptionProperties::ColumnEncryptionProperties(bool encrypted,
-                                                       const std::string& 
column_path,
-                                                       const std::string& key,
-                                                       const std::string& 
key_metadata)
-    : column_path_(column_path) {
-  DCHECK(!column_path.empty());
+                                                       std::string column_path,
+                                                       
encryption::SecureString key,
+                                                       std::string 
key_metadata)
+    : column_path_(std::move(column_path)),
+      encrypted_(encrypted),
+      encrypted_with_footer_key_(encrypted && key.empty()),
+      key_(std::move(key)),
+      key_metadata_(std::move(key_metadata)) {
+  DCHECK(!column_path_.empty());
   if (!encrypted) {
     DCHECK(key.empty() && key_metadata.empty());
   }
-
-  if (!key.empty()) {
-    DCHECK(key.length() == 16 || key.length() == 24 || key.length() == 32);
+  if (!key_.empty()) {
+    DCHECK(key_.length() == 16 || key_.length() == 24 || key_.length() == 32);
   }
-
-  encrypted_with_footer_key_ = (encrypted && key.empty());
   if (encrypted_with_footer_key_) {
-    DCHECK(key_metadata.empty());
+    DCHECK(key_metadata_.empty());
   }
-
-  encrypted_ = encrypted;
-  key_metadata_ = key_metadata;
-  key_ = key;
 }
 
-ColumnDecryptionProperties::ColumnDecryptionProperties(const std::string& 
column_path,
-                                                       const std::string& key)
-    : column_path_(column_path) {
-  DCHECK(!column_path.empty());
+ColumnDecryptionProperties::ColumnDecryptionProperties(std::string column_path,
+                                                       
encryption::SecureString key)
+    : column_path_(std::move(column_path)), key_(std::move(key)) {
+  DCHECK(!column_path_.empty());
 
-  if (!key.empty()) {
-    DCHECK(key.length() == 16 || key.length() == 24 || key.length() == 32);
+  if (!key_.empty()) {
+    DCHECK(key_.length() == 16 || key_.length() == 24 || key_.length() == 32);
   }
-
-  key_ = key;
 }
 
-std::string FileDecryptionProperties::column_key(const std::string& 
column_path) const {
+const encryption::SecureString& FileDecryptionProperties::column_key(
+    const std::string& column_path) const {
   if (column_decryption_properties_.find(column_path) !=
       column_decryption_properties_.end()) {
     auto column_prop = column_decryption_properties_.at(column_path);
     if (column_prop != nullptr) {
       return column_prop->key();
     }
   }
-  return empty_string_;
+  return no_key_;

Review Comment:
   we are still returning a reference to a `SecureString`. I tried to return 
some `std::optional`, to replace empty `SecureString` notation for "no key 
given" with `std::nullopt`, but this opened a can of worms. Not going down this 
rabbit whole in this PR.
   
   At least the naming is improved.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to