rdblue commented on code in PR #2639:
URL: https://github.com/apache/iceberg/pull/2639#discussion_r1103902393


##########
parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java:
##########
@@ -231,6 +243,31 @@ private WriteBuilder createContextFunc(
       return this;
     }
 
+    private FileEncryptionProperties 
createEncryptionProperties(EncryptionKeyMetadata keyMetadata) {
+      Preconditions.checkArgument(keyMetadata != null, "Null key metadata");
+
+      // Native Parquet encryption can be activated only by envelope metadata.
+      // Other metadata types imply flat/generic file encryption
+      if (!(keyMetadata instanceof EnvelopeKeyMetadata)) {
+        return null;
+      }
+
+      EnvelopeKeyMetadata envelopeMetadata = (EnvelopeKeyMetadata) keyMetadata;
+
+      ByteBuffer footerDataKey = envelopeMetadata.encryptionKey();
+      if (null == footerDataKey) {
+        throw new ParquetCryptoRuntimeException(
+            "Can't create parquet encryption properties - missing key for 
parquet footer");
+      }
+
+      ByteBuffer aadPrefixBB = envelopeMetadata.aadPrefix();
+      byte[] aadPrefix = (null == aadPrefixBB) ? null : aadPrefixBB.array();

Review Comment:
   This is unsafe. Please use `ByteBuffers.toByteArray`.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to