Skip to content

Fix #3246: crypto-encrypt-action and crypto-decrypt-action allow the CBC mode with a random initialization vector - #3247

Open
davsclaus wants to merge 1 commit into
apache:mainfrom
davsclaus:ci-issue-3246
Open

davsclaus wants to merge 1 commit into
apache:mainfrom
davsclaus:ci-issue-3246

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Fixes #3246.

With algorithm: AES the crypto actions encrypt in ECB mode (the Java default for the name alone), and a full transformation such as AES/CBC/PKCS5Padding fails because the same value also names the secret key. So the same text always gave the same bytes, and there was no way to pick another mode.

Changes

  • A new optional mode option on crypto-encrypt-action and crypto-decrypt-action. With mode: CBC the transformation is <algorithm>/CBC/PKCS5Padding, and the crypto data format puts a new random initialization vector in front of each message (inline: true), which the decrypt action reads back.
  • Without mode the actions work as before, so data encrypted by earlier versions still decrypts. The descriptions say that AES alone is ECB and recommend mode: CBC, set on both actions at the same time.
  • GCM is not offered: the crypto data format passes the vector as an IvParameterSpec, which GCM does not take.

Tests

  • CryptoKameletsTest: with mode=CBC (AES and DESede) two encryptions of the same text differ and both decrypt; without mode the output is the same as before (ECB) and decrypts.
  • ./mvnw clean install passes.

Claude Code on behalf of Claus Ibsen

🤖 Generated with Claude Code

…w the CBC mode with a random initialization vector

With the algorithm name alone, such as AES, Java encrypts in ECB mode,
and a full transformation fails because the same value names the key.
A new optional mode option uses <algorithm>/<mode>/PKCS5Padding with a
new random initialization vector put in front of each message. Without
mode nothing changes, so earlier data still decrypts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
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

Successfully merging this pull request may close these issues.

crypto-encrypt-action and crypto-decrypt-action: allow the CBC mode with a random initialization vector

1 participant