Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email email@example.com
Re: What problem have this Rijndael(.NET&PHP) code?
From: Jamie Riden (jamesreurope.com)
Date: Fri Dec 15 2006 - 13:42:04 CST
On 15/12/06, ±è¿µÀÏ <zero12anaver.com> wrote:
> Dear, web security Professionals.
> I have a AES problem.
> I want to send confidential data.
> STEP is bottom...
> * STEP
> 1. Encrypt confidential-data by C#.NET.
> 2. Send encrypted data on HTTP(80) protocol.
> 2. Decrypt encyrpted data by PHP & mcrypt(2.4.x)
I got PHP's mcrypt talking to the Botan library in C++ and I think one
of the issues was the padding scheme - not the actual mechanics of the
encryption itself. Unfortunately, I don't have access to the source
code any more, and I don't know the .NET implementation.
The Botan doc states : "In the case of the ECB and CBC modes, a
padding method can also be specified. If it is not supplied, ECB
defaults to not padding, and CBC defaults to using PKCS #5/#7
compatible padding. The padding methods currently available are
"NoPadding", "PKCS7", "OneAndZeros", and "CTS". CTS padding is
currently only available for CBC mode, but the others can also be used
in ECB mode."
I seem to remember that I had to use 'NoPadding' to interoperate with
PHP - the PHP docs are kind of vague on this. Google suggests you may
need "RijndaelCipher.Padding = PaddingMode.None;" in your .NET stuff.
(You know that ECB mode isn't a great one to use unless you don't have
any patterns in your plaintext? CBC is probably best for encrypting
Hope this helps a bit.
Jamie Riden, CISSP / jamesreurope.com / jamie.ridengmail.com
NZ Honeynet project - http://www.nz-honeynet.org/