ggershinsky commented on code in PR #18337: URL: https://github.com/apache/iceberg/pull/18337#discussion_r4192015586
########## core/src/test/java/org/apache/iceberg/encryption/TestStandardEncryptionManager.java: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.encryption; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import java.nio.ByteBuffer; +import java.security.SecureRandom; +import java.util.List; +import java.util.Map; +import org.apache.iceberg.TableProperties; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; +import org.junit.jupiter.api.Test; + +class TestStandardEncryptionManager { Review Comment: this class tests only key generation aspects of SEM. maybe this should be reflected in the class name? ########## core/src/main/java/org/apache/iceberg/encryption/EncryptionUtil.java: ########## @@ -119,7 +120,14 @@ public static EncryptionManager createEncryptionManager( "Invalid data key length: %s (must be 16, 24, or 32)", dataKeyLength); - return new StandardEncryptionManager(keys, tableKeyId, dataKeyLength, kmsClient); + boolean kekGenerationEnabled = Review Comment: also in this and other related names ########## core/src/main/java/org/apache/iceberg/encryption/StandardEncryptionManager.java: ########## @@ -146,8 +160,17 @@ String keyEncryptionKeyID() { } // No unexpired key encryption keys; create one - ByteBuffer unwrapped = newKey(); - ByteBuffer wrapped = kmsClient.wrapKey(unwrapped, tableKeyId); + ByteBuffer unwrapped; + ByteBuffer wrapped; + if (kekGenerationEnabled && kmsClient.supportsKeyGeneration()) { Review Comment: if kekGenerationEnabled is set to true, but kmsClient.supportsKeyGeneration() is false, I think we need to throw an exception. Otherwise, we get a behavior unexpected by the user. Actually, maybe we'd want to call this parameter "encryption.kms-key-generation" or "encryption.use-kms-key-generation" ########## core/src/main/java/org/apache/iceberg/encryption/EncryptionUtil.java: ########## @@ -40,6 +40,7 @@ public class EncryptionUtil { ImmutableSet.<String>builder() .add(TableProperties.ENCRYPTION_TABLE_KEY) .add(TableProperties.ENCRYPTION_DEK_LENGTH) + .add(TableProperties.ENCRYPTION_KEK_GENERATION_ENABLED) Review Comment: the main point of this parameter is a key generation in KMS; it should be reflected in the name. Maybe something like "ENCRYPTION_KMS_KEY_GENERATION" or "ENCRYPTION_USE_KMS_KEY_GENERATION" or "ENCRYPTION_KMS_KEY_GENERATION_ENABLED" ########## core/src/main/java/org/apache/iceberg/TableProperties.java: ########## @@ -461,5 +461,9 @@ private TableProperties() {} public static final String ENCRYPTION_DEK_LENGTH = "encryption.data-key-length"; public static final int ENCRYPTION_DEK_LENGTH_DEFAULT = 16; + public static final String ENCRYPTION_KEK_GENERATION_ENABLED = + "encryption.kek-generation-enabled"; Review Comment: something like "encryption.kms-key-generation" or "encryption.use-kms-key-generation" or "encryption.kms-key-generation-enabled"? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
