ext/openssl/ossl_pkey_rsa.c File Reference

#include "ossl.h"

Go to the source code of this file.

Defines

#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


Define Documentation

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

Definition at line 626 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)

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 375 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 629 of file ossl_pkey_rsa.c.

References cPKey, cRSA, DEF_OSSL_PKEY_BN, DefRSAConst, ePKeyError, eRSAError, mOSSL, mPKey, 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(), 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 303 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(), rb_scan_args(), RSA_HAS_PRIVATE, RSTRING_LENINT, RSTRING_PTR, StringValue, and VALUE.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_get_params ( VALUE  self  )  [static]

Definition at line 511 of file ossl_pkey_rsa.c.

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

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 eRSAError, FIX2INT, FIXNUM_P, GetPKey, 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(), StringValuePtr, and VALUE.

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, ossl_raise(), Qfalse, rb_eTypeError, rsa_instance(), VALUE, and WrapPKey.

Referenced by ossl_pkey_new().

static VALUE ossl_rsa_private_decrypt ( int  argc,
VALUE *  argv,
VALUE  self 
) [static]

Definition at line 476 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, StringValue, and VALUE.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_private_encrypt ( int  argc,
VALUE *  argv,
VALUE  self 
) [static]

Definition at line 444 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, StringValue, and VALUE.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_public_decrypt ( int  argc,
VALUE *  argv,
VALUE  self 
) [static]

Definition at line 415 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, StringValue, and VALUE.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_public_encrypt ( int  argc,
VALUE *  argv,
VALUE  self 
) [static]

Definition at line 386 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, StringValue, and VALUE.

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, ossl_raise(), Qfalse, rb_scan_args(), rsa_generate(), rsa_instance(), size, and VALUE.

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_der ( VALUE  self  )  [static]

Definition at line 351 of file ossl_pkey_rsa.c.

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

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_public_key ( VALUE  self  )  [static]

Definition at line 569 of file ossl_pkey_rsa.c.

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

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_text ( VALUE  self  )  [static]

Definition at line 543 of file ossl_pkey_rsa.c.

References eRSAError, GetPKeyRSA, NULL, ossl_membio2str(), ossl_raise(), and VALUE.

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 NULL, ossl_generate_cb(), rb_block_given_p(), rb_jump_tag(), and rb_thread_call_without_gvl().

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 Qfalse, VALUE, 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().


Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7