11 #if !defined(OPENSSL_NO_DH)
15 #define GetPKeyDH(obj, pkey) do { \
16 GetPKey((obj), (pkey)); \
17 if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_DH) { \
18 ossl_raise(rb_eRuntimeError, "THIS IS NOT A DH!") ; \
22 #define DH_HAS_PRIVATE(dh) ((dh)->priv_key)
24 #ifdef OSSL_ENGINE_ENABLED
25 # define DH_PRIVATE(dh) (DH_HAS_PRIVATE(dh) || (dh)->engine)
27 # define DH_PRIVATE(dh) DH_HAS_PRIVATE(dh)
49 if (!(pkey = EVP_PKEY_new())) {
52 if (!EVP_PKEY_assign_DH(pkey, dh)) {
69 if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH) {
89 dh = DH_generate_parameters(size, gen,
94 if (!DH_generate_key(dh)) {
184 dh = d2i_DHparams_bio(in,
NULL);
191 if (!EVP_PKEY_assign_DH(pkey, dh)) {
248 if (!(out = BIO_new(BIO_s_mem()))) {
251 if (!PEM_write_bio_DHparams(out, pkey->pkey.dh)) {
278 if((len = i2d_DHparams(pkey->pkey.dh,
NULL)) <= 0)
282 if(i2d_DHparams(pkey->pkey.dh, &p) < 0)
331 if (!(out = BIO_new(BIO_s_mem()))) {
334 if (!DHparams_print(out, pkey->pkey.dh)) {
372 dh = DHparams_dup(pkey->pkey.dh);
400 if (!DH_check(dh, &codes)) {
432 if (!DH_generate_key(dh))
462 if ((len = DH_compute_key((
unsigned char *)
RSTRING_PTR(str), pub_key, dh)) < 0) {
482 0xf4, 0xcd, 0x71, 0xe5, 0x8d, 0x18, 0x3f, 0x98,
483 0x9f, 0x4f, 0x60, 0xb0, 0x02, 0x2e, 0xfe, 0x7c,
484 0x09, 0xdf, 0x15, 0xc4, 0x1c, 0x71, 0x63, 0xba,
485 0x04, 0xb8, 0x27, 0x94, 0x44, 0xc8, 0x93, 0xa8,
486 0x48, 0x4c, 0xca, 0x6d, 0x7a, 0xae, 0x18, 0x4a,
487 0x81, 0x91, 0xb6, 0xce, 0x4d, 0x8e, 0xf6, 0xe5,
488 0x08, 0x04, 0x8c, 0x52, 0x8f, 0xe3, 0x4a, 0x31,
489 0x44, 0x47, 0x19, 0xa1, 0x4a, 0xc8, 0x8b, 0xcb,
502 0x9d, 0x25, 0x39, 0x5c, 0xb4, 0x54, 0x8a, 0xff,
503 0x25, 0xe6, 0xd6, 0x9f, 0x4c, 0xc3, 0xc1, 0x8d,
504 0xa1, 0xfa, 0xba, 0x88, 0x4c, 0x53, 0xa9, 0x74,
505 0xda, 0xfa, 0xba, 0x0b, 0x20, 0xbe, 0x40, 0xd7,
506 0xba, 0xe7, 0x1d, 0x70, 0x28, 0x61, 0x60, 0x4c,
507 0x49, 0x01, 0x5f, 0xd9, 0x0f, 0x60, 0x16, 0x3d,
508 0xba, 0xd3, 0xa9, 0x5e, 0xfa, 0x98, 0x64, 0x60,
509 0x26, 0x0e, 0x04, 0x75, 0xd8, 0x13, 0xd7, 0x31,
510 0xb4, 0x8e, 0xad, 0xeb, 0x9c, 0x57, 0x4c, 0x8f,
511 0x65, 0xf3, 0x90, 0x16, 0x31, 0xdc, 0x15, 0x6f,
512 0x7d, 0x1d, 0x00, 0xae, 0x76, 0xf2, 0xd1, 0x11,
513 0xd1, 0x4f, 0x88, 0x7b, 0x29, 0x9f, 0xf6, 0xce,
514 0x68, 0xef, 0x57, 0xe7, 0x85, 0xf2, 0x40, 0x54,
515 0x1c, 0x12, 0x40, 0xa2, 0x35, 0x25, 0xcf, 0x12,
516 0xa3, 0xe1, 0x07, 0x8e, 0xdb, 0x1d, 0xb4, 0x14,
517 0xff, 0x57, 0xe7, 0x19, 0x8d, 0x51, 0x77, 0x83
530 if (dh->p ==
NULL || dh->g ==
NULL){
#define GetPKeyDH(obj, pkey)
static unsigned char DEFAULT_DH_1024_PRIM[]
static VALUE dh_instance(VALUE klass, DH *dh)
static VALUE ossl_dh_generate_key(VALUE self)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
#define OSSL_PKEY_BN(keytype, name)
#define ossl_str_adjust(str, p)
#define RSTRING_PTR(string)
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)
DH * OSSL_DEFAULT_DH_1024
VALUE ossl_membio2str(BIO *bio)
VALUE ossl_dh_new(EVP_PKEY *pkey)
static VALUE ossl_dh_check_params(VALUE self)
void ossl_generate_cb(int p, int n, void *arg)
VALUE ossl_to_der_if_possible(VALUE obj)
int rb_block_given_p(void)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
#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)
static unsigned char DEFAULT_DH_1024_GEN[]
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
static unsigned char DEFAULT_DH_512_GEN[]
#define WrapPKey(klass, obj, pkey)
BIO * ossl_obj2bio(VALUE obj)
static VALUE ossl_dh_to_der(VALUE self)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static DH * ossl_create_dh(unsigned char *p, size_t plen, unsigned char *g, size_t glen)
static unsigned char DEFAULT_DH_512_PRIM[]
register unsigned int len
static VALUE ossl_dh_is_public(VALUE self)
static VALUE ossl_dh_export(VALUE self)
VALUE rb_define_module_under(VALUE outer, const char *name)
static DH * dh_generate(int size, int gen)
#define rb_str_set_len(str, length)
void ossl_raise(VALUE exc, const char *fmt,...)
static unsigned int hash(const char *str, unsigned int len)
VALUE ossl_bn_new(const BIGNUM *bn)
BIGNUM * GetBNPtr(VALUE obj)
VALUE rb_define_module(const char *name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
static VALUE ossl_dh_is_private(VALUE self)
VALUE rb_str_new2(const char *)
static VALUE ossl_dh_get_params(VALUE self)
VALUE rb_str_new(const char *, long)