Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
ossl_pkey_rsa.c File Reference
`#include "ossl.h"`
Include dependency graph for ossl_pkey_rsa.c:

Go to the source code of this file.

## Macros
#define | GetPKeyRSA(obj, pkey)
#define | RSA_HAS_PRIVATE(rsa) ((rsa)->p && (rsa)->q)
#define | RSA_PRIVATE(obj, rsa) (RSA_HAS_PRIVATE(rsa)||OSSL_PKEY_IS_PRIVATE(obj))
#define | ossl_rsa_buf_size(pkey) (RSA_size((pkey)->pkey.rsa)+16)
#define | DefRSAConst(x) rb_define_const(cRSA, #x,INT2FIX(RSA_##x))

## Functions
static VALUE | rsa_instance (VALUE klass, RSA *rsa)
VALUE | ossl_rsa_new (EVP_PKEY *pkey)
static RSA * | rsa_generate (int size, unsigned long exp)
static VALUE | ossl_rsa_s_generate (int argc, VALUE *argv, VALUE klass)
static VALUE | ossl_rsa_initialize (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_is_public (VALUE self)
static VALUE | ossl_rsa_is_private (VALUE self)
static VALUE | ossl_rsa_export (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_to_der (VALUE self)
static VALUE | ossl_rsa_public_encrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_public_decrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_private_encrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_private_decrypt (int argc, VALUE *argv, VALUE self)
static VALUE | ossl_rsa_get_params (VALUE self)
static VALUE | ossl_rsa_to_text (VALUE self)
static VALUE | ossl_rsa_to_public_key (VALUE self)
void | Init_ossl_rsa ()

## Variables
VALUE | cRSA
VALUE | eRSAError

## Macro Definition Documentation

#define DefRSAConst | ( |  | x | ) | rb_define_const(cRSA, #x,INT2FIX(RSA_##x))

Definition at line 625 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa().

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

Value:
do { \
GetPKey((obj), (pkey)); \
if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_RSA) { /* PARANOIA? */ \
ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
} \
} 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_rsa.c.

Referenced by ossl_rsa_export(), ossl_rsa_get_params(), ossl_rsa_is_private(), ossl_rsa_is_public(), ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), ossl_rsa_public_encrypt(), ossl_rsa_to_der(), ossl_rsa_to_public_key(), and ossl_rsa_to_text().

#define ossl_rsa_buf_size | ( |  | pkey | ) | (RSA_size((pkey)->pkey.rsa)+16)

Definition at line 374 of file ossl_pkey_rsa.c.

Referenced by ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), and ossl_rsa_public_encrypt().

#define RSA_HAS_PRIVATE | ( |  | rsa | ) | ((rsa)->p && (rsa)->q)

Definition at line 22 of file ossl_pkey_rsa.c.

Referenced by ossl_rsa_export(), and ossl_rsa_to_der().

#define RSA_PRIVATE | ( |  | obj,
|  |  | rsa
| ) |  | (RSA_HAS_PRIVATE(rsa)||OSSL_PKEY_IS_PRIVATE(obj))

Definition at line 23 of file ossl_pkey_rsa.c.

Referenced by ossl_rsa_is_private(), ossl_rsa_private_decrypt(), and ossl_rsa_private_encrypt().

## Function Documentation

void Init_ossl_rsa | ( | void |  | ) |

Definition at line 628 of file ossl_pkey_rsa.c.

References cPKey, cRSA, d, DEF_OSSL_PKEY_BN, DefRSAConst, e, ePKeyError, eRSAError, mOSSL, mPKey, n, ossl_rsa_export(), ossl_rsa_get_params(), ossl_rsa_initialize(), ossl_rsa_is_private(), ossl_rsa_is_public(), ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), ossl_rsa_public_encrypt(), ossl_rsa_s_generate(), ossl_rsa_to_der(), ossl_rsa_to_public_key(), ossl_rsa_to_text(), p, q, 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 VALUE ossl_rsa_export | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 302 of file ossl_pkey_rsa.c.

References eOSSLError, eRSAError, GetCipherPtr(), GetPKeyRSA, NIL_P(), NULL, ossl_membio2str(), OSSL_MIN_PWD_LEN, ossl_pem_passwd_cb(), ossl_raise(), out, rb_scan_args(), RSA_HAS_PRIVATE, RSTRING_LENINT, RSTRING_PTR, str, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_get_params | ( | VALUE | self | ) |
| static

Definition at line 510 of file ossl_pkey_rsa.c.

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

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_initialize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 203 of file ossl_pkey_rsa.c.

References arg, eRSAError, FIX2INT, FIXNUM_P, GetPKey, in, NIL_P(), NULL, NUM2ULONG, OSSL_BIO_reset, ossl_obj2bio(), ossl_pem_passwd_cb(), ossl_raise(), ossl_to_der_if_possible(), rb_scan_args(), rsa_generate(), and StringValuePtr.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_is_private | ( | VALUE | self | ) |
| static

Definition at line 283 of file ossl_pkey_rsa.c.

References GetPKeyRSA, Qfalse, Qtrue, and RSA_PRIVATE.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_is_public | ( | VALUE | self | ) |
| static

Definition at line 265 of file ossl_pkey_rsa.c.

References GetPKeyRSA, and Qtrue.

Referenced by Init_ossl_rsa().

VALUE ossl_rsa_new | ( | EVP_PKEY * | pkey | ) |

Definition at line 56 of file ossl_pkey_rsa.c.

References cRSA, eRSAError, NULL, obj, ossl_raise(), Qfalse, rb_eTypeError, rsa_instance(), and WrapPKey.

Referenced by ossl_pkey_new().

static VALUE ossl_rsa_private_decrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 475 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len(), RSA_PRIVATE, RSTRING_LENINT, RSTRING_PTR, str, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_private_encrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 443 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len(), RSA_PRIVATE, RSTRING_LENINT, RSTRING_PTR, str, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_public_decrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 414 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len(), RSTRING_LENINT, RSTRING_PTR, str, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_public_encrypt | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 385 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, NUM2INT, ossl_raise(), ossl_rsa_buf_size, rb_scan_args(), rb_str_new(), rb_str_set_len(), RSTRING_LENINT, RSTRING_PTR, str, and StringValue.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_s_generate | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |
| static

Definition at line 162 of file ossl_pkey_rsa.c.

References eRSAError, NIL_P(), NULL, NUM2INT, NUM2ULONG, obj, ossl_raise(), Qfalse, rb_scan_args(), rsa_generate(), rsa_instance(), and size.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_der | ( | VALUE | self | ) |
| static

Definition at line 350 of file ossl_pkey_rsa.c.

References _, eRSAError, GetPKeyRSA, int, len, NULL, ossl_raise(), ossl_str_adjust, p, rb_str_new(), RSA_HAS_PRIVATE, RSTRING_PTR, and str.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_public_key | ( | VALUE | self | ) |
| static

Definition at line 568 of file ossl_pkey_rsa.c.

References CLASS_OF, eRSAError, GetPKeyRSA, NULL, obj, ossl_raise(), Qfalse, and rsa_instance().

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_text | ( | VALUE | self | ) |
| static

Definition at line 542 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, ossl_membio2str(), ossl_raise(), out, and str.

Referenced by Init_ossl_rsa().

static RSA* rsa_generate | ( | int | size,
|  | unsigned long | exp
| ) |  |
| static

Definition at line 98 of file ossl_pkey_rsa.c.

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

Referenced by ossl_rsa_initialize(), and ossl_rsa_s_generate().

static VALUE rsa_instance | ( | VALUE | klass,
|  | RSA * | rsa
| ) |  |
| static

Definition at line 35 of file ossl_pkey_rsa.c.

References obj, Qfalse, and WrapPKey.

Referenced by ossl_rsa_new(), ossl_rsa_s_generate(), and ossl_rsa_to_public_key().

## Variable Documentation

VALUE cRSA

Definition at line 28 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa(), and ossl_rsa_new().

VALUE eRSAError

Definition at line 29 of file ossl_pkey_rsa.c.

Referenced by Init_ossl_rsa(), ossl_rsa_export(), ossl_rsa_initialize(), ossl_rsa_new(), ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), ossl_rsa_public_encrypt(), ossl_rsa_s_generate(), ossl_rsa_to_der(), ossl_rsa_to_public_key(), and ossl_rsa_to_text().