Support Questions

Find answers, ask questions, and share your expertise

How to use DecryptContent with AES-128 CTR and an IV

avatar
New Contributor

I have the AES decryption working in a Nodejs script using crypto locally on my computer, with the following parts:

Text to decrypt: c6 c7 4b 49 0d cf 5c 20 87 0a e0 cd c4 a7 bf 94 d8
Key: 3E 9B 26 FE 46 4F 6D 2D 2F 69 5D 87 8A 07 93 74
Initialization Vector (IV): 2d 2c 83 42 00 74 1b 16 20 c0 7d 13 20 00 00 00

Correct result: 14 25 79 ed a8 ff a7 00 00 e5 03 00 00 be 03 00 00

So I know both key and IV are correct. I am using AES128, CTR and NoPadding

Now, I need to do it in Apache Nifi, and I am trying to use the DecryptContent processor. I am confused about how to make it happen and have tried quite a few things, the latest being:

Cipher Algorithm Mode is set to CTR
Cipher Algorithm Padding is set to NoPadding
Key Specification Format: RAW

I have set the content of the incoming flowfile content to

c6c74b490dcf5c20870ae0cdc4a7bf94d84E69466949562d2c834200741b1620c07d1320000000
(With 4E6946694956 as the NiFiIV delimiter)

This results in an error from the DecryptContent processor: "Wrong IV length: must be 16 bytes long"
This suggests to me that it is reading the payload as a normal text string, and not as HEX values. Is there a way to set the content to HEX specifically?

The documentation is a little sketchy about how to provide the content to be decrypted (or I have just missed something), so I am hoping you can help me.

1 ACCEPTED SOLUTION

avatar
New Contributor

For anyone reading here; I never got the DecryptContent processor to work. Made a Groovy script processor instead, that handled the decrypting

View solution in original post

2 REPLIES 2

avatar
Community Manager

@Molleb, Welcome to our community! To help you get the best possible answer, I have tagged in our NiFi experts @MattWho @SAMSAL @mburgess  who may be able to assist you further.

Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.



Regards,

Vidya Sargur,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
New Contributor

For anyone reading here; I never got the DecryptContent processor to work. Made a Groovy script processor instead, that handled the decrypting