Ruby  1.9.3p551(2014-11-13revision48407)
Macros | Functions | Variables
ossl_pkey_rsa.c File Reference
#include "ossl.h"

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, int 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 557 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)
#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))

Function Documentation

void Init_ossl_rsa ( void  )
static VALUE ossl_rsa_export ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE ossl_rsa_get_params ( VALUE  self)
static

Definition at line 442 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
static VALUE ossl_rsa_is_private ( VALUE  self)
static

Definition at line 218 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 200 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(), and WrapPKey.

Referenced by ossl_pkey_new().

static VALUE ossl_rsa_private_decrypt ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE ossl_rsa_private_encrypt ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE ossl_rsa_public_decrypt ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE ossl_rsa_public_encrypt ( int  argc,
VALUE argv,
VALUE  self 
)
static
static VALUE ossl_rsa_s_generate ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 97 of file ossl_pkey_rsa.c.

References eRSAError, NIL_P, NULL, NUM2INT, 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 282 of file ossl_pkey_rsa.c.

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

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_public_key ( VALUE  self)
static

Definition at line 500 of file ossl_pkey_rsa.c.

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

Referenced by Init_ossl_rsa().

static VALUE ossl_rsa_to_text ( VALUE  self)
static

Definition at line 474 of file ossl_pkey_rsa.c.

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

Referenced by Init_ossl_rsa().

static RSA* rsa_generate ( int  size,
int  exp 
)
static

Definition at line 80 of file ossl_pkey_rsa.c.

References NULL, ossl_generate_cb(), and rb_block_given_p().

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, 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