ggershinsky commented on code in PR #3231:
URL: https://github.com/apache/iceberg/pull/3231#discussion_r1278951980
##########
core/src/main/java/org/apache/iceberg/encryption/Ciphers.java:
##########
@@ -101,37 +117,52 @@ public AesGcmDecryptor(byte[] keyBytes) {
}
public byte[] decrypt(byte[] ciphertext, byte[] aad) {
- int plainTextLength = ciphertext.length - GCM_TAG_LENGTH - NONCE_LENGTH;
+ return decrypt(ciphertext, 0, ciphertext.length, aad);
+ }
+
+ public byte[] decrypt(
+ byte[] ciphertext, int ciphertextOffset, int ciphertextLength, byte[]
aad) {
Preconditions.checkState(
- plainTextLength >= 1,
+ ciphertextLength - GCM_TAG_LENGTH - NONCE_LENGTH >= 1,
"Cannot decrypt cipher text of length "
+ ciphertext.length
+ " because text must longer than GCM_TAG_LENGTH + NONCE_LENGTH
bytes. Text may not be encrypted"
+ " with AES GCM cipher");
// Get the nonce from ciphertext
byte[] nonce = new byte[NONCE_LENGTH];
- System.arraycopy(ciphertext, 0, nonce, 0, NONCE_LENGTH);
+ System.arraycopy(ciphertext, ciphertextOffset, nonce, 0, NONCE_LENGTH);
Review Comment:
Cool!
--
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]