Home All Groups Group Topic Archive Search About

Decrypting external encrypted data and padding mode

Author
19 Jan 2006 11:04 PM
marcus7171
Hi!

I'm encrypting data with an external cryptographic framework (crypto++
c++ library) and trying to decrypt it with .NET C# Framework classes.
This is how I create the stream chain.

  fileStream = new FileStream(fileName, fileMode, fileAccess);
  ...
  RijndaelManaged aes = new RijndaelManaged();
  aes.Padding = PaddingMode.None;
  aes.Mode = CipherMode.CFB;
  stream = new BinaryReader(
    new CryptoStream(
      fileStream,
      aes.CreateDecryptor(key, iv),
      CryptoStreamMode.Read
    )
  );


I have set the padding mode = none.

However, it still throws an exception not enough data to decrypt when
it tries to decrypt the end of the ciphertext.

What is wrong? Is CryptoStream buffering in block-sized chunks? Do I
need to add an extra block of zeros in the message?

My only solution currently is to add extra padding bytes of a block
size to the message, then it works.

Thanks for any help!
Regards
Marcus

AddThis Social Bookmark Button