Skip to content

Instantly share code, notes, and snippets.

@xnyhps xnyhps/dh.c Secret
Created Feb 2, 2016

Embed
What would you like to do?
$ openssl dhparam -2 512 -C -noout
Generating DH parameters, 512 bit long safe prime, generator 2
This is going to take a long time
[...]
#ifndef HEADER_DH_H
#include <openssl/dh.h>
#endif
DH *get_dh512()
{
static unsigned char dh512_p[]={
0xCF,0x9A,0xE0,0xC3,0x1E,0x58,0xC9,0x67,0x30,0x29,0x40,0x52,
0xB8,0xEB,0x66,0xA7,0x65,0x4D,0xBC,0x8A,0x85,0x4A,0x16,0x8C,
0xBB,0x18,0x49,0x0C,0x90,0x3C,0x9F,0xED,0x9F,0xF5,0xD7,0x14,
0x46,0x4A,0xF2,0xA0,0x5C,0x83,0x26,0x19,0xC4,0xFF,0x82,0x63,
0xC7,0x9F,0x7E,0xAE,0x60,0xB3,0x9E,0xDE,0x71,0xC4,0x90,0x9F,
0xA1,0x38,0xAA,0x33,
};
static unsigned char dh512_g[]={
0x02,
};
DH *dh;
if ((dh=DH_new()) == NULL) return(NULL);
dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
if ((dh->p == NULL) || (dh->g == NULL))
{ DH_free(dh); return(NULL); }
return(dh);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.