Re: Rijndael class, Padding bug?, Ivan Medvedev

From: Ivan Medvedev [MS] (ivanmed@online.microsoft.com)
Date: 01/24/03


From: "Ivan Medvedev [MS]" <ivanmed@online.microsoft.com>
Date: Thu, 23 Jan 2003 15:09:40 -0800


If you do TransformFinalBlock for both encryption and decryption and don't
set the padding (the defauld value is PKCS7 padding) everything should work.
One thing that many people miss is that when you use padding the encrypted
data can be larger than the plaintext and when decrypting one needs to make
sure he is feeding all the encrypted data to the decryptor, not just the
same number of bytes the plaintext had. If this still does not work for you
could you please post your code?
Thanks,
--Ivan

This posting is provided "AS IS" with no warranties, and confers no rights

"AJoshi" <ajoshi@approva.net> wrote in message
news:e6znd24uCHA.1628@TK2MSFTNGP10...
> Thank you, Greg. I already had a buffer with the raw data, so why go
through
> hoops and use a stream? BTW, TransformFinalBlock worked, but I still had
to
> use PaddinMode.None.
>
>
> "Greg Fee" <gregfee@microsoft.com> wrote in message
> news:OlGvD01uCHA.1848@TK2MSFTNGP09...
> > You'll need to call TransformFinalBlock for the final block of the
> > encryption. The streams are nice as they handle of this for you.
> >
> >
> > "AJoshi" <ajoshi@approva.net> wrote in message
> > news:#didOsvuCHA.2372@TK2MSFTNGP12...
> > > I used code similar to the one posted by Ivan on 1/4/2003, except that
I
> > > used byte[] for raw, encrypted and decrypted data. I did not use any
> > > streams. Something very strange. I used the CreateEncryptor and
> > > CreateDecryptor methods on the Rijndael class and used the
> TransformBlock
> > > methods of the returned ICryptoTransform. Encryption works fine.
> > Decryption
> > > works only if you set the Padding property of the Rijndael class to
> > > Padding.None. Strange.
> > > Thanks
> > > A Joshi
> > >
> > >
> >
> >
>
>



Relevant Pages

  • RE: AES Codebook Decrypt Problem
    ... occurred during decryption and I believe the ... issue was the padding scheme employed, which appeared to be PKCS7 by default, ... The various encryption methods (ECB is the base but CBC, CFB, OFB, ... >> the issue yesterday by setting up padding and now get the desired output for ...
    (microsoft.public.platformsdk.security)
  • padding and buffer size for Cryptoapi CryptEncrypt()
    ... but decryption exits with NTE_BAD_DATA. ... encryption with RSA public keys and decryption with RSA private keys. ... The encryption uses PKCS #1 Type 2 padding. ... length as the modulus of the RSA key used to decrypt the data. ...
    (microsoft.public.platformsdk.security)
  • Re: 3des bad data in web farm environment
    ... If you get bad data from flushfinalblock, means that the padding was ... the encryption / decryption code. ... The encryption appears to be working. ...
    (microsoft.public.dotnet.security)
  • Re: Crypto API using RC2 instead of RC4?
    ... "prepare data for decryption" step is only pre-allocating buffers. ... padding is added by cryptencrypt and removed by cryptdecrypt. ... > My test application creates a random string. ... > I'm not clued up on encryption but as far as I can tell all the padding ...
    (microsoft.public.platformsdk.security)
  • Re: Rijndael class, Padding bug?, Ivan Medvedev
    ... Thanks, Ivan, Greg, George. ... > If you do TransformFinalBlock for both encryption and decryption and don't ...
    (microsoft.public.dotnet.security)

Quantcast