1024-bit Diffie-Hellman in C #

So, I am working on a project to interact with a C # client with existing server technology. One of the requirements is key exchange using Diffie-Hellman.

We know the public P and G, and I need to create a 1024-bit public key to send to the server.

On the server side, C ++ uses OpenSSL. I am currently using the same code in my native DLL called via P / Invoke, and it also works. I would prefer, if possible, to eliminate the native DLL dependency.

char publicKey[128];
char P[128]; //this is set to a static 128-byte value, omitting for brevity
unsigned long G = 2;

DH* dh = DH_new();
dh->p = BN_new();
dh->g = BN_new();

BN_set_word(dh->g, G);
BN_bin2bn(P, 128, dh->p);
if(DH_generate_key(dh))
{
   BN_bn2bin(dh->pub_key, publicKey);
}

This generates a 1024-bit public key.

DH BouncyCastle, - 1024- , 960- . , , . , .

BouncyCastle DH , OpenSSL DH, ? , #, ?

+5

All Articles