Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Functions | Variables
ossl_pkey.h File Reference

Go to the source code of this file.

## Data Structures
struct | ossl_generate_cb_arg

## Macros
#define | OSSL_PKEY_SET_PRIVATE(obj) rb_iv_set((obj), "private", Qtrue)
#define | OSSL_PKEY_SET_PUBLIC(obj) rb_iv_set((obj), "private", Qfalse)
#define | OSSL_PKEY_IS_PRIVATE(obj) (rb_iv_get((obj), "private") == Qtrue)
#define | NewPKey(klass) TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, 0)
#define | SetPKey(obj, pkey)
#define | GetPKey(obj, pkey)
#define | OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, _name, _get)
#define | OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3)
#define | OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2)
#define | OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3)
#define | OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2)
#define | OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, _name)
#define | OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3)
#define | OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2)
#define | DEF_OSSL_PKEY_BN(class, keytype, name)

## Functions
int | ossl_generate_cb_2 (int p, int n, BN_GENCB *cb)
void | ossl_generate_cb_stop (void *ptr)
VALUE | ossl_pkey_new (EVP_PKEY *)
void | ossl_pkey_check_public_key (const EVP_PKEY *)
EVP_PKEY * | GetPKeyPtr (VALUE)
EVP_PKEY * | DupPKeyPtr (VALUE)
EVP_PKEY * | GetPrivPKeyPtr (VALUE)
void | Init_ossl_pkey (void)
VALUE | ossl_rsa_new (EVP_PKEY *)
void | Init_ossl_rsa (void)
VALUE | ossl_dsa_new (EVP_PKEY *)
void | Init_ossl_dsa (void)
VALUE | ossl_dh_new (EVP_PKEY *)
void | Init_ossl_dh (void)
VALUE | ossl_ec_new (EVP_PKEY *)
void | Init_ossl_ec (void)

## Variables
VALUE | mPKey
VALUE | cPKey
VALUE | ePKeyError
const rb_data_type_t | ossl_evp_pkey_type
VALUE | cRSA
VALUE | eRSAError
VALUE | cDSA
VALUE | eDSAError
VALUE | cDH
VALUE | eDHError
VALUE | cEC
VALUE | eECError
VALUE | cEC_GROUP
VALUE | eEC_GROUP
VALUE | cEC_POINT
VALUE | eEC_POINT

## Macro Definition Documentation

## ◆ DEF_OSSL_PKEY_BN

#define DEF_OSSL_PKEY_BN | ( |  | class,
|  |  | keytype,
|  |  | name
| ) |  |

Value:
do { \
rb_define_method((class), #name, ossl_##keytype##_get_##name, 0);\
rb_define_method((class), #name "=", ossl_##keytype##_set_##name, 1);\
} while (0)

Definition at line 223 of file ossl_pkey.h.

## ◆ GetPKey

#define GetPKey | ( |  | obj,
|  |  | pkey
| ) |  |

Value:
do {\
TypedData_Get_Struct((obj), EVP_PKEY, &ossl_evp_pkey_type, (pkey)); \
if (!(pkey)) { \
rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
} \
} while (0)

Definition at line 31 of file ossl_pkey.h.

## ◆ NewPKey

#define NewPKey | ( |  | klass | ) | TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, 0)

Definition at line 22 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF2

#define OSSL_PKEY_BN_DEF2 | ( |  | _keytype,
|  |  | _type,
|  |  | _group,
|  |  | a1,
|  |  | a2
| ) |  |

Value:
OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2) \
OSSL_PKEY_BN_DEF_SETTER2(_keytype, _type, _group, a1, a2) \
OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a1) \
OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a2)

Definition at line 217 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF3

#define OSSL_PKEY_BN_DEF3 | ( |  | _keytype,
|  |  | _type,
|  |  | _group,
|  |  | a1,
|  |  | a2,
|  |  | a3
| ) |  |

Value:
OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3) \
OSSL_PKEY_BN_DEF_SETTER3(_keytype, _type, _group, a1, a2, a3) \
OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a1) \
OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a2) \
OSSL_PKEY_BN_DEF_SETTER_OLD(_keytype, _type, _group, a3)

Definition at line 210 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF_GETTER0

#define OSSL_PKEY_BN_DEF_GETTER0 | ( |  | _keytype,
|  |  | _type,
|  |  | _name,
|  |  | _get
| ) |  |

Value:
/* \
* call-seq: \
* _keytype##.##_name -> aBN \
*/ \
static VALUE ossl_##_keytype##_get_##_name(VALUE self) \
{ \
_type *obj; \
const BIGNUM *bn; \
\
Get##_type(self, obj); \
_get; \
if (bn == NULL) \
return Qnil; \
return ossl_bn_new(bn); \
}

Definition at line 92 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF_GETTER2

#define OSSL_PKEY_BN_DEF_GETTER2 | ( |  | _keytype,
|  |  | _type,
|  |  | _group,
|  |  | a1,
|  |  | a2
| ) |  |

Value:
OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
_type##_get0_##_group(obj, &bn, NULL)) \
OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
_type##_get0_##_group(obj, NULL, &bn))

Definition at line 114 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF_GETTER3

#define OSSL_PKEY_BN_DEF_GETTER3 | ( |  | _keytype,
|  |  | _type,
|  |  | _group,
|  |  | a1,
|  |  | a2,
|  |  | a3
| ) |  |

Value:
OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a1, \
_type##_get0_##_group(obj, &bn, NULL, NULL)) \
OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a2, \
_type##_get0_##_group(obj, NULL, &bn, NULL)) \
OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, a3, \
_type##_get0_##_group(obj, NULL, NULL, &bn))

Definition at line 106 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF_SETTER2

#define OSSL_PKEY_BN_DEF_SETTER2 | ( |  | _keytype,
|  |  | _type,
|  |  | _group,
|  |  | a1,
|  |  | a2
| ) |  |

Value:
/* \
* call-seq: \
* _keytype##.set_##_group(a1, a2) -> self \
*/ \
static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2) \
{ \
_type *obj; \
BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
\
Get##_type(self, obj); \
if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
(orig_bn2 && !(bn2 = BN_dup(orig_bn2)))) { \
BN_clear_free(bn1); \
BN_clear_free(bn2); \
ossl_raise(eBNError, NULL); \
} \
\
if (!_type##_set0_##_group(obj, bn1, bn2)) { \
BN_clear_free(bn1); \
BN_clear_free(bn2); \
ossl_raise(ePKeyError, #_type"_set0_"#_group); \
} \
return self; \
}

Definition at line 148 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF_SETTER3

#define OSSL_PKEY_BN_DEF_SETTER3 | ( |  | _keytype,
|  |  | _type,
|  |  | _group,
|  |  | a1,
|  |  | a2,
|  |  | a3
| ) |  |

Value:
/* \
* call-seq: \
* _keytype##.set_##_group(a1, a2, a3) -> self \
*/ \
static VALUE ossl_##_keytype##_set_##_group(VALUE self, VALUE v1, VALUE v2, VALUE v3) \
{ \
_type *obj; \
BIGNUM *bn1 = NULL, *orig_bn1 = NIL_P(v1) ? NULL : GetBNPtr(v1);\
BIGNUM *bn2 = NULL, *orig_bn2 = NIL_P(v2) ? NULL : GetBNPtr(v2);\
BIGNUM *bn3 = NULL, *orig_bn3 = NIL_P(v3) ? NULL : GetBNPtr(v3);\
\
Get##_type(self, obj); \
if ((orig_bn1 && !(bn1 = BN_dup(orig_bn1))) || \
(orig_bn2 && !(bn2 = BN_dup(orig_bn2))) || \
(orig_bn3 && !(bn3 = BN_dup(orig_bn3)))) { \
BN_clear_free(bn1); \
BN_clear_free(bn2); \
BN_clear_free(bn3); \
ossl_raise(eBNError, NULL); \
} \
\
if (!_type##_set0_##_group(obj, bn1, bn2, bn3)) { \
BN_clear_free(bn1); \
BN_clear_free(bn2); \
BN_clear_free(bn3); \
ossl_raise(ePKeyError, #_type"_set0_"#_group); \
} \
return self; \
}

Definition at line 120 of file ossl_pkey.h.

## ◆ OSSL_PKEY_BN_DEF_SETTER_OLD

#define OSSL_PKEY_BN_DEF_SETTER_OLD | ( |  | _keytype,
|  |  | _type,
|  |  | _group,
|  |  | _name
| ) |  |

Value:
/* \
* call-seq: \
* _keytype##.##_name = bn -> bn \
*/ \
static VALUE ossl_##_keytype##_set_##_name(VALUE self, VALUE bignum) \
{ \
_type *obj; \
BIGNUM *bn; \
\
rb_warning("#"#_name"= is deprecated; use #set_"#_group); \
Get##_type(self, obj); \
if (NIL_P(bignum)) { \
BN_clear_free(obj->_name); \
obj->_name = NULL; \
return Qnil; \
} \
\
bn = GetBNPtr(bignum); \
if (obj->_name == NULL) \
obj->_name = BN_new(); \
if (obj->_name == NULL) \
ossl_raise(eBNError, NULL); \
if (BN_copy(obj->_name, bn) == NULL) \
ossl_raise(eBNError, NULL); \
return bignum; \
}

Definition at line 172 of file ossl_pkey.h.

## ◆ OSSL_PKEY_IS_PRIVATE

#define OSSL_PKEY_IS_PRIVATE | ( |  | obj | ) | (rb_iv_get((obj), "private") == Qtrue)

Definition at line 20 of file ossl_pkey.h.

## ◆ OSSL_PKEY_SET_PRIVATE

#define OSSL_PKEY_SET_PRIVATE | ( |  | obj | ) | rb_iv_set((obj), "private", Qtrue)

Definition at line 18 of file ossl_pkey.h.

## ◆ OSSL_PKEY_SET_PUBLIC

#define OSSL_PKEY_SET_PUBLIC | ( |  | obj | ) | rb_iv_set((obj), "private", Qfalse)

Definition at line 19 of file ossl_pkey.h.

## ◆ SetPKey

#define SetPKey | ( |  | obj,
|  |  | pkey
| ) |  |

Value:
do { \
if (!(pkey)) { \
rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
} \
RTYPEDDATA_DATA(obj) = (pkey); \
OSSL_PKEY_SET_PUBLIC(obj); \
} while (0)

Definition at line 24 of file ossl_pkey.h.

## Function Documentation

## ◆ DupPKeyPtr()

EVP_PKEY* DupPKeyPtr | ( | VALUE |  | ) |

Definition at line 252 of file ossl_pkey.c.

References EVP_PKEY_up_ref, GetPKey, and obj.

## ◆ GetPKeyPtr()

EVP_PKEY* GetPKeyPtr | ( | VALUE |  | ) |

Definition at line 229 of file ossl_pkey.c.

References GetPKey, and obj.

## ◆ GetPrivPKeyPtr()

EVP_PKEY* GetPrivPKeyPtr | ( | VALUE |  | ) |

Definition at line 239 of file ossl_pkey.c.

References obj, and rb_funcallv.

## ◆ Init_ossl_dh()

void Init_ossl_dh | ( | void |  | ) |

Definition at line 576 of file ossl_pkey_dh.c.

References cDH, cPKey, eDHError, eOSSLError, ePKeyError, mOSSL, mPKey, rb_cObject, rb_define_class_under(), rb_define_module_under(), and rb_define_singleton_method().

## ◆ Init_ossl_dsa()

void Init_ossl_dsa | ( | void |  | ) |

Definition at line 609 of file ossl_pkey_dsa.c.

References cDSA, cPKey, eDSAError, eOSSLError, ePKeyError, mOSSL, mPKey, rb_cObject, rb_define_class_under(), rb_define_module_under(), and rb_define_singleton_method().

## ◆ Init_ossl_ec()

void Init_ossl_ec | ( | void |  | ) |

Definition at line 1650 of file ossl_pkey_ec.c.

References cEC, cEC_GROUP, cEC_POINT, cPKey, eEC_GROUP, eEC_POINT, eECError, eOSSLError, ePKeyError, mOSSL, mPKey, rb_cObject, rb_define_class_under(), rb_define_module_under(), and rb_eStandardError.

## ◆ Init_ossl_pkey()

void Init_ossl_pkey | ( | void |  | ) |

Definition at line 412 of file ossl_pkey.c.

References cPKey, eOSSLError, ePKeyError, mOSSL, mPKey, rb_cObject, rb_define_class_under(), rb_define_module(), rb_define_module_function(), rb_define_module_under(), and rb_eStandardError.

## ◆ Init_ossl_rsa()

void Init_ossl_rsa | ( | void |  | ) |

Definition at line 880 of file ossl_pkey_rsa.c.

References cPKey, cRSA, eOSSLError, ePKeyError, eRSAError, mOSSL, mPKey, rb_cObject, rb_define_class_under(), rb_define_module_under(), and rb_define_singleton_method().

## ◆ ossl_dh_new()

VALUE ossl_dh_new | ( | EVP_PKEY * |  | ) |

Definition at line 58 of file ossl_pkey_dh.c.

References obj.

## ◆ ossl_dsa_new()

VALUE ossl_dsa_new | ( | EVP_PKEY * |  | ) |

Definition at line 72 of file ossl_pkey_dsa.c.

References obj.

## ◆ ossl_ec_new()

VALUE ossl_ec_new | ( | EVP_PKEY * |  | ) |

Definition at line 87 of file ossl_pkey_ec.c.

References obj.

## ◆ ossl_generate_cb_2()

int ossl_generate_cb_2 | ( | int | p,
|  | int | n,
|  | BN_GENCB * | cb
| ) |  |

Definition at line 39 of file ossl_pkey.c.

References arg, BN_GENCB_get_arg, int, INT2NUM, n, rb_ary_new2, rb_ary_store(), rb_protect(), rb_thread_call_with_gvl(), rb_yield(), and ossl_generate_cb_arg::state.

## ◆ ossl_generate_cb_stop()

void ossl_generate_cb_stop | ( | void * | ptr | ) |

Definition at line 72 of file ossl_pkey.c.

References arg, and ptr.

## ◆ ossl_pkey_check_public_key()

void ossl_pkey_check_public_key | ( | const EVP_PKEY * |  | ) |

Definition at line 189 of file ossl_pkey.c.

References ePKeyError, n, NULL, ossl_raise(), and ptr.

## ◆ ossl_pkey_new()

VALUE ossl_pkey_new | ( | EVP_PKEY * |  | ) |

Definition at line 129 of file ossl_pkey.c.

References obj, and rb_protect().

## ◆ ossl_rsa_new()

VALUE ossl_rsa_new | ( | EVP_PKEY * |  | ) |

Definition at line 73 of file ossl_pkey_rsa.c.

References obj.

## Variable Documentation

## ◆ cDH

VALUE cDH

Definition at line 29 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh().

## ◆ cDSA

VALUE cDSA

Definition at line 43 of file ossl_pkey_dsa.c.

Referenced by Init_ossl_dsa().

## ◆ cEC

VALUE cEC

Definition at line 43 of file ossl_pkey_ec.c.

Referenced by Init_ossl_ec().

## ◆ cEC_GROUP

VALUE cEC_GROUP

Definition at line 45 of file ossl_pkey_ec.c.

Referenced by Init_ossl_ec().

## ◆ cEC_POINT

VALUE cEC_POINT

Definition at line 47 of file ossl_pkey_ec.c.

Referenced by Init_ossl_ec().

## ◆ cPKey

VALUE cPKey

Definition at line 16 of file ossl_pkey.c.

Referenced by Init_ossl_dh(), Init_ossl_dsa(), Init_ossl_ec(), Init_ossl_pkey(), and Init_ossl_rsa().

## ◆ cRSA

VALUE cRSA

Definition at line 44 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa().

## ◆ eDHError

VALUE eDHError

Definition at line 30 of file ossl_pkey_dh.c.

Referenced by Init_ossl_dh().

## ◆ eDSAError

VALUE eDSAError

Definition at line 44 of file ossl_pkey_dsa.c.

Referenced by Init_ossl_dsa().

## ◆ eEC_GROUP

VALUE eEC_GROUP

Definition at line 46 of file ossl_pkey_ec.c.

Referenced by Init_ossl_ec().

## ◆ eEC_POINT

VALUE eEC_POINT

Definition at line 48 of file ossl_pkey_ec.c.

Referenced by Init_ossl_ec().

## ◆ eECError

VALUE eECError

Definition at line 44 of file ossl_pkey_ec.c.

Referenced by Init_ossl_ec().

## ◆ ePKeyError

VALUE ePKeyError

Definition at line 17 of file ossl_pkey.c.

Referenced by Init_ossl_dh(), Init_ossl_dsa(), Init_ossl_ec(), Init_ossl_pkey(), Init_ossl_rsa(), and ossl_pkey_check_public_key().

## ◆ eRSAError

VALUE eRSAError

Definition at line 45 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa().

## ◆ mPKey

VALUE mPKey

Definition at line 15 of file ossl_pkey.c.

Referenced by Init_ossl_dh(), Init_ossl_dsa(), Init_ossl_ec(), Init_ossl_pkey(), and Init_ossl_rsa().

## ◆ ossl_evp_pkey_type

const rb_data_type_t ossl_evp_pkey_type

Definition at line 87 of file ossl_pkey.c.

rb_warning
void rb_warning(const char *fmt,...)
Definition: error.c:334
VALUE
unsigned long VALUE
Definition: ruby.h:102
ePKeyError
VALUE ePKeyError
Definition: ossl_pkey.c:17
NULL
#define NULL
Definition: _sdbm.c:101
if
if((ID)(DISPID) nameid !=nameid)
Definition: win32ole.c:357
obj
const VALUE VALUE obj
Definition: rb_mjit_min_header-2.7.0.h:5742
OSSL_PKEY_BN_DEF_GETTER3
#define OSSL_PKEY_BN_DEF_GETTER3(_keytype, _type, _group, a1, a2, a3)
Definition: ossl_pkey.h:106
ossl_bn_new
VALUE ossl_bn_new(const BIGNUM *bn)
Definition: ossl_bn.c:58
ossl_evp_pkey_type
const rb_data_type_t ossl_evp_pkey_type
Definition: ossl_pkey.c:87
eBNError
VALUE eBNError
Definition: ossl_bn.c:52
rb_eRuntimeError
VALUE rb_eRuntimeError
Definition: error.c:920
OSSL_PKEY_BN_DEF_GETTER0
#define OSSL_PKEY_BN_DEF_GETTER0(_keytype, _type, _name, _get)
Definition: ossl_pkey.h:92
OSSL_PKEY_BN_DEF_GETTER2
#define OSSL_PKEY_BN_DEF_GETTER2(_keytype, _type, _group, a1, a2)
Definition: ossl_pkey.h:114
NIL_P
#define NIL_P(v)
Definition: ruby.h:482
GetBNPtr
#define GetBNPtr(obj)
Definition: ossl_bn.h:18
Qnil
#define Qnil
Definition: ruby.h:469
name
const char * name
Definition: nkf.c:208