Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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)
GetPKey
#define GetPKey(obj, pkey)
Definition: ossl_pkey.h:30
rb_eRuntimeError
VALUE rb_eRuntimeError
Definition: error.c:510
obj
static VALUE VALUE obj
Definition: tcltklib.c:3158
type
int type
Definition: tcltklib.c:111
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186
ossl_raise
void ossl_raise(VALUE exc, const char *fmt,...)
Definition: ossl.c:328

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

Definition at line 103 of file ossl_pkey_dh.c.

References memset(), NULL, ossl_generate_cb(), rb_block_given_p(), rb_jump_tag(), rb_thread_call_without_gvl(), and size.

Referenced by ossl_dh_initialize(), and ossl_dh_s_generate().

static VALUE dh_instance | ( | VALUE | klass,
|  | DH * | dh
| ) |  |
| static

Definition at line 41 of file ossl_pkey_dh.c.

References obj, Qfalse, and WrapPKey.

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

void Init_ossl_dh | ( | void |  | ) |

Definition at line 589 of file ossl_pkey_dh.c.

References cDH, cPKey, DEF_OSSL_PKEY_BN, DEFAULT_DH_1024_GEN, DEFAULT_DH_1024_PRIM, DEFAULT_DH_512_GEN, DEFAULT_DH_512_PRIM, eDHError, ePKeyError, mOSSL, mPKey, ossl_create_dh(), OSSL_DEFAULT_DH_1024, OSSL_DEFAULT_DH_512, ossl_dh_check_params(), ossl_dh_compute_key(), ossl_dh_export(), ossl_dh_generate_key(), ossl_dh_get_params(), ossl_dh_initialize(), ossl_dh_is_private(), ossl_dh_is_public(), ossl_dh_s_generate(), ossl_dh_to_der(), ossl_dh_to_public_key(), ossl_dh_to_text(), p, rb_define_alias(), rb_define_class_under(), rb_define_method(), rb_define_module(), rb_define_module_under(), and rb_define_singleton_method().

Referenced by Init_ossl_pkey().

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, len, NULL, ossl_raise(), rb_str_new(), rb_str_set_len(), RSTRING_PTR, and str.

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(), ossl_raise(), out, and str.

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

Definition at line 205 of file ossl_pkey_dh.c.

References arg, dh_generate(), eDHError, FIX2INT, FIXNUM_P, GetPKey, in, NIL_P(), NULL, NUM2INT, OSSL_BIO_reset, ossl_obj2bio(), ossl_raise(), ossl_to_der_if_possible(), and rb_scan_args().

Referenced by Init_ossl_dh().

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, obj, 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, obj, 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, len, NULL, ossl_raise(), ossl_str_adjust, p, rb_str_new(), RSTRING_PTR, and str.

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, obj, 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(), ossl_raise(), out, and str.

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

Definition at line 35 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh(), ossl_create_dh(), ossl_dh_compute_key(), ossl_dh_export(), ossl_dh_generate_key(), ossl_dh_initialize(), ossl_dh_new(), ossl_dh_s_generate(), ossl_dh_to_der(), ossl_dh_to_public_key(), and ossl_dh_to_text().

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().