Diffie-Hellman Implementation-Help

B

Badri Mohan

Hi guys,
Anyone tried to do a Diffie-Hellman encryption and decryption totally in c#.
Any ideas?

Right now i do it as a separate win32 dll
and use PInvoke from c#..

Anyone tried of doin that entirely in C#..

Any exchange of ideas is appreciated.
Thanks and waiting for replies.

Badri
 
D

David Bolt

Badri,
Somehow I think this is not the correct newsgroup, but while your here...
So you already have a dll, is it one you wrote, or one someone else
supplied? If you wrote it, then it should be a straight forward, although
possibly lengthy, task to re-write using C#. Especially since it was
probably written in C or C++ in the first place.
Regards
Dave
 
S

Sébastien Pouliot

Badri,

It should be easy - from a mathematical point of view. Manipulating big
integers is probably the main problem.
I know two ways to solve it.
a. Use the BigInteger class from the Mono project
(http://www.go-mono.com) or it's ancestor at CodeProject;
b. Use the bigInteger class from Microsoft that is included in Visual J#
redist.

Good luck!
 
P

Pieter Philippaerts

Badri Mohan said:
Anyone tried to do a Diffie-Hellman encryption and decryption totally in c#.
Any ideas?
Right now i do it as a separate win32 dll
and use PInvoke from c#..
Anyone tried of doin that entirely in C#..

As Sébastien mentioned, you can use the Mono BigInteger class to implement
it. That's exactly what I've done, so if you're interested here's the code:
http://www.mentalis.org/downloads/DH.zip
It appears to work perfectly but I haven't tested whether it's compatible
with other Diffie Hellman implementations. I assume it is, but I'd like to
verify that before I officially publish the code. I would appreciate it if
you could verify this for me, since you already have a working DH
implementation. I tried to write a C# wrapper around the CryptoAPI to verify
my managed code, but I ran into some problems.

Regards,
Pieter Philippaerts
 
P

Pieter Philippaerts

Pieter Philippaerts said:
It appears to work perfectly but I haven't tested whether it's compatible
with other Diffie Hellman implementations.

I just tested against Cipher448's implementation, and everything worked
perfectly.

Regards,
Pieter Philippaerts
 
B

Badri Mohan

Hey thats a cool implementation..
One more Question ..
Will it run under Mono in Linux..???
Thanks and waiting for reply..
 
B

Badri Mohan

Thanks for the reply...David
Actually everthing works fine for me when there is a wrapper created but it
does not run under Mono in Linux..
It says thereis a Out of sync error..
Any guesses??
 
P

Pieter Philippaerts

Badri Mohan said:
Hey thats a cool implementation..
One more Question ..
Will it run under Mono in Linux..???
Thanks and waiting for reply..

Yes, it will -- in fact, I just emailed the code to Sébastien to include it
in the Mono runtime.
However there's a bug in the official BigInteger implementation
[http://bugzilla.ximian.com/show_bug.cgi?id=51229] that may cause the
Diffie-Hellman implementation to malfunction. The BigInteger class that I
used for the Diffie-Hellman implementation contains a work-around for this
bug.

Regards,
Pieter Philippaerts
 
Joined
Mar 5, 2013
Messages
1
Reaction score
0
can i know how this code runs??i am not able to execute it..can u help me please?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top