| Ruby
    3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
    | 
 
 
 
Go to the documentation of this file.
   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); \ 
   92             dh = d2i_DHparams_bio(in, 
NULL);
 
   99     if (!EVP_PKEY_assign_DH(
pkey, dh)) {
 
  107 ossl_dh_initialize_copy(
VALUE self, 
VALUE other)
 
  111     const BIGNUM *pub, *priv;
 
  114     if (EVP_PKEY_base_id(
pkey) != EVP_PKEY_NONE)
 
  116     GetDH(other, dh_other);
 
  118     dh = DHparams_dup(dh_other);
 
  121     EVP_PKEY_assign_DH(
pkey, dh);
 
  123     DH_get0_key(dh_other, &pub, &priv);
 
  125         BIGNUM *pub2 = BN_dup(pub);
 
  126         BIGNUM *priv2 = BN_dup(priv);
 
  128         if (!pub2 || (priv && !priv2)) {
 
  130             BN_clear_free(priv2);
 
  133         DH_set0_key(dh, pub2, priv2);
 
  147 ossl_dh_is_public(
VALUE self)
 
  153     DH_get0_key(dh, &bn, 
NULL);
 
  166 ossl_dh_is_private(
VALUE self)
 
  172     DH_get0_key(dh, 
NULL, &bn);
 
  174 #if !defined(OPENSSL_NO_ENGINE) 
  175     return (bn || DH_get0_engine(dh)) ? 
Qtrue : 
Qfalse;
 
  192 ossl_dh_export(
VALUE self)
 
  199     if (!(out = BIO_new(BIO_s_mem()))) {
 
  202     if (!PEM_write_bio_DHparams(out, dh)) {
 
  221 ossl_dh_to_der(
VALUE self)
 
  229     if((
len = i2d_DHparams(dh, 
NULL)) <= 0)
 
  233     if(i2d_DHparams(dh, &p) < 0)
 
  249 ossl_dh_get_params(
VALUE self)
 
  256     DH_get0_pqg(dh, &p, &q, &g);
 
  280 ossl_dh_check_params(
VALUE self)
 
  283 #ifdef HAVE_EVP_PKEY_CHECK 
  288     pctx = EVP_PKEY_CTX_new(
pkey, 
NULL);
 
  291     ret = EVP_PKEY_param_check(pctx);
 
  292     EVP_PKEY_CTX_free(pctx);
 
  298     ret = DH_check(dh, &codes) == 1 && codes == 0;
 
  
#define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3)
VALUE rb_define_module_under(VALUE outer, const char *name)
VALUE ossl_to_der_if_possible(VALUE obj)
VALUE ossl_membio2str(BIO *bio)
BIO * ossl_obj2bio(volatile VALUE *pobj)
#define OSSL_BIO_reset(bio)
void ossl_clear_error(void)
#define ossl_str_adjust(str, p)
#define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2)
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
#define rb_str_new(str, len)
#define DEF_OSSL_PKEY_BN(class, keytype, name)
VALUE rb_cObject
Object class.
#define GetPKey(obj, pkey)
VALUE ossl_bn_new(const BIGNUM *bn)
void ossl_raise(VALUE exc, const char *fmt,...)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
#define RSTRING_PTR(string)
char str[HTML_ESCAPE_MAX_LEN+1]
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.