Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Vikas Bansal <43470111+vikasvb90@users.noreply.github.com>
  • Loading branch information
vikasvb90 committed Aug 14, 2023
1 parent b033e4e commit 4ea7c57
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

/**
* This class implementation is referenced from AWS Encryption SDK
* https://tiny.amazon.com/lfkvesll/codeamazpackblobheadamaz4
*
* This class implements the CryptoHandler interface by providing methods for the decryption of
* ciphertext produced by the methods in {@link EncryptionHandler}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

/**
* This class implementation has been referenced from AWS encryption SDK.
* https://tiny.amazon.com/1j988pk3f/codeamazpackblobheadamaz4
*
* The frame decryption handler is a subclass of the decryption handler and thereby provides an
* implementation of the Cryptography handler.
Expand Down Expand Up @@ -235,10 +234,7 @@ public static long estimateDecryptedSize(long encryptedSize, int frameSize, int
long frames = (encryptedSize - lastFrameHeaderOverhead) / (frameSize + nonceLen + tagLenBytes + (Integer.SIZE / Byte.SIZE)) + 1;

// Calculate the size of the actual content in frames
long contentSize = frames * frameSize;

// Calculate the size of the last frame
long lastFrameSize = 0;
long contentSizeWithoutLastFrame = (frames - 1) * frameSize;

// Calculate the sequence number size for all frames
long seqNumberSize = frames * (Integer.SIZE / Byte.SIZE);
Expand All @@ -247,9 +243,9 @@ public static long estimateDecryptedSize(long encryptedSize, int frameSize, int
long headerOverhead = (nonceLen + tagLenBytes) * frames + seqNumberSize;

// Calculate the size of the last frame content
lastFrameSize = encryptedSize - contentSize - headerOverhead - lastFrameHeaderOverhead;
long lastFrameSize = encryptedSize - contentSizeWithoutLastFrame - headerOverhead - lastFrameHeaderOverhead;

return contentSize + lastFrameSize;
return contentSizeWithoutLastFrame + lastFrameSize;
}

@Override
Expand Down

0 comments on commit 4ea7c57

Please sign in to comment.