Ruby  2.0.0p451(2014-02-24revision45167)
Macros | Functions | Variables
ossl_pkey_dh.c File Reference
#include "ossl.h"
Include dependency graph for ossl_pkey_dh.c:

Go to the source code of this file.

Macros

#define GetPKeyDH(obj, pkey)
 
#define DH_HAS_PRIVATE(dh)   ((dh)->priv_key)
 
#define DH_PRIVATE(dh)   DH_HAS_PRIVATE(dh)
 

Functions

static VALUE dh_instance (VALUE klass, DH *dh)
 
VALUE ossl_dh_new (EVP_PKEY *pkey)
 
static DH * dh_generate (int size, int gen)
 
static VALUE ossl_dh_s_generate (int argc, VALUE *argv, VALUE klass)
 
static VALUE ossl_dh_initialize (int argc, VALUE *argv, VALUE self)
 
static VALUE ossl_dh_is_public (VALUE self)
 
static VALUE ossl_dh_is_private (VALUE self)
 
static VALUE ossl_dh_export (VALUE self)
 
static VALUE ossl_dh_to_der (VALUE self)
 
static VALUE ossl_dh_get_params (VALUE self)
 
static VALUE ossl_dh_to_text (VALUE self)
 
static VALUE ossl_dh_to_public_key (VALUE self)
 
static VALUE ossl_dh_check_params (VALUE self)
 
static VALUE ossl_dh_generate_key (VALUE self)
 
static VALUE ossl_dh_compute_key (VALUE self, VALUE pub)
 
static DH * ossl_create_dh (unsigned char *p, size_t plen, unsigned char *g, size_t glen)
 
void Init_ossl_dh ()
 

Variables

VALUE cDH
 
VALUE eDHError
 
static unsigned char DEFAULT_DH_512_PRIM []
 
static unsigned char DEFAULT_DH_512_GEN [] = { 0x02 }
 
DH * OSSL_DEFAULT_DH_512 = NULL
 
static unsigned char DEFAULT_DH_1024_PRIM []
 
static unsigned char DEFAULT_DH_1024_GEN [] = { 0x02 }
 
DH * OSSL_DEFAULT_DH_1024 = NULL
 

Macro Definition Documentation

#define DH_HAS_PRIVATE (   dh)    ((dh)->priv_key)

Definition at line 22 of file ossl_pkey_dh.c.

#define DH_PRIVATE (   dh)    DH_HAS_PRIVATE(dh)

Definition at line 27 of file ossl_pkey_dh.c.

Referenced by ossl_dh_is_private().

#define GetPKeyDH (   obj,
  pkey 
)
Value:
do { \
GetPKey((obj), (pkey)); \
if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_DH) { /* PARANOIA? */ \
ossl_raise(rb_eRuntimeError, "THIS IS NOT A DH!") ; \
} \
} while (0)
#define GetPKey(obj, pkey)
Definition: ossl_pkey.h:30
VALUE rb_eRuntimeError
Definition: error.c:510
int type
Definition: tcltklib.c:111
void ossl_raise(VALUE exc, const char *fmt,...)
Definition: ossl.c:332
if(c== ')') lex_state
Definition: ripper.y:7588

Definition at line 15 of file ossl_pkey_dh.c.

Referenced by ossl_dh_check_params(), ossl_dh_compute_key(), ossl_dh_export(), ossl_dh_generate_key(), ossl_dh_get_params(), ossl_dh_is_private(), ossl_dh_is_public(), ossl_dh_to_der(), ossl_dh_to_public_key(), and ossl_dh_to_text().

Function Documentation

static DH* dh_generate ( int  size,
int  gen 
)
static
static VALUE dh_instance ( VALUE  klass,
DH *  dh 
)
static

Definition at line 41 of file ossl_pkey_dh.c.

References Qfalse, and WrapPKey.

Referenced by ossl_dh_new(), ossl_dh_s_generate(), and ossl_dh_to_public_key().

void Init_ossl_dh ( void  )
static DH* ossl_create_dh ( unsigned char *  p,
size_t  plen,
unsigned char *  g,
size_t  glen 
)
static

Definition at line 570 of file ossl_pkey_dh.c.

References eDHError, NULL, ossl_raise(), and rb_long2int.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_check_params ( VALUE  self)
static

Definition at line 438 of file ossl_pkey_dh.c.

References GetPKeyDH, Qfalse, and Qtrue.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_compute_key ( VALUE  self,
VALUE  pub 
)
static

Definition at line 496 of file ossl_pkey_dh.c.

References eDHError, GetBNPtr(), GetPKeyDH, NULL, ossl_raise(), rb_str_new(), rb_str_set_len(), and RSTRING_PTR.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_export ( VALUE  self)
static

Definition at line 288 of file ossl_pkey_dh.c.

References eDHError, GetPKeyDH, NULL, ossl_membio2str(), and ossl_raise().

Referenced by Init_ossl_dh().

static VALUE ossl_dh_generate_key ( VALUE  self)
static

Definition at line 471 of file ossl_pkey_dh.c.

References eDHError, GetPKeyDH, and ossl_raise().

Referenced by Init_ossl_dh().

static VALUE ossl_dh_get_params ( VALUE  self)
static

Definition at line 345 of file ossl_pkey_dh.c.

References GetPKeyDH, hash(), ossl_bn_new(), rb_hash_aset(), rb_hash_new(), and rb_str_new2.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_initialize ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE ossl_dh_is_private ( VALUE  self)
static

Definition at line 270 of file ossl_pkey_dh.c.

References DH_PRIVATE, GetPKeyDH, Qfalse, and Qtrue.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_is_public ( VALUE  self)
static

Definition at line 253 of file ossl_pkey_dh.c.

References GetPKeyDH, Qfalse, and Qtrue.

Referenced by Init_ossl_dh().

VALUE ossl_dh_new ( EVP_PKEY *  pkey)

Definition at line 62 of file ossl_pkey_dh.c.

References cDH, dh_instance(), eDHError, NULL, ossl_raise(), Qfalse, rb_eTypeError, and WrapPKey.

Referenced by ossl_pkey_new().

static VALUE ossl_dh_s_generate ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 162 of file ossl_pkey_dh.c.

References dh_generate(), dh_instance(), eDHError, NULL, NUM2INT, ossl_raise(), Qfalse, rb_scan_args(), and size.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_to_der ( VALUE  self)
static

Definition at line 317 of file ossl_pkey_dh.c.

References eDHError, GetPKeyDH, NULL, ossl_raise(), ossl_str_adjust, p, rb_str_new(), and RSTRING_PTR.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_to_public_key ( VALUE  self)
static

Definition at line 412 of file ossl_pkey_dh.c.

References CLASS_OF, dh_instance(), eDHError, GetPKeyDH, NULL, ossl_raise(), and Qfalse.

Referenced by Init_ossl_dh().

static VALUE ossl_dh_to_text ( VALUE  self)
static

Definition at line 371 of file ossl_pkey_dh.c.

References eDHError, GetPKeyDH, NULL, ossl_membio2str(), and ossl_raise().

Referenced by Init_ossl_dh().

Variable Documentation

VALUE cDH

Definition at line 34 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh(), and ossl_dh_new().

unsigned char DEFAULT_DH_1024_GEN[] = { 0x02 }
static

Definition at line 566 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh().

unsigned char DEFAULT_DH_1024_PRIM[]
static
Initial value:
= {
0x9d, 0x25, 0x39, 0x5c, 0xb4, 0x54, 0x8a, 0xff,
0x25, 0xe6, 0xd6, 0x9f, 0x4c, 0xc3, 0xc1, 0x8d,
0xa1, 0xfa, 0xba, 0x88, 0x4c, 0x53, 0xa9, 0x74,
0xda, 0xfa, 0xba, 0x0b, 0x20, 0xbe, 0x40, 0xd7,
0xba, 0xe7, 0x1d, 0x70, 0x28, 0x61, 0x60, 0x4c,
0x49, 0x01, 0x5f, 0xd9, 0x0f, 0x60, 0x16, 0x3d,
0xba, 0xd3, 0xa9, 0x5e, 0xfa, 0x98, 0x64, 0x60,
0x26, 0x0e, 0x04, 0x75, 0xd8, 0x13, 0xd7, 0x31,
0xb4, 0x8e, 0xad, 0xeb, 0x9c, 0x57, 0x4c, 0x8f,
0x65, 0xf3, 0x90, 0x16, 0x31, 0xdc, 0x15, 0x6f,
0x7d, 0x1d, 0x00, 0xae, 0x76, 0xf2, 0xd1, 0x11,
0xd1, 0x4f, 0x88, 0x7b, 0x29, 0x9f, 0xf6, 0xce,
0x68, 0xef, 0x57, 0xe7, 0x85, 0xf2, 0x40, 0x54,
0x1c, 0x12, 0x40, 0xa2, 0x35, 0x25, 0xcf, 0x12,
0xa3, 0xe1, 0x07, 0x8e, 0xdb, 0x1d, 0xb4, 0x14,
0xff, 0x57, 0xe7, 0x19, 0x8d, 0x51, 0x77, 0x83
}

Definition at line 548 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh().

unsigned char DEFAULT_DH_512_GEN[] = { 0x02 }
static

Definition at line 538 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh().

unsigned char DEFAULT_DH_512_PRIM[]
static
Initial value:
= {
0xf4, 0xcd, 0x71, 0xe5, 0x8d, 0x18, 0x3f, 0x98,
0x9f, 0x4f, 0x60, 0xb0, 0x02, 0x2e, 0xfe, 0x7c,
0x09, 0xdf, 0x15, 0xc4, 0x1c, 0x71, 0x63, 0xba,
0x04, 0xb8, 0x27, 0x94, 0x44, 0xc8, 0x93, 0xa8,
0x48, 0x4c, 0xca, 0x6d, 0x7a, 0xae, 0x18, 0x4a,
0x81, 0x91, 0xb6, 0xce, 0x4d, 0x8e, 0xf6, 0xe5,
0x08, 0x04, 0x8c, 0x52, 0x8f, 0xe3, 0x4a, 0x31,
0x44, 0x47, 0x19, 0xa1, 0x4a, 0xc8, 0x8b, 0xcb,
}

Definition at line 528 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh().

VALUE eDHError
DH* OSSL_DEFAULT_DH_1024 = NULL

Definition at line 567 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh(), and ossl_default_tmp_dh_callback().

DH* OSSL_DEFAULT_DH_512 = NULL

Definition at line 539 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh(), and ossl_default_tmp_dh_callback().