Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AES/CBC/WITHCTS Need at least one block of input for CTS #1649

Open
trohsb opened this issue May 6, 2024 · 1 comment
Open

AES/CBC/WITHCTS Need at least one block of input for CTS #1649

trohsb opened this issue May 6, 2024 · 1 comment

Comments

@trohsb
Copy link

trohsb commented May 6, 2024

Hi,
I'm performing encryption and dectryption with AES/CBC/WITHCTS. If the data is less than 16 bytes, a block, then I get the following error:

javax.crypto.IllegalBlockSizeException: need at least one block of input for CTS at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineDoFinal(Unknown Source) ~[bcprov-jdk15on-1.69.jar!/:1.69.0] at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2417) ~[na:na]

Wikipedia says:

Ciphertext stealing for CBC mode doesn't necessarily require the plaintext to be longer than one block. In the case where the plaintext is one block long or less, the Initialization vector (IV) can act as the prior block of ciphertext. In this case a modified IV must be sent to the receiver. This may not be possible in situations where the IV can not be freely chosen by the sender when the ciphertext is sent (e.g., when the IV is a derived or pre-established value), and in this case ciphertext stealing for CBC mode can only occur in plaintexts longer than one block.

Are there any examples on how todo that?

@cipherboy
Copy link
Collaborator

@trohsb I don't see an actual description in either the wikipedia or the NIST publication of this algorithm (for the "modified IV"). Do you have a source for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants