0
votes

I am using a the Crypt::Rijndael module to decrypt some application data.

I gave the encrypted data, encryption key and client IV as the input.

Out of 432 bytes of application data, the first 16 bytes of the decrypted output is always wrong.

What might cause this issue?

1
Show us some code and please explain what "wrong" means in this context.innaM
I suggest you email the author of the module, Brian D Foy <[email protected]> who is an occasional contributor here.Borodin
How can we tell what you did wrong from that?ikegami
@ikegami by knowing CBC mode encryption in this particular caseMaarten Bodewes
The code is,use Crypt::Rijndael; my $crypted = pack("H*",Encrypted application data); my $key = pack("H*","4ffd099494d9cc0d0a6e238209038f27d56da73c8ce376e0b58678f1dd3d9656"); my $iv = pack("H*", "6907fd4a18bacd7bbfb0bf61b28cd37c"); my $cipher = Crypt::Rijndael->new( $key, Crypt::Rijndael::MODE_CBC() ); $cipher->set_iv($iv); my $plaintext = $cipher->decrypt($crypted); #my $hex = unpack "H*",$plaintext; print $plaintext;user2436047

1 Answers

2
votes

Sixteen bytes is 128 bits, the same as the AES/Rijndael block size. If the first 16 bytes are garbage, followed by the full message then what has probably happened is the IV has been prepended to the message, and you are trying to decrypt the IV as well as the message. To solve, extract the first 16 bytes of the incoming cyphertext and use it as the IV.

Alternatively, you have sixteen bytes of garbage followed by a partial message, missing its first 16 bytes. In this case you are probably using the wrong IV. Make sure that you are using the correct IV. Check it byte by byte to make sure it is correct. In particular, make sure that any encoding used while transferring the IV is correctly handled. If even one bit in the IV is wrong you will have a problem.