12 #if !defined(OPENSSL_NO_DH) 14 #define GetPKeyDH(obj, pkey) do { \ 15 GetPKey((obj), (pkey)); \ 16 if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DH) { \ 17 ossl_raise(rb_eRuntimeError, "THIS IS NOT A DH!") ; \ 20 #define GetDH(obj, dh) do { \ 22 GetPKeyDH((obj), _pkey); \ 23 (dh) = EVP_PKEY_get0_DH(_pkey); \ 45 if (!(pkey = EVP_PKEY_new())) {
48 if (!EVP_PKEY_assign_DH(pkey, dh)) {
118 if (cb_arg.
yield == 1) {
137 if (!DH_generate_key(dh)) {
229 dh = d2i_DHparams_bio(in,
NULL);
236 if (!EVP_PKEY_assign_DH(pkey, dh)) {
248 const BIGNUM *pub, *priv;
253 GetDH(other, dh_other);
255 dh = DHparams_dup(dh_other);
258 EVP_PKEY_assign_DH(pkey, dh);
260 DH_get0_key(dh_other, &pub, &priv);
262 BIGNUM *pub2 = BN_dup(pub);
263 BIGNUM *priv2 = BN_dup(priv);
265 if (!pub2 || priv && !priv2) {
267 BN_clear_free(priv2);
270 DH_set0_key(dh, pub2, priv2);
290 DH_get0_key(dh, &bn,
NULL);
309 DH_get0_key(dh,
NULL, &bn);
311 #if !defined(OPENSSL_NO_ENGINE) 312 return (bn || DH_get0_engine(dh)) ?
Qtrue :
Qfalse;
336 if (!(out = BIO_new(BIO_s_mem()))) {
339 if (!PEM_write_bio_DHparams(out, dh)) {
366 if((len = i2d_DHparams(dh,
NULL)) <= 0)
370 if(i2d_DHparams(dh, &p) < 0)
393 DH_get0_pqg(dh, &p, &q, &g);
394 DH_get0_key(dh, &pub_key, &priv_key);
422 if (!(out = BIO_new(BIO_s_mem()))) {
425 if (!DHparams_print(out, dh)) {
461 GetDH(
self, orig_dh);
462 dh = DHparams_dup(orig_dh);
487 if (!DH_check(dh, &codes)) {
516 if (!DH_generate_key(dh))
547 if ((len = DH_compute_key((
unsigned char *)
RSTRING_PTR(str), pub_key, dh)) < 0) {
static VALUE dh_instance(VALUE klass, DH *dh)
static VALUE ossl_dh_generate_key(VALUE self)
static unsigned int hash(str, len) register const char *str
static VALUE ossl_dh_initialize_copy(VALUE self, VALUE other)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
#define SetPKey(obj, pkey)
#define ossl_str_adjust(str, p)
BIO * ossl_obj2bio(volatile VALUE *pobj)
void rb_str_set_len(VALUE, long)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
#define GetPKey(obj, pkey)
static VALUE ossl_dh_compute_key(VALUE self, VALUE pub)
static VALUE ossl_dh_to_text(VALUE self)
VALUE ossl_membio2str(BIO *bio)
VALUE ossl_dh_new(EVP_PKEY *pkey)
#define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2)
static VALUE ossl_dh_check_params(VALUE self)
#define rb_define_copy_func(klass, func)
VALUE ossl_to_der_if_possible(VALUE obj)
void ossl_generate_cb_stop(void *ptr)
void ossl_clear_error(void)
int rb_block_given_p(void)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
RUBY_EXTERN VALUE rb_cObject
#define OSSL_BIO_reset(bio)
static VALUE ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
static VALUE ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
#define DEF_OSSL_PKEY_BN(class, keytype, name)
static VALUE ossl_dh_to_public_key(VALUE self)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
int ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
#define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3)
static VALUE ossl_dh_to_der(VALUE self)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static VALUE ossl_dh_is_public(VALUE self)
void rb_jump_tag(int tag)
static VALUE ossl_dh_export(VALUE self)
register unsigned int len
VALUE rb_define_module_under(VALUE outer, const char *name)
static DH * dh_generate(int size, int gen)
void ossl_raise(VALUE exc, const char *fmt,...)
#define BN_GENCB_free(cb)
VALUE ossl_bn_new(const BIGNUM *bn)
#define EVP_PKEY_base_id(pkey)
#define RB_INTEGER_TYPE_P(obj)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static VALUE ossl_dh_is_private(VALUE self)
static VALUE ossl_dh_get_params(VALUE self)
static void * dh_blocking_gen(void *arg)
VALUE rb_obj_class(VALUE)
VALUE rb_str_new(const char *, long)