generate(p1, p2 = v2)
public
Creates a new DH instance
from scratch by generating the private and public components alike.
-
size is an integer representing the desired key size. Keys smaller
than 1024 bits should be considered insecure.
-
generator is a small number > 1, typically 2 or 5.
static VALUE
ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
{
DH *dh ;
int g = 2;
VALUE size, gen, obj;
if (rb_scan_args(argc, argv, "11", &size, &gen) == 2) {
g = NUM2INT(gen);
}
dh = dh_generate(NUM2INT(size), g);
obj = dh_instance(klass, dh);
if (obj == Qfalse) {
DH_free(dh);
ossl_raise(eDHError, NULL);
}
return obj;
}