From 22974644fda537ef462b31a7e6e1e746c1605fcf Mon Sep 17 00:00:00 2001 From: Dominic Reed Date: Wed, 6 Nov 2024 15:48:07 -0800 Subject: [PATCH] correct array offset for ByteBuffer Summary: Test Plan: --- sdk/src/main/java/io/opentdf/platform/sdk/NanoTDF.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/main/java/io/opentdf/platform/sdk/NanoTDF.java b/sdk/src/main/java/io/opentdf/platform/sdk/NanoTDF.java index 39170b97..5695713a 100644 --- a/sdk/src/main/java/io/opentdf/platform/sdk/NanoTDF.java +++ b/sdk/src/main/java/io/opentdf/platform/sdk/NanoTDF.java @@ -140,7 +140,7 @@ public int createNanoTDF(ByteBuffer data, OutputStream outputStream, System.arraycopy(iv, 0, actualIV, kIvPadding, iv.length); } while (Arrays.equals(actualIV, kEmptyIV)); // if match, we need to retry to prevent key + iv reuse with the policy - byte[] cipherData = gcm.encrypt(actualIV, authTagSize, data.array(), 0, dataSize); + byte[] cipherData = gcm.encrypt(actualIV, authTagSize, data.array(), data.arrayOffset(), dataSize); // Write the length of the payload as int24 int cipherDataLengthWithoutPadding = cipherData.length - kIvPadding;