ulab-original
jsorg71 18 years ago
parent ddba72271f
commit 023a32252d

@ -53,6 +53,8 @@ key_gen(void)
char* e_data; char* e_data;
char* n_data; char* n_data;
char* d_data; char* d_data;
unsigned char* p;
int len;
int e_len; int e_len;
int n_len; int n_len;
int d_len; int d_len;
@ -64,10 +66,11 @@ key_gen(void)
e_data = 0; e_data = 0;
n_data = 0; n_data = 0;
d_data = 0; d_data = 0;
error = 0;
my_ctx = BN_CTX_new(); my_ctx = BN_CTX_new();
my_e = BN_new(); my_e = BN_new();
BN_bin2bn((unsigned char*)g_rev_exponent, sizeof(g_rev_exponent), my_e); p = (unsigned char*)g_rev_exponent;
len = sizeof(g_rev_exponent);
BN_bin2bn(p, len, my_e);
my_key = RSA_new(); my_key = RSA_new();
g_writeln(""); g_writeln("");
g_writeln("Generating %d bit rsa key...", MY_KEY_SIZE); g_writeln("Generating %d bit rsa key...", MY_KEY_SIZE);
@ -82,7 +85,8 @@ key_gen(void)
if (e_len > 0) if (e_len > 0)
{ {
e_data = (char*)g_malloc(e_len, 0); e_data = (char*)g_malloc(e_len, 0);
BN_bn2bin(my_key->e, (unsigned char*)e_data); p = (unsigned char*)e_data;
BN_bn2bin(my_key->e, p);
g_writeln("public exponent size %d bytes", e_len); g_writeln("public exponent size %d bytes", e_len);
g_hexdump(e_data, e_len); g_hexdump(e_data, e_len);
g_writeln(""); g_writeln("");
@ -91,7 +95,8 @@ key_gen(void)
if (n_len > 0) if (n_len > 0)
{ {
n_data = (char*)g_malloc(n_len, 0); n_data = (char*)g_malloc(n_len, 0);
BN_bn2bin(my_key->n, (unsigned char*)n_data); p = (unsigned char*)n_data;
BN_bn2bin(my_key->n, p);
g_writeln("public modulus size %d bytes", n_len); g_writeln("public modulus size %d bytes", n_len);
g_hexdump(n_data, n_len); g_hexdump(n_data, n_len);
g_writeln(""); g_writeln("");
@ -100,7 +105,8 @@ key_gen(void)
if (d_len > 0) if (d_len > 0)
{ {
d_data = (char*)g_malloc(d_len, 0); d_data = (char*)g_malloc(d_len, 0);
BN_bn2bin(my_key->d, (unsigned char*)d_data); p = (unsigned char*)d_data;
BN_bn2bin(my_key->d, p);
g_writeln("private exponent size %d bytes", d_len); g_writeln("private exponent size %d bytes", d_len);
g_hexdump(d_data, d_len); g_hexdump(d_data, d_len);
g_writeln(""); g_writeln("");

Loading…
Cancel
Save