Zheng Feng created CAMEL-21423:
----------------------------------

             Summary: It is not possible to use "inline" with 
"AES/GCM/NoPadding"
                 Key: CAMEL-21423
                 URL: https://issues.apache.org/jira/browse/CAMEL-21423
             Project: Camel
          Issue Type: Bug
          Components:  camel-crypto
    Affects Versions: 4.8.1
            Reporter: Zheng Feng
            Assignee: Zheng Feng


{code:java}
         CryptoDataFormat cryptoFormat = new 
CryptoDataFormat("AES/GCM/NoPadding", secretKey);
         cryptoFormat.setInitializationVector(iv); // it should set the iv 
based on the info from paramSpec.. 
         cryptoFormat.setShouldInlineInitializationVector(true);
         cryptoFormat.setAlgorithmParameterSpec(paramSpec);
{code}
Will not work, but with "AES/GCM/NoPadding", it expects to configure a 
GCMParamSpec.

The related codes are inĀ 
[CryptoDataFormat.java|https://github.com/apache/camel/blob/295c7871cf351340021795d6d38258e0c3e92ca9/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/CryptoDataFormat.java#L112-L120]

{code:java}
      if (mode == ENCRYPT_MODE || mode == DECRYPT_MODE) {
            if (iv != null) {
                cipher.init(mode, key, new IvParameterSpec(iv));
            } else if (parameterSpec != null) {
                cipher.init(mode, key, parameterSpec);
            } else {
                cipher.init(mode, key);
            }
        }
{code}
I think it could check *(parameterSpec != null)* at first.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to