You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/05/07 03:01:11 UTC

(james-project) branch master updated: [ENHANCEMENT] Use the correct AES segment size

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new 14a6affbc1 [ENHANCEMENT] Use the correct AES segment size
14a6affbc1 is described below

commit 14a6affbc1f75450d325d1941865a0061ce74061
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Mon May 6 13:52:02 2024 +0200

    [ENHANCEMENT] Use the correct AES segment size
    
    Prevent needless copies / reallocations
---
 .../src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java       | 3 +--
 .../java/org/apache/james/blob/aes/PBKDF2StreamingAeadFactory.java     | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java b/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java
index cabbee8d7f..17803c4203 100644
--- a/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java
+++ b/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/AESBlobStoreDAO.java
@@ -112,9 +112,8 @@ public class AESBlobStoreDAO implements BlobStoreDAO {
         return Mono.from(underlying.readBytes(bucketName, blobId))
             .map(Throwing.function(bytes -> {
                 InputStream inputStream = decrypt(new ByteArrayInputStream(bytes));
-                int aesPadding = 128;
                 try (UnsynchronizedByteArrayOutputStream outputStream = UnsynchronizedByteArrayOutputStream.builder()
-                    .setBufferSize(bytes.length + aesPadding)
+                    .setBufferSize(bytes.length + PBKDF2StreamingAeadFactory.SEGMENT_SIZE)
                     .get()) {
                     IOUtils.copy(inputStream, outputStream);
                     return outputStream.toByteArray();
diff --git a/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/PBKDF2StreamingAeadFactory.java b/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/PBKDF2StreamingAeadFactory.java
index 7c829830b3..b4bffb839b 100644
--- a/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/PBKDF2StreamingAeadFactory.java
+++ b/server/blob/blob-aes/src/main/java/org/apache/james/blob/aes/PBKDF2StreamingAeadFactory.java
@@ -35,7 +35,7 @@ public class PBKDF2StreamingAeadFactory {
     private static final String SECRET_KEY_FACTORY_ALGORITHM = "PBKDF2WithHmacSHA512";
     private static final String HKDF_ALGO = "HmacSha256";
     private static final int KEY_SIZE_IN_BYTES = 32;
-    private static final int SEGMENT_SIZE = 4096;
+    static final int SEGMENT_SIZE = 4096;
     private static final int OFFSET = 0;
     public static final byte[] EMPTY_ASSOCIATED_DATA = new byte[0];
 


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org