Method: OpenSSL::PKey::DH.generate
- Defined in:
- ossl_pkey_dh.c
.generate(size[, generator]) ⇒ Object
Creates a new DH instance from scratch by generating the private and public components alike.
Parameters
sizeis an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.generatoris a small number > 1, typically 2 or 5.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'ossl_pkey_dh.c', line 161
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;
}
|