Home All Groups Group Topic Archive Search About

Rijndael in ASP.NET and Delphi

Author
29 Nov 2007 6:57 AM
Iwan Budihalim
Who can help? I'm trying to implement an encrypted (plain text)
communication between a Delphi application and an ASP.NET. My choice
is AES/rijndael-128. For both sides, i use standard modules:

Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component
Library v2) from cityinthesky (www.cityinthesky.com)

ASP.NET : Standard library of Rijndael

both sides are working, BUT they do different! The results in encryption
and decryption do not match when i use same keys. now i've no clue what
i am doing wrong.

Anyone out there who can give me the right hint??

Author
28 Nov 2007 4:03 PM
Jon Skeet [C# MVP]
Show quote
On Nov 29, 6:57 am, "Iwan Budihalim" <iwan_budiha***@visuallabs.net>
wrote:
> Who can help? I'm trying to implement an encrypted (plain text)
> communication between a Delphi application and an ASP.NET. My choice
> is AES/rijndael-128. For both sides, i use standard modules:
>
> Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component
> Library v2) from cityinthesky (www.cityinthesky.com)
>
> ASP.NET : Standard library of Rijndael
>
> both sides are working, BUT they do different! The results in encryption
> and decryption do not match when i use same keys. now i've no clue what
> i am doing wrong.
>
> Anyone out there who can give me the right hint??

The first thing to do is find a third implementation - that way you
can easily find out which of your current implementations is broken.

Then it would help if you could post the C# code. It's easy to mess up
using encryption.

Jon
Author
28 Nov 2007 11:04 PM
rossum
On Wed, 28 Nov 2007 08:03:24 -0800 (PST), "Jon Skeet [C# MVP]"
<sk***@pobox.com> wrote:

>The first thing to do is find a third implementation - that way you
>can easily find out which of your current implementations is broken.
Try Bouncy Castle: http://www.bouncycastle.org/csharp/

I use their Java crypto library and it works very well.

rossum
Author
28 Nov 2007 7:04 PM
Doug Forster
Hi Iwan,

I don't know the answer to your question, but have you considered doing the
Delphi side via a COM exposed C# dll. We have just starting doing this to
gain access to the .NET database libraries from Delphi and it is proving
very successful.

Cheers
Doug Forster

Show quote
"Iwan Budihalim" <iwan_budiha***@visuallabs.net> wrote in message
news:ebGIZZdMIHA.4476@TK2MSFTNGP06.phx.gbl...
> Who can help? I'm trying to implement an encrypted (plain text)
> communication between a Delphi application and an ASP.NET. My choice
> is AES/rijndael-128. For both sides, i use standard modules:
>
> Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component
> Library v2) from cityinthesky (www.cityinthesky.com)
>
> ASP.NET : Standard library of Rijndael
>
> both sides are working, BUT they do different! The results in encryption
> and decryption do not match when i use same keys. now i've no clue what
> i am doing wrong.
>
> Anyone out there who can give me the right hint??
>
Author
29 Nov 2007 12:12 PM
Iwan Budihalim
I think, i better share the library so they can read between C# and Delphi.
Show quote
"Doug Forster" <nobody@nowhere,com> wrote in message
news:Oo8c6FfMIHA.5244@TK2MSFTNGP03.phx.gbl...
> Hi Iwan,
>
> I don't know the answer to your question, but have you considered doing
> the Delphi side via a COM exposed C# dll. We have just starting doing this
> to gain access to the .NET database libraries from Delphi and it is
> proving very successful.
>
> Cheers
> Doug Forster
>
> "Iwan Budihalim" <iwan_budiha***@visuallabs.net> wrote in message
> news:ebGIZZdMIHA.4476@TK2MSFTNGP06.phx.gbl...
>> Who can help? I'm trying to implement an encrypted (plain text)
>> communication between a Delphi application and an ASP.NET. My choice
>> is AES/rijndael-128. For both sides, i use standard modules:
>>
>> Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component
>> Library v2) from cityinthesky (www.cityinthesky.com)
>>
>> ASP.NET : Standard library of Rijndael
>>
>> both sides are working, BUT they do different! The results in encryption
>> and decryption do not match when i use same keys. now i've no clue what
>> i am doing wrong.
>>
>> Anyone out there who can give me the right hint??
>>
>
>
Author
29 Nov 2007 12:55 AM
Arne_Vajhøj
Iwan Budihalim wrote:
Show quote
> Who can help? I'm trying to implement an encrypted (plain text)
> communication between a Delphi application and an ASP.NET. My choice
> is AES/rijndael-128. For both sides, i use standard modules:
>
> Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component
> Library v2) from cityinthesky (www.cityinthesky.com)
>
> ASP.NET : Standard library of Rijndael
>
> both sides are working, BUT they do different! The results in encryption
> and decryption do not match when i use same keys. now i've no clue what
> i am doing wrong.
>
> Anyone out there who can give me the right hint??

Same key size ? Same key ? Same iv ? Same sequences of update
and final calls ?

Arne
Author
29 Nov 2007 12:56 AM
Arne_Vajhøj
Iwan Budihalim wrote:
Show quote
> Who can help? I'm trying to implement an encrypted (plain text)
> communication between a Delphi application and an ASP.NET. My choice
> is AES/rijndael-128. For both sides, i use standard modules:
>
> Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component
> Library v2) from cityinthesky (www.cityinthesky.com)
>
> ASP.NET : Standard library of Rijndael
>
> both sides are working, BUT they do different! The results in encryption
> and decryption do not match when i use same keys. now i've no clue what
> i am doing wrong.
>
> Anyone out there who can give me the right hint??

If you post encryption of "This is a test" from both in hex or base64,
then we could compare.

Arne
Author
29 Nov 2007 10:00 PM
rossum
On Wed, 28 Nov 2007 22:57:26 -0800, "Iwan Budihalim"
<iwan_budiha***@visuallabs.net> wrote:

Show quote
>Who can help? I'm trying to implement an encrypted (plain text)
>communication between a Delphi application and an ASP.NET. My choice
>is AES/rijndael-128. For both sides, i use standard modules:
>
>Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component
>Library v2) from cityinthesky (www.cityinthesky.com)
>
>ASP.NET : Standard library of Rijndael
>
>both sides are working, BUT they do different! The results in encryption
>and decryption do not match when i use same keys. now i've no clue what
>i am doing wrong.
>
>Anyone out there who can give me the right hint??
>
Just a thought, have you tried the official test vectors in FIPS 197:
http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf

You can play with both your implementations until you get the right
results from both of them.

For AES-128 (10 rounds) the official test vectors are:

  PLAINTEXT:  00112233445566778899aabbccddeeff
  KEY:        000102030405060708090a0b0c0d0e0f
  CYPHERTEXT: 69c4e0d86a7b0430d8cdb78070b4c55a

rossum

AddThis Social Bookmark Button